summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/Symbols.list4
-rw-r--r--src/lib/libcrypto/hmac/hmac.c56
-rw-r--r--src/lib/libcrypto/hmac/hmac.h7
3 files changed, 56 insertions, 11 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index bee42ac164..1da0493c73 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -1604,7 +1604,11 @@ HKDF_extract
1604HMAC 1604HMAC
1605HMAC_CTX_cleanup 1605HMAC_CTX_cleanup
1606HMAC_CTX_copy 1606HMAC_CTX_copy
1607HMAC_CTX_free
1608HMAC_CTX_get_md
1607HMAC_CTX_init 1609HMAC_CTX_init
1610HMAC_CTX_new
1611HMAC_CTX_reset
1608HMAC_CTX_set_flags 1612HMAC_CTX_set_flags
1609HMAC_Final 1613HMAC_Final
1610HMAC_Init 1614HMAC_Init
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}
diff --git a/src/lib/libcrypto/hmac/hmac.h b/src/lib/libcrypto/hmac/hmac.h
index f3418b3cb7..e787c62ac8 100644
--- a/src/lib/libcrypto/hmac/hmac.h
+++ b/src/lib/libcrypto/hmac/hmac.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: hmac.h,v 1.12 2014/06/21 13:39:46 jsing Exp $ */ 1/* $OpenBSD: hmac.h,v 1.13 2018/02/17 14:53:59 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 *
@@ -83,8 +83,10 @@ typedef struct hmac_ctx_st {
83 83
84#define HMAC_size(e) (EVP_MD_size((e)->md)) 84#define HMAC_size(e) (EVP_MD_size((e)->md))
85 85
86 86HMAC_CTX *HMAC_CTX_new(void);
87void HMAC_CTX_free(HMAC_CTX *ctx);
87void HMAC_CTX_init(HMAC_CTX *ctx); 88void HMAC_CTX_init(HMAC_CTX *ctx);
89int HMAC_CTX_reset(HMAC_CTX *ctx);
88void HMAC_CTX_cleanup(HMAC_CTX *ctx); 90void HMAC_CTX_cleanup(HMAC_CTX *ctx);
89 91
90#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */ 92#define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx) /* deprecated */
@@ -100,6 +102,7 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
100int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); 102int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);
101 103
102void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); 104void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);
105const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx);
103 106
104#ifdef __cplusplus 107#ifdef __cplusplus
105} 108}