diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/p5_pbe.c')
-rw-r--r-- | src/lib/libcrypto/asn1/p5_pbe.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/libcrypto/asn1/p5_pbe.c b/src/lib/libcrypto/asn1/p5_pbe.c index 94bc38b99f..f0f23c668d 100644 --- a/src/lib/libcrypto/asn1/p5_pbe.c +++ b/src/lib/libcrypto/asn1/p5_pbe.c | |||
@@ -76,31 +76,31 @@ IMPLEMENT_ASN1_FUNCTIONS(PBEPARAM) | |||
76 | 76 | ||
77 | int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, | 77 | int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, |
78 | const unsigned char *salt, int saltlen) | 78 | const unsigned char *salt, int saltlen) |
79 | { | 79 | { |
80 | PBEPARAM *pbe=NULL; | 80 | PBEPARAM *pbe=NULL; |
81 | ASN1_STRING *pbe_str=NULL; | 81 | ASN1_STRING *pbe_str=NULL; |
82 | unsigned char *sstr; | 82 | unsigned char *sstr; |
83 | 83 | ||
84 | pbe = PBEPARAM_new(); | 84 | pbe = PBEPARAM_new(); |
85 | if (!pbe) | 85 | if (!pbe) |
86 | { | 86 | { |
87 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); | 87 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); |
88 | goto err; | 88 | goto err; |
89 | } | 89 | } |
90 | if(iter <= 0) | 90 | if(iter <= 0) |
91 | iter = PKCS5_DEFAULT_ITER; | 91 | iter = PKCS5_DEFAULT_ITER; |
92 | if (!ASN1_INTEGER_set(pbe->iter, iter)) | 92 | if (!ASN1_INTEGER_set(pbe->iter, iter)) |
93 | { | 93 | { |
94 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); | 94 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); |
95 | goto err; | 95 | goto err; |
96 | } | 96 | } |
97 | if (!saltlen) | 97 | if (!saltlen) |
98 | saltlen = PKCS5_SALT_LEN; | 98 | saltlen = PKCS5_SALT_LEN; |
99 | if (!ASN1_STRING_set(pbe->salt, NULL, saltlen)) | 99 | if (!ASN1_STRING_set(pbe->salt, NULL, saltlen)) |
100 | { | 100 | { |
101 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); | 101 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); |
102 | goto err; | 102 | goto err; |
103 | } | 103 | } |
104 | sstr = ASN1_STRING_data(pbe->salt); | 104 | sstr = ASN1_STRING_data(pbe->salt); |
105 | if (salt) | 105 | if (salt) |
106 | memcpy(sstr, salt, saltlen); | 106 | memcpy(sstr, salt, saltlen); |
@@ -108,10 +108,10 @@ int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, | |||
108 | goto err; | 108 | goto err; |
109 | 109 | ||
110 | if(!ASN1_item_pack(pbe, ASN1_ITEM_rptr(PBEPARAM), &pbe_str)) | 110 | if(!ASN1_item_pack(pbe, ASN1_ITEM_rptr(PBEPARAM), &pbe_str)) |
111 | { | 111 | { |
112 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); | 112 | ASN1err(ASN1_F_PKCS5_PBE_SET0_ALGOR,ERR_R_MALLOC_FAILURE); |
113 | goto err; | 113 | goto err; |
114 | } | 114 | } |
115 | 115 | ||
116 | PBEPARAM_free(pbe); | 116 | PBEPARAM_free(pbe); |
117 | pbe = NULL; | 117 | pbe = NULL; |
@@ -125,24 +125,24 @@ err: | |||
125 | if (pbe_str != NULL) | 125 | if (pbe_str != NULL) |
126 | ASN1_STRING_free(pbe_str); | 126 | ASN1_STRING_free(pbe_str); |
127 | return 0; | 127 | return 0; |
128 | } | 128 | } |
129 | 129 | ||
130 | /* Return an algorithm identifier for a PKCS#5 PBE algorithm */ | 130 | /* Return an algorithm identifier for a PKCS#5 PBE algorithm */ |
131 | 131 | ||
132 | X509_ALGOR *PKCS5_pbe_set(int alg, int iter, | 132 | X509_ALGOR *PKCS5_pbe_set(int alg, int iter, |
133 | const unsigned char *salt, int saltlen) | 133 | const unsigned char *salt, int saltlen) |
134 | { | 134 | { |
135 | X509_ALGOR *ret; | 135 | X509_ALGOR *ret; |
136 | ret = X509_ALGOR_new(); | 136 | ret = X509_ALGOR_new(); |
137 | if (!ret) | 137 | if (!ret) |
138 | { | 138 | { |
139 | ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE); | 139 | ASN1err(ASN1_F_PKCS5_PBE_SET,ERR_R_MALLOC_FAILURE); |
140 | return NULL; | 140 | return NULL; |
141 | } | 141 | } |
142 | 142 | ||
143 | if (PKCS5_pbe_set0_algor(ret, alg, iter, salt, saltlen)) | 143 | if (PKCS5_pbe_set0_algor(ret, alg, iter, salt, saltlen)) |
144 | return ret; | 144 | return ret; |
145 | 145 | ||
146 | X509_ALGOR_free(ret); | 146 | X509_ALGOR_free(ret); |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |