diff options
Diffstat (limited to 'src/lib/libcrypto/pkcs12/p12_mutl.c')
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_mutl.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_mutl.c b/src/lib/libcrypto/pkcs12/p12_mutl.c index 13d866da51..0fb67f74b8 100644 --- a/src/lib/libcrypto/pkcs12/p12_mutl.c +++ b/src/lib/libcrypto/pkcs12/p12_mutl.c | |||
@@ -56,7 +56,7 @@ | |||
56 | * | 56 | * |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef NO_HMAC | 59 | #ifndef OPENSSL_NO_HMAC |
60 | #include <stdio.h> | 60 | #include <stdio.h> |
61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
62 | #include <openssl/hmac.h> | 62 | #include <openssl/hmac.h> |
@@ -71,6 +71,7 @@ int PKCS12_gen_mac (PKCS12 *p12, const char *pass, int passlen, | |||
71 | HMAC_CTX hmac; | 71 | HMAC_CTX hmac; |
72 | unsigned char key[PKCS12_MAC_KEY_LENGTH], *salt; | 72 | unsigned char key[PKCS12_MAC_KEY_LENGTH], *salt; |
73 | int saltlen, iter; | 73 | int saltlen, iter; |
74 | |||
74 | salt = p12->mac->salt->data; | 75 | salt = p12->mac->salt->data; |
75 | saltlen = p12->mac->salt->length; | 76 | saltlen = p12->mac->salt->length; |
76 | if (!p12->mac->iter) iter = 1; | 77 | if (!p12->mac->iter) iter = 1; |
@@ -85,10 +86,12 @@ int PKCS12_gen_mac (PKCS12 *p12, const char *pass, int passlen, | |||
85 | PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_KEY_GEN_ERROR); | 86 | PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_KEY_GEN_ERROR); |
86 | return 0; | 87 | return 0; |
87 | } | 88 | } |
88 | HMAC_Init (&hmac, key, PKCS12_MAC_KEY_LENGTH, md_type); | 89 | HMAC_CTX_init(&hmac); |
89 | HMAC_Update (&hmac, p12->authsafes->d.data->data, | 90 | HMAC_Init_ex(&hmac, key, PKCS12_MAC_KEY_LENGTH, md_type, NULL); |
91 | HMAC_Update(&hmac, p12->authsafes->d.data->data, | ||
90 | p12->authsafes->d.data->length); | 92 | p12->authsafes->d.data->length); |
91 | HMAC_Final (&hmac, mac, maclen); | 93 | HMAC_Final(&hmac, mac, maclen); |
94 | HMAC_CTX_cleanup(&hmac); | ||
92 | return 1; | 95 | return 1; |
93 | } | 96 | } |
94 | 97 | ||
@@ -113,7 +116,7 @@ int PKCS12_verify_mac (PKCS12 *p12, const char *pass, int passlen) | |||
113 | /* Set a mac */ | 116 | /* Set a mac */ |
114 | 117 | ||
115 | int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen, | 118 | int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen, |
116 | unsigned char *salt, int saltlen, int iter, EVP_MD *md_type) | 119 | unsigned char *salt, int saltlen, int iter, const EVP_MD *md_type) |
117 | { | 120 | { |
118 | unsigned char mac[EVP_MAX_MD_SIZE]; | 121 | unsigned char mac[EVP_MAX_MD_SIZE]; |
119 | unsigned int maclen; | 122 | unsigned int maclen; |
@@ -137,7 +140,7 @@ int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen, | |||
137 | 140 | ||
138 | /* Set up a mac structure */ | 141 | /* Set up a mac structure */ |
139 | int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen, | 142 | int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen, |
140 | EVP_MD *md_type) | 143 | const EVP_MD *md_type) |
141 | { | 144 | { |
142 | if (!(p12->mac = PKCS12_MAC_DATA_new())) return PKCS12_ERROR; | 145 | if (!(p12->mac = PKCS12_MAC_DATA_new())) return PKCS12_ERROR; |
143 | if (iter > 1) { | 146 | if (iter > 1) { |