summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pkcs12/p12_key.c
diff options
context:
space:
mode:
authorbeck <>2002-05-15 02:29:21 +0000
committerbeck <>2002-05-15 02:29:21 +0000
commitb64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch)
treefa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/pkcs12/p12_key.c
parente471e1ea98d673597b182ea85f29e30c97cd08b5 (diff)
downloadopenbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/pkcs12/p12_key.c')
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index a4fd5b98ec..0d39ebde8c 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -118,6 +118,7 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
118 } 118 }
119#endif 119#endif
120 120
121 EVP_MD_CTX_init(&ctx);
121#ifdef DEBUG_KEYGEN 122#ifdef DEBUG_KEYGEN
122 fprintf(stderr, "KEYGEN DEBUG\n"); 123 fprintf(stderr, "KEYGEN DEBUG\n");
123 fprintf(stderr, "ID %d, ITER %d\n", id, iter); 124 fprintf(stderr, "ID %d, ITER %d\n", id, iter);
@@ -147,14 +148,14 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
147 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen]; 148 for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen];
148 for (i = 0; i < Plen; i++) *p++ = pass[i % passlen]; 149 for (i = 0; i < Plen; i++) *p++ = pass[i % passlen];
149 for (;;) { 150 for (;;) {
150 EVP_DigestInit (&ctx, md_type); 151 EVP_DigestInit_ex(&ctx, md_type, NULL);
151 EVP_DigestUpdate (&ctx, D, v); 152 EVP_DigestUpdate(&ctx, D, v);
152 EVP_DigestUpdate (&ctx, I, Ilen); 153 EVP_DigestUpdate(&ctx, I, Ilen);
153 EVP_DigestFinal (&ctx, Ai, NULL); 154 EVP_DigestFinal_ex(&ctx, Ai, NULL);
154 for (j = 1; j < iter; j++) { 155 for (j = 1; j < iter; j++) {
155 EVP_DigestInit (&ctx, md_type); 156 EVP_DigestInit_ex(&ctx, md_type, NULL);
156 EVP_DigestUpdate (&ctx, Ai, u); 157 EVP_DigestUpdate(&ctx, Ai, u);
157 EVP_DigestFinal (&ctx, Ai, NULL); 158 EVP_DigestFinal_ex(&ctx, Ai, NULL);
158 } 159 }
159 memcpy (out, Ai, min (n, u)); 160 memcpy (out, Ai, min (n, u));
160 if (u >= n) { 161 if (u >= n) {
@@ -164,6 +165,7 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
164 OPENSSL_free (I); 165 OPENSSL_free (I);
165 BN_free (Ij); 166 BN_free (Ij);
166 BN_free (Bpl1); 167 BN_free (Bpl1);
168 EVP_MD_CTX_cleanup(&ctx);
167#ifdef DEBUG_KEYGEN 169#ifdef DEBUG_KEYGEN
168 fprintf(stderr, "Output KEY (length %d)\n", tmpn); 170 fprintf(stderr, "Output KEY (length %d)\n", tmpn);
169 h__dump(tmpout, tmpn); 171 h__dump(tmpout, tmpn);