diff options
Diffstat (limited to 'src/lib/libcrypto/hmac/hmac.c')
-rw-r--r-- | src/lib/libcrypto/hmac/hmac.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c index c45e001492..6c110bd52b 100644 --- a/src/lib/libcrypto/hmac/hmac.c +++ b/src/lib/libcrypto/hmac/hmac.c | |||
@@ -58,8 +58,10 @@ | |||
58 | #include <stdio.h> | 58 | #include <stdio.h> |
59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
60 | #include <string.h> | 60 | #include <string.h> |
61 | #include "cryptlib.h" | ||
62 | #include <openssl/hmac.h> | 61 | #include <openssl/hmac.h> |
62 | #include "cryptlib.h" | ||
63 | |||
64 | #ifndef OPENSSL_FIPS | ||
63 | 65 | ||
64 | void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, | 66 | void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, |
65 | const EVP_MD *md, ENGINE *impl) | 67 | const EVP_MD *md, ENGINE *impl) |
@@ -79,7 +81,7 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, | |||
79 | { | 81 | { |
80 | reset=1; | 82 | reset=1; |
81 | j=EVP_MD_block_size(md); | 83 | j=EVP_MD_block_size(md); |
82 | OPENSSL_assert(j <= (int)sizeof(ctx->key)); | 84 | OPENSSL_assert(j <= sizeof ctx->key); |
83 | if (j < len) | 85 | if (j < len) |
84 | { | 86 | { |
85 | EVP_DigestInit_ex(&ctx->md_ctx,md, impl); | 87 | EVP_DigestInit_ex(&ctx->md_ctx,md, impl); |
@@ -89,7 +91,7 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, | |||
89 | } | 91 | } |
90 | else | 92 | else |
91 | { | 93 | { |
92 | OPENSSL_assert(len>=0 && len<=(int)sizeof(ctx->key)); | 94 | OPENSSL_assert(len <= sizeof ctx->key); |
93 | memcpy(ctx->key,key,len); | 95 | memcpy(ctx->key,key,len); |
94 | ctx->key_length=len; | 96 | ctx->key_length=len; |
95 | } | 97 | } |
@@ -121,7 +123,7 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len, | |||
121 | HMAC_Init_ex(ctx,key,len,md, NULL); | 123 | HMAC_Init_ex(ctx,key,len,md, NULL); |
122 | } | 124 | } |
123 | 125 | ||
124 | void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len) | 126 | void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len) |
125 | { | 127 | { |
126 | EVP_DigestUpdate(&ctx->md_ctx,data,len); | 128 | EVP_DigestUpdate(&ctx->md_ctx,data,len); |
127 | } | 129 | } |
@@ -156,7 +158,7 @@ void HMAC_CTX_cleanup(HMAC_CTX *ctx) | |||
156 | } | 158 | } |
157 | 159 | ||
158 | unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, | 160 | unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, |
159 | const unsigned char *d, size_t n, unsigned char *md, | 161 | const unsigned char *d, int n, unsigned char *md, |
160 | unsigned int *md_len) | 162 | unsigned int *md_len) |
161 | { | 163 | { |
162 | HMAC_CTX c; | 164 | HMAC_CTX c; |
@@ -171,3 +173,11 @@ unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, | |||
171 | return(md); | 173 | return(md); |
172 | } | 174 | } |
173 | 175 | ||
176 | void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags) | ||
177 | { | ||
178 | EVP_MD_CTX_set_flags(&ctx->i_ctx, flags); | ||
179 | EVP_MD_CTX_set_flags(&ctx->o_ctx, flags); | ||
180 | EVP_MD_CTX_set_flags(&ctx->md_ctx, flags); | ||
181 | } | ||
182 | |||
183 | #endif | ||