Lines Matching refs:ctx

25 int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,  in HMAC_Init_ex()  argument
35 if (md != NULL && md != ctx->md && (key == NULL || len < 0)) in HMAC_Init_ex()
39 ctx->md = md; in HMAC_Init_ex()
40 else if (ctx->md != NULL) in HMAC_Init_ex()
41 md = ctx->md; in HMAC_Init_ex()
61 if (!EVP_DigestInit_ex(ctx->md_ctx, md, impl) in HMAC_Init_ex()
62 || !EVP_DigestUpdate(ctx->md_ctx, key, len) in HMAC_Init_ex()
63 || !EVP_DigestFinal_ex(ctx->md_ctx, keytmp, in HMAC_Init_ex()
78 if (!EVP_DigestInit_ex(ctx->i_ctx, md, impl) in HMAC_Init_ex()
79 || !EVP_DigestUpdate(ctx->i_ctx, pad, in HMAC_Init_ex()
85 if (!EVP_DigestInit_ex(ctx->o_ctx, md, impl) in HMAC_Init_ex()
86 || !EVP_DigestUpdate(ctx->o_ctx, pad, in HMAC_Init_ex()
90 if (!EVP_MD_CTX_copy_ex(ctx->md_ctx, ctx->i_ctx)) in HMAC_Init_ex()
102 int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md) in HMAC_Init() argument
105 HMAC_CTX_reset(ctx); in HMAC_Init()
106 return HMAC_Init_ex(ctx, key, len, md, NULL); in HMAC_Init()
110 int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len) in HMAC_Update() argument
112 if (!ctx->md) in HMAC_Update()
114 return EVP_DigestUpdate(ctx->md_ctx, data, len); in HMAC_Update()
117 int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) in HMAC_Final() argument
122 if (!ctx->md) in HMAC_Final()
125 if (!EVP_DigestFinal_ex(ctx->md_ctx, buf, &i)) in HMAC_Final()
127 if (!EVP_MD_CTX_copy_ex(ctx->md_ctx, ctx->o_ctx)) in HMAC_Final()
129 if (!EVP_DigestUpdate(ctx->md_ctx, buf, i)) in HMAC_Final()
131 if (!EVP_DigestFinal_ex(ctx->md_ctx, md, len)) in HMAC_Final()
138 size_t HMAC_size(const HMAC_CTX *ctx) in HMAC_size() argument
140 int size = EVP_MD_get_size((ctx)->md); in HMAC_size()
147 HMAC_CTX *ctx = OPENSSL_zalloc(sizeof(HMAC_CTX)); in HMAC_CTX_new() local
149 if (ctx != NULL) { in HMAC_CTX_new()
150 if (!HMAC_CTX_reset(ctx)) { in HMAC_CTX_new()
151 HMAC_CTX_free(ctx); in HMAC_CTX_new()
155 return ctx; in HMAC_CTX_new()
158 static void hmac_ctx_cleanup(HMAC_CTX *ctx) in hmac_ctx_cleanup() argument
160 EVP_MD_CTX_reset(ctx->i_ctx); in hmac_ctx_cleanup()
161 EVP_MD_CTX_reset(ctx->o_ctx); in hmac_ctx_cleanup()
162 EVP_MD_CTX_reset(ctx->md_ctx); in hmac_ctx_cleanup()
163 ctx->md = NULL; in hmac_ctx_cleanup()
166 void HMAC_CTX_free(HMAC_CTX *ctx) in HMAC_CTX_free() argument
168 if (ctx != NULL) { in HMAC_CTX_free()
169 hmac_ctx_cleanup(ctx); in HMAC_CTX_free()
170 EVP_MD_CTX_free(ctx->i_ctx); in HMAC_CTX_free()
171 EVP_MD_CTX_free(ctx->o_ctx); in HMAC_CTX_free()
172 EVP_MD_CTX_free(ctx->md_ctx); in HMAC_CTX_free()
173 OPENSSL_free(ctx); in HMAC_CTX_free()
177 static int hmac_ctx_alloc_mds(HMAC_CTX *ctx) in hmac_ctx_alloc_mds() argument
179 if (ctx->i_ctx == NULL) in hmac_ctx_alloc_mds()
180 ctx->i_ctx = EVP_MD_CTX_new(); in hmac_ctx_alloc_mds()
181 if (ctx->i_ctx == NULL) in hmac_ctx_alloc_mds()
183 if (ctx->o_ctx == NULL) in hmac_ctx_alloc_mds()
184 ctx->o_ctx = EVP_MD_CTX_new(); in hmac_ctx_alloc_mds()
185 if (ctx->o_ctx == NULL) in hmac_ctx_alloc_mds()
187 if (ctx->md_ctx == NULL) in hmac_ctx_alloc_mds()
188 ctx->md_ctx = EVP_MD_CTX_new(); in hmac_ctx_alloc_mds()
189 if (ctx->md_ctx == NULL) in hmac_ctx_alloc_mds()
194 int HMAC_CTX_reset(HMAC_CTX *ctx) in HMAC_CTX_reset() argument
196 hmac_ctx_cleanup(ctx); in HMAC_CTX_reset()
197 if (!hmac_ctx_alloc_mds(ctx)) { in HMAC_CTX_reset()
198 hmac_ctx_cleanup(ctx); in HMAC_CTX_reset()
240 void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags) in HMAC_CTX_set_flags() argument
242 EVP_MD_CTX_set_flags(ctx->i_ctx, flags); in HMAC_CTX_set_flags()
243 EVP_MD_CTX_set_flags(ctx->o_ctx, flags); in HMAC_CTX_set_flags()
244 EVP_MD_CTX_set_flags(ctx->md_ctx, flags); in HMAC_CTX_set_flags()
247 const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx) in HMAC_CTX_get_md() argument
249 return ctx->md; in HMAC_CTX_get_md()