diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/pkcs12/p12_crpt.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_crpt.c b/src/lib/libcrypto/pkcs12/p12_crpt.c index c0b41f9252..1709b30d5e 100644 --- a/src/lib/libcrypto/pkcs12/p12_crpt.c +++ b/src/lib/libcrypto/pkcs12/p12_crpt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: p12_crpt.c,v 1.9 2014/06/12 15:49:30 deraadt Exp $ */ | 1 | /* $OpenBSD: p12_crpt.c,v 1.10 2014/07/08 09:24:53 jsing Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -62,12 +62,14 @@ | |||
62 | 62 | ||
63 | /* PKCS#12 PBE algorithms now in static table */ | 63 | /* PKCS#12 PBE algorithms now in static table */ |
64 | 64 | ||
65 | void PKCS12_PBE_add(void) | 65 | void |
66 | PKCS12_PBE_add(void) | ||
66 | { | 67 | { |
67 | } | 68 | } |
68 | 69 | ||
69 | int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | 70 | int |
70 | ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de) | 71 | PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, |
72 | ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de) | ||
71 | { | 73 | { |
72 | PBEPARAM *pbe; | 74 | PBEPARAM *pbe; |
73 | int saltlen, iter, ret; | 75 | int saltlen, iter, ret; |
@@ -78,29 +80,31 @@ int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | |||
78 | /* Extract useful info from parameter */ | 80 | /* Extract useful info from parameter */ |
79 | if (param == NULL || param->type != V_ASN1_SEQUENCE || | 81 | if (param == NULL || param->type != V_ASN1_SEQUENCE || |
80 | param->value.sequence == NULL) { | 82 | param->value.sequence == NULL) { |
81 | PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN,PKCS12_R_DECODE_ERROR); | 83 | PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR); |
82 | return 0; | 84 | return 0; |
83 | } | 85 | } |
84 | 86 | ||
85 | pbuf = param->value.sequence->data; | 87 | pbuf = param->value.sequence->data; |
86 | if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) { | 88 | if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) { |
87 | PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN,PKCS12_R_DECODE_ERROR); | 89 | PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR); |
88 | return 0; | 90 | return 0; |
89 | } | 91 | } |
90 | 92 | ||
91 | if (!pbe->iter) iter = 1; | 93 | if (!pbe->iter) |
92 | else iter = ASN1_INTEGER_get (pbe->iter); | 94 | iter = 1; |
95 | else | ||
96 | iter = ASN1_INTEGER_get (pbe->iter); | ||
93 | salt = pbe->salt->data; | 97 | salt = pbe->salt->data; |
94 | saltlen = pbe->salt->length; | 98 | saltlen = pbe->salt->length; |
95 | if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_KEY_ID, | 99 | if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_KEY_ID, |
96 | iter, EVP_CIPHER_key_length(cipher), key, md)) { | 100 | iter, EVP_CIPHER_key_length(cipher), key, md)) { |
97 | PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN,PKCS12_R_KEY_GEN_ERROR); | 101 | PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_KEY_GEN_ERROR); |
98 | PBEPARAM_free(pbe); | 102 | PBEPARAM_free(pbe); |
99 | return 0; | 103 | return 0; |
100 | } | 104 | } |
101 | if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_IV_ID, | 105 | if (!PKCS12_key_gen (pass, passlen, salt, saltlen, PKCS12_IV_ID, |
102 | iter, EVP_CIPHER_iv_length(cipher), iv, md)) { | 106 | iter, EVP_CIPHER_iv_length(cipher), iv, md)) { |
103 | PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN,PKCS12_R_IV_GEN_ERROR); | 107 | PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_IV_GEN_ERROR); |
104 | PBEPARAM_free(pbe); | 108 | PBEPARAM_free(pbe); |
105 | return 0; | 109 | return 0; |
106 | } | 110 | } |