Lines Matching refs:ctx
51 dtls_hmac_context_free(dtls_hmac_context_t *ctx) { in dtls_hmac_context_free() argument
52 free(ctx); in dtls_hmac_context_free()
65 dtls_hmac_context_free(dtls_hmac_context_t *ctx) { in dtls_hmac_context_free() argument
66 memb_free(&hmac_context_storage, ctx); in dtls_hmac_context_free()
76 dtls_hmac_update(dtls_hmac_context_t *ctx, in dtls_hmac_update() argument
78 assert(ctx); in dtls_hmac_update()
79 dtls_hash_update(&ctx->data, input, ilen); in dtls_hmac_update()
84 dtls_hmac_context_t *ctx; in dtls_hmac_new() local
86 ctx = dtls_hmac_context_new(); in dtls_hmac_new()
87 if (ctx) in dtls_hmac_new()
88 dtls_hmac_init(ctx, key, klen); in dtls_hmac_new()
90 return ctx; in dtls_hmac_new()
94 dtls_hmac_init(dtls_hmac_context_t *ctx, const unsigned char *key, size_t klen) { in dtls_hmac_init() argument
97 assert(ctx); in dtls_hmac_init()
99 memset(ctx, 0, sizeof(dtls_hmac_context_t)); in dtls_hmac_init()
102 dtls_hash_init(&ctx->data); in dtls_hmac_init()
103 dtls_hash_update(&ctx->data, key, klen); in dtls_hmac_init()
104 dtls_hash_finalize(ctx->pad, &ctx->data); in dtls_hmac_init()
106 memcpy(ctx->pad, key, klen); in dtls_hmac_init()
110 ctx->pad[i] ^= 0x36; in dtls_hmac_init()
112 dtls_hash_init(&ctx->data); in dtls_hmac_init()
113 dtls_hmac_update(ctx, ctx->pad, DTLS_HMAC_BLOCKSIZE); in dtls_hmac_init()
117 ctx->pad[i] ^= 0x6A; in dtls_hmac_init()
121 dtls_hmac_free(dtls_hmac_context_t *ctx) { in dtls_hmac_free() argument
122 if (ctx) in dtls_hmac_free()
123 dtls_hmac_context_free(ctx); in dtls_hmac_free()
127 dtls_hmac_finalize(dtls_hmac_context_t *ctx, unsigned char *result) { in dtls_hmac_finalize() argument
131 assert(ctx); in dtls_hmac_finalize()
134 len = dtls_hash_finalize(buf, &ctx->data); in dtls_hmac_finalize()
136 dtls_hash_init(&ctx->data); in dtls_hmac_finalize()
137 dtls_hash_update(&ctx->data, ctx->pad, DTLS_HMAC_BLOCKSIZE); in dtls_hmac_finalize()
138 dtls_hash_update(&ctx->data, buf, len); in dtls_hmac_finalize()
140 len = dtls_hash_finalize(result, &ctx->data); in dtls_hmac_finalize()
151 dtls_hmac_context_t *ctx; in main() local
159 ctx = dtls_hmac_new(argv[1], strlen(argv[1])); in main()
160 assert(ctx); in main()
161 dtls_hmac_update(ctx, argv[2], strlen(argv[2])); in main()
163 len = dtls_hmac_finalize(ctx, buf); in main()
169 dtls_hmac_free(ctx); in main()