diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/asn1/p5_pbe.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c index 390305ad38..28caebd5c2 100644 --- a/src/lib/libcrypto/asn1/p5_pbe.c +++ b/src/lib/libcrypto/asn1/p5_pbe.c | |||
@@ -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 |
@@ -74,28 +74,29 @@ IMPLEMENT_ASN1_FUNCTIONS(PBEPARAM) | |||
74 | 74 | ||
75 | /* Set an algorithm identifier for a PKCS#5 PBE algorithm */ | 75 | /* Set an algorithm identifier for a PKCS#5 PBE algorithm */ |
76 | 76 | ||
77 | int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, | 77 | int |
78 | const unsigned char *salt, int saltlen) | 78 | PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, |
79 | const unsigned char *salt, int saltlen) | ||
79 | { | 80 | { |
80 | PBEPARAM *pbe=NULL; | 81 | PBEPARAM *pbe = NULL; |
81 | ASN1_STRING *pbe_str=NULL; | 82 | ASN1_STRING *pbe_str = NULL; |
82 | unsigned char *sstr; | 83 | unsigned char *sstr; |
83 | 84 | ||
84 | pbe = PBEPARAM_new(); | 85 | pbe = PBEPARAM_new(); |
85 | if (!pbe) { | 86 | if (!pbe) { |
86 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); | 87 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); |
87 | goto err; | 88 | goto err; |
88 | } | 89 | } |
89 | if(iter <= 0) | 90 | if (iter <= 0) |
90 | iter = PKCS5_DEFAULT_ITER; | 91 | iter = PKCS5_DEFAULT_ITER; |
91 | if (!ASN1_INTEGER_set(pbe->iter, iter)) { | 92 | if (!ASN1_INTEGER_set(pbe->iter, iter)) { |
92 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); | 93 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); |
93 | goto err; | 94 | goto err; |
94 | } | 95 | } |
95 | if (!saltlen) | 96 | if (!saltlen) |
96 | saltlen = PKCS5_SALT_LEN; | 97 | saltlen = PKCS5_SALT_LEN; |
97 | if (!ASN1_STRING_set(pbe->salt, NULL, saltlen)) { | 98 | if (!ASN1_STRING_set(pbe->salt, NULL, saltlen)) { |
98 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); | 99 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); |
99 | goto err; | 100 | goto err; |
100 | } | 101 | } |
101 | sstr = ASN1_STRING_data(pbe->salt); | 102 | sstr = ASN1_STRING_data(pbe->salt); |
@@ -104,8 +105,8 @@ int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, | |||
104 | else if (RAND_pseudo_bytes(sstr, saltlen) < 0) | 105 | else if (RAND_pseudo_bytes(sstr, saltlen) < 0) |
105 | goto err; | 106 | goto err; |
106 | 107 | ||
107 | if(!ASN1_item_pack(pbe, ASN1_ITEM_rptr(PBEPARAM), &pbe_str)) { | 108 | if (!ASN1_item_pack(pbe, ASN1_ITEM_rptr(PBEPARAM), &pbe_str)) { |
108 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); | 109 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR, ERR_R_MALLOC_FAILURE); |
109 | goto err; | 110 | goto err; |
110 | } | 111 | } |
111 | 112 | ||
@@ -125,17 +126,17 @@ err: | |||
125 | 126 | ||
126 | /* Return an algorithm identifier for a PKCS#5 PBE algorithm */ | 127 | /* Return an algorithm identifier for a PKCS#5 PBE algorithm */ |
127 | 128 | ||
128 | X509_ALGOR *PKCS5_pbe_set(int alg, int iter, | 129 | X509_ALGOR * |
129 | const unsigned char *salt, int saltlen) | 130 | PKCS5_pbe_set(int alg, int iter, const unsigned char *salt, int saltlen) |
130 | { | 131 | { |
131 | X509_ALGOR *ret; | 132 | X509_ALGOR *ret; |
132 | ret = X509_ALGOR_new(); | 133 | ret = X509_ALGOR_new(); |
133 | if (!ret) { | 134 | if (!ret) { |
134 | ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE); | 135 | ASN1err(ASN1_F_PKCS5_PBE_SET, ERR_R_MALLOC_FAILURE); |
135 | return NULL; | 136 | return NULL; |
136 | } | 137 | } |
137 | 138 | ||
138 | if (PKCS5_pbe_set0_algor(ret, alg, iter, salt, saltlen)) | 139 | if (PKCS5_pbe_set0_algor(ret, alg, iter, salt, saltlen)) |
139 | return ret; | 140 | return ret; |
140 | 141 | ||
141 | X509_ALGOR_free(ret); | 142 | X509_ALGOR_free(ret); |