diff options
| author | jsing <> | 2018-02-17 14:53:59 +0000 |
|---|---|---|
| committer | jsing <> | 2018-02-17 14:53:59 +0000 |
| commit | fe31e083891620d38e67f59ea40fa3b92f6fcc48 (patch) | |
| tree | d253f3b4cf504cc55d56a675effcdec3d0020b97 /src/lib/libc | |
| parent | 85302f6eb21057056417176ee1eee15c94edc1eb (diff) | |
| download | openbsd-fe31e083891620d38e67f59ea40fa3b92f6fcc48.tar.gz openbsd-fe31e083891620d38e67f59ea40fa3b92f6fcc48.tar.bz2 openbsd-fe31e083891620d38e67f59ea40fa3b92f6fcc48.zip | |
Provide HMAC_CTX_new(), HMAC_CTX_free(), HMAC_CTX_reset() and
HMAC_CTX_get_md().
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/Symbols.list | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/hmac/hmac.c | 56 | ||||
| -rw-r--r-- | src/lib/libcrypto/hmac/hmac.h | 7 |
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 | |||
| 1604 | HMAC | 1604 | HMAC |
| 1605 | HMAC_CTX_cleanup | 1605 | HMAC_CTX_cleanup |
| 1606 | HMAC_CTX_copy | 1606 | HMAC_CTX_copy |
| 1607 | HMAC_CTX_free | ||
| 1608 | HMAC_CTX_get_md | ||
| 1607 | HMAC_CTX_init | 1609 | HMAC_CTX_init |
| 1610 | HMAC_CTX_new | ||
| 1611 | HMAC_CTX_reset | ||
| 1608 | HMAC_CTX_set_flags | 1612 | HMAC_CTX_set_flags |
| 1609 | HMAC_Final | 1613 | HMAC_Final |
| 1610 | HMAC_Init | 1614 | HMAC_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 | ||
| 174 | HMAC_CTX * | ||
| 175 | HMAC_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 | |||
| 187 | void | ||
| 188 | HMAC_CTX_free(HMAC_CTX *ctx) | ||
| 189 | { | ||
| 190 | if (ctx == NULL) | ||
| 191 | return; | ||
| 192 | |||
| 193 | HMAC_CTX_cleanup(ctx); | ||
| 194 | |||
| 195 | free(ctx); | ||
| 196 | } | ||
| 197 | |||
| 198 | int | ||
| 199 | HMAC_CTX_reset(HMAC_CTX *ctx) | ||
| 200 | { | ||
| 201 | HMAC_CTX_cleanup(ctx); | ||
| 202 | HMAC_CTX_init(ctx); | ||
| 203 | return 1; | ||
| 204 | } | ||
| 205 | |||
| 174 | void | 206 | void |
| 175 | HMAC_CTX_init(HMAC_CTX *ctx) | 207 | HMAC_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 | ||
| 241 | void | ||
| 242 | HMAC_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 | |||
| 249 | const EVP_MD * | ||
| 250 | HMAC_CTX_get_md(const HMAC_CTX *ctx) | ||
| 251 | { | ||
| 252 | return ctx->md; | ||
| 253 | } | ||
| 254 | |||
| 209 | unsigned char * | 255 | unsigned char * |
| 210 | HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, | 256 | HMAC(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 | |||
| 232 | void | ||
| 233 | HMAC_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 | 86 | HMAC_CTX *HMAC_CTX_new(void); | |
| 87 | void HMAC_CTX_free(HMAC_CTX *ctx); | ||
| 87 | void HMAC_CTX_init(HMAC_CTX *ctx); | 88 | void HMAC_CTX_init(HMAC_CTX *ctx); |
| 89 | int HMAC_CTX_reset(HMAC_CTX *ctx); | ||
| 88 | void HMAC_CTX_cleanup(HMAC_CTX *ctx); | 90 | void 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, | |||
| 100 | int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); | 102 | int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); |
| 101 | 103 | ||
| 102 | void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); | 104 | void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); |
| 105 | const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); | ||
| 103 | 106 | ||
| 104 | #ifdef __cplusplus | 107 | #ifdef __cplusplus |
| 105 | } | 108 | } |
