summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-12-16 14:09:33 +0000
committertb <>2023-12-16 14:09:33 +0000
commit3bddf1f70e4d43164ac7ee15aee8b8cc15d41900 (patch)
tree169dad6a33880943a268bdd63e0a57068f5bf95f /src
parent8037621774b49536be41fb210500651c3c7b09ba (diff)
downloadopenbsd-3bddf1f70e4d43164ac7ee15aee8b8cc15d41900.tar.gz
openbsd-3bddf1f70e4d43164ac7ee15aee8b8cc15d41900.tar.bz2
openbsd-3bddf1f70e4d43164ac7ee15aee8b8cc15d41900.zip
Move EVP_PBE_find() next to the tables
There is no point in having EVP_PBE_CipherInit() between the table and the lookup functions (which it notably uses). No code change.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/evp/evp_pbe.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c
index 0fe82953e3..94658f8797 100644
--- a/src/lib/libcrypto/evp/evp_pbe.c
+++ b/src/lib/libcrypto/evp/evp_pbe.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_pbe.c,v 1.32 2023/12/16 14:04:59 tb Exp $ */ 1/* $OpenBSD: evp_pbe.c,v 1.33 2023/12/16 14:09:33 tb 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 */
@@ -221,6 +221,51 @@ static const struct pbe_config pbe_prf[] = {
221#define N_PBE_PRF (sizeof(pbe_prf) / sizeof(pbe_prf[0])) 221#define N_PBE_PRF (sizeof(pbe_prf) / sizeof(pbe_prf[0]))
222 222
223int 223int
224EVP_PBE_find(int type, int pbe_nid, int *out_cipher_nid, int *out_md_nid,
225 EVP_PBE_KEYGEN **out_keygen)
226{
227 const struct pbe_config *pbe = NULL;
228 size_t i;
229
230 if (out_cipher_nid != NULL)
231 *out_cipher_nid = NID_undef;
232 if (out_md_nid != NULL)
233 *out_md_nid = NID_undef;
234 if (out_keygen != NULL)
235 *out_keygen = NULL;
236
237 if (pbe_nid == NID_undef)
238 return 0;
239
240 if (type == EVP_PBE_TYPE_OUTER) {
241 for (i = 0; i < N_PBE_OUTER; i++) {
242 if (pbe_nid == pbe_outer[i].pbe_nid) {
243 pbe = &pbe_outer[i];
244 break;
245 }
246 }
247 } else if (type == EVP_PBE_TYPE_PRF) {
248 for (i = 0; i < N_PBE_PRF; i++) {
249 if (pbe_nid == pbe_prf[i].pbe_nid) {
250 pbe = &pbe_prf[i];
251 break;
252 }
253 }
254 }
255 if (pbe == NULL)
256 return 0;
257
258 if (out_cipher_nid != NULL)
259 *out_cipher_nid = pbe->cipher_nid;
260 if (out_md_nid != NULL)
261 *out_md_nid = pbe->md_nid;
262 if (out_keygen != NULL)
263 *out_keygen = pbe->keygen;
264
265 return 1;
266}
267
268int
224EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, 269EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
225 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de) 270 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de)
226{ 271{
@@ -274,51 +319,6 @@ EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
274} 319}
275 320
276int 321int
277EVP_PBE_find(int type, int pbe_nid, int *out_cipher_nid, int *out_md_nid,
278 EVP_PBE_KEYGEN **out_keygen)
279{
280 const struct pbe_config *pbe = NULL;
281 size_t i;
282
283 if (out_cipher_nid != NULL)
284 *out_cipher_nid = NID_undef;
285 if (out_md_nid != NULL)
286 *out_md_nid = NID_undef;
287 if (out_keygen != NULL)
288 *out_keygen = NULL;
289
290 if (pbe_nid == NID_undef)
291 return 0;
292
293 if (type == EVP_PBE_TYPE_OUTER) {
294 for (i = 0; i < N_PBE_OUTER; i++) {
295 if (pbe_nid == pbe_outer[i].pbe_nid) {
296 pbe = &pbe_outer[i];
297 break;
298 }
299 }
300 } else if (type == EVP_PBE_TYPE_PRF) {
301 for (i = 0; i < N_PBE_PRF; i++) {
302 if (pbe_nid == pbe_prf[i].pbe_nid) {
303 pbe = &pbe_prf[i];
304 break;
305 }
306 }
307 }
308 if (pbe == NULL)
309 return 0;
310
311 if (out_cipher_nid != NULL)
312 *out_cipher_nid = pbe->cipher_nid;
313 if (out_md_nid != NULL)
314 *out_md_nid = pbe->md_nid;
315 if (out_keygen != NULL)
316 *out_keygen = pbe->keygen;
317
318 return 1;
319}
320
321int
322EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid, 322EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
323 EVP_PBE_KEYGEN *keygen) 323 EVP_PBE_KEYGEN *keygen)
324{ 324{