summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/hmac/hmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/hmac/hmac.c')
-rw-r--r--src/lib/libcrypto/hmac/hmac.c56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c
index 84917662ca..7bf17eed96 100644
--- a/src/lib/libcrypto/hmac/hmac.c
+++ b/src/lib/libcrypto/hmac/hmac.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hmac.c,v 1.24 2017/03/03 10:39:07 inoguchi Exp $ */ 1/* $OpenBSD: hmac.c,v 1.25 2018/02/17 14:53:58 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -171,6 +171,38 @@ err:
171 return 0; 171 return 0;
172} 172}
173 173
174HMAC_CTX *
175HMAC_CTX_new(void)
176{
177 HMAC_CTX *ctx;
178
179 if ((ctx = calloc(1, sizeof(*ctx))) == NULL)
180 return NULL;
181
182 HMAC_CTX_init(ctx);
183
184 return ctx;
185}
186
187void
188HMAC_CTX_free(HMAC_CTX *ctx)
189{
190 if (ctx == NULL)
191 return;
192
193 HMAC_CTX_cleanup(ctx);
194
195 free(ctx);
196}
197
198int
199HMAC_CTX_reset(HMAC_CTX *ctx)
200{
201 HMAC_CTX_cleanup(ctx);
202 HMAC_CTX_init(ctx);
203 return 1;
204}
205
174void 206void
175HMAC_CTX_init(HMAC_CTX *ctx) 207HMAC_CTX_init(HMAC_CTX *ctx)
176{ 208{
@@ -206,6 +238,20 @@ HMAC_CTX_cleanup(HMAC_CTX *ctx)
206 explicit_bzero(ctx, sizeof(*ctx)); 238 explicit_bzero(ctx, sizeof(*ctx));
207} 239}
208 240
241void
242HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags)
243{
244 EVP_MD_CTX_set_flags(&ctx->i_ctx, flags);
245 EVP_MD_CTX_set_flags(&ctx->o_ctx, flags);
246 EVP_MD_CTX_set_flags(&ctx->md_ctx, flags);
247}
248
249const EVP_MD *
250HMAC_CTX_get_md(const HMAC_CTX *ctx)
251{
252 return ctx->md;
253}
254
209unsigned char * 255unsigned char *
210HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, 256HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d,
211 size_t n, unsigned char *md, unsigned int *md_len) 257 size_t n, unsigned char *md, unsigned int *md_len)
@@ -228,11 +274,3 @@ err:
228 HMAC_CTX_cleanup(&c); 274 HMAC_CTX_cleanup(&c);
229 return NULL; 275 return NULL;
230} 276}
231
232void
233HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags)
234{
235 EVP_MD_CTX_set_flags(&ctx->i_ctx, flags);
236 EVP_MD_CTX_set_flags(&ctx->o_ctx, flags);
237 EVP_MD_CTX_set_flags(&ctx->md_ctx, flags);
238}