sync with OpenBSD -current

This commit is contained in:
purplerain 2024-01-05 00:18:10 +00:00
parent eff43bb1fd
commit a2b5593ce1
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
76 changed files with 1704 additions and 1876 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ameth_lib.c,v 1.41 2023/12/29 19:00:31 tb Exp $ */
/* $OpenBSD: ameth_lib.c,v 1.42 2024/01/04 16:50:53 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -71,60 +71,20 @@
EVP_PKEY_ASN1_METHOD*
EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info)
{
EVP_PKEY_ASN1_METHOD *ameth;
if ((ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD))) == NULL)
return NULL;
ameth->pkey_id = id;
ameth->pkey_base_id = id;
ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
if (info != NULL) {
if ((ameth->info = strdup(info)) == NULL)
goto err;
}
if (pem_str != NULL) {
if ((ameth->pem_str = strdup(pem_str)) == NULL)
goto err;
}
return ameth;
err:
EVP_PKEY_asn1_free(ameth);
EVPerror(ERR_R_DISABLED);
return NULL;
}
void
EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src)
{
EVP_PKEY_ASN1_METHOD preserve;
preserve.pkey_id = dst->pkey_id;
preserve.pkey_base_id = dst->pkey_base_id;
preserve.pkey_flags = dst->pkey_flags;
preserve.pem_str = dst->pem_str;
preserve.info = dst->info;
*dst = *src;
dst->pkey_id = preserve.pkey_id;
dst->pkey_base_id = preserve.pkey_base_id;
dst->pkey_flags = preserve.pkey_flags;
dst->pem_str = preserve.pem_str;
dst->info = preserve.info;
EVPerror(ERR_R_DISABLED);
}
void
EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth)
{
if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC)) {
free(ameth->pem_str);
free(ameth->info);
free(ameth);
}
EVPerror(ERR_R_DISABLED);
}
void
@ -137,12 +97,7 @@ EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,
int (*pkey_size)(const EVP_PKEY *pk),
int (*pkey_bits)(const EVP_PKEY *pk))
{
ameth->pub_decode = pub_decode;
ameth->pub_encode = pub_encode;
ameth->pub_cmp = pub_cmp;
ameth->pub_print = pub_print;
ameth->pkey_size = pkey_size;
ameth->pkey_bits = pkey_bits;
EVPerror(ERR_R_DISABLED);
}
void
@ -152,9 +107,7 @@ EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,
int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent,
ASN1_PCTX *pctx))
{
ameth->priv_decode = priv_decode;
ameth->priv_encode = priv_encode;
ameth->priv_print = priv_print;
EVPerror(ERR_R_DISABLED);
}
void
@ -167,54 +120,49 @@ EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent,
ASN1_PCTX *pctx))
{
ameth->param_decode = param_decode;
ameth->param_encode = param_encode;
ameth->param_missing = param_missing;
ameth->param_copy = param_copy;
ameth->param_cmp = param_cmp;
ameth->param_print = param_print;
EVPerror(ERR_R_DISABLED);
}
void
EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
void (*pkey_free)(EVP_PKEY *pkey))
{
ameth->pkey_free = pkey_free;
EVPerror(ERR_R_DISABLED);
}
void
EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2))
{
ameth->pkey_ctrl = pkey_ctrl;
EVPerror(ERR_R_DISABLED);
}
void
EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
int (*pkey_security_bits)(const EVP_PKEY *pkey))
{
ameth->pkey_security_bits = pkey_security_bits;
EVPerror(ERR_R_DISABLED);
}
void
EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,
int (*pkey_check)(const EVP_PKEY *pk))
{
ameth->pkey_check = pkey_check;
EVPerror(ERR_R_DISABLED);
}
void
EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth,
int (*pkey_public_check)(const EVP_PKEY *pk))
{
ameth->pkey_public_check = pkey_public_check;
EVPerror(ERR_R_DISABLED);
}
void
EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth,
int (*pkey_param_check)(const EVP_PKEY *pk))
{
ameth->pkey_param_check = pkey_param_check;
EVPerror(ERR_R_DISABLED);
}
int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cm_ameth.c,v 1.10 2022/11/26 16:08:51 tb Exp $ */
/* $OpenBSD: cm_ameth.c,v 1.11 2024/01/04 17:01:26 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2010.
*/
@ -77,8 +77,8 @@ cmac_key_free(EVP_PKEY *pkey)
}
const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = {
.base_method = &cmac_asn1_meth,
.pkey_id = EVP_PKEY_CMAC,
.pkey_base_id = EVP_PKEY_CMAC,
.pem_str = "CMAC",
.info = "OpenSSL CMAC method",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dh_ameth.c,v 1.39 2023/08/12 07:59:48 tb Exp $ */
/* $OpenBSD: dh_ameth.c,v 1.40 2024/01/04 17:01:26 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -523,8 +523,8 @@ dh_pkey_param_check(const EVP_PKEY *pkey)
}
const EVP_PKEY_ASN1_METHOD dh_asn1_meth = {
.base_method = &dh_asn1_meth,
.pkey_id = EVP_PKEY_DH,
.pkey_base_id = EVP_PKEY_DH,
.pem_str = "DH",
.info = "OpenSSL PKCS#3 DH method",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dsa_ameth.c,v 1.55 2023/08/12 07:59:48 tb Exp $ */
/* $OpenBSD: dsa_ameth.c,v 1.57 2024/01/04 17:01:26 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -674,64 +674,60 @@ dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
}
}
/* NB these are sorted in pkey_id order, lowest first */
const EVP_PKEY_ASN1_METHOD dsa_asn1_meth = {
.base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA,
const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = {
{
.pkey_id = EVP_PKEY_DSA2,
.pkey_base_id = EVP_PKEY_DSA,
.pkey_flags = ASN1_PKEY_ALIAS
},
.pem_str = "DSA",
.info = "OpenSSL DSA method",
{
.pkey_id = EVP_PKEY_DSA1,
.pkey_base_id = EVP_PKEY_DSA,
.pkey_flags = ASN1_PKEY_ALIAS
},
.pub_decode = dsa_pub_decode,
.pub_encode = dsa_pub_encode,
.pub_cmp = dsa_pub_cmp,
.pub_print = dsa_pub_print,
{
.pkey_id = EVP_PKEY_DSA4,
.pkey_base_id = EVP_PKEY_DSA,
.pkey_flags = ASN1_PKEY_ALIAS
},
.priv_decode = dsa_priv_decode,
.priv_encode = dsa_priv_encode,
.priv_print = dsa_priv_print,
{
.pkey_id = EVP_PKEY_DSA3,
.pkey_base_id = EVP_PKEY_DSA,
.pkey_flags = ASN1_PKEY_ALIAS
},
.pkey_size = dsa_size,
.pkey_bits = dsa_bits,
.pkey_security_bits = dsa_security_bits,
{
.pkey_id = EVP_PKEY_DSA,
.pkey_base_id = EVP_PKEY_DSA,
.param_decode = dsa_param_decode,
.param_encode = dsa_param_encode,
.param_missing = dsa_missing_parameters,
.param_copy = dsa_copy_parameters,
.param_cmp = dsa_cmp_parameters,
.param_print = dsa_param_print,
.sig_print = dsa_sig_print,
.pem_str = "DSA",
.info = "OpenSSL DSA method",
.pub_decode = dsa_pub_decode,
.pub_encode = dsa_pub_encode,
.pub_cmp = dsa_pub_cmp,
.pub_print = dsa_pub_print,
.priv_decode = dsa_priv_decode,
.priv_encode = dsa_priv_encode,
.priv_print = dsa_priv_print,
.pkey_size = dsa_size,
.pkey_bits = dsa_bits,
.pkey_security_bits = dsa_security_bits,
.param_decode = dsa_param_decode,
.param_encode = dsa_param_encode,
.param_missing = dsa_missing_parameters,
.param_copy = dsa_copy_parameters,
.param_cmp = dsa_cmp_parameters,
.param_print = dsa_param_print,
.sig_print = dsa_sig_print,
.pkey_free = dsa_free,
.pkey_ctrl = dsa_pkey_ctrl,
.old_priv_decode = old_dsa_priv_decode,
.old_priv_encode = old_dsa_priv_encode
}
.pkey_free = dsa_free,
.pkey_ctrl = dsa_pkey_ctrl,
.old_priv_decode = old_dsa_priv_decode,
.old_priv_encode = old_dsa_priv_encode
};
const EVP_PKEY_ASN1_METHOD dsa1_asn1_meth = {
.base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA1,
.pkey_flags = ASN1_PKEY_ALIAS,
};
const EVP_PKEY_ASN1_METHOD dsa2_asn1_meth = {
.base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA2,
.pkey_flags = ASN1_PKEY_ALIAS,
};
const EVP_PKEY_ASN1_METHOD dsa3_asn1_meth = {
.base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA3,
.pkey_flags = ASN1_PKEY_ALIAS,
};
const EVP_PKEY_ASN1_METHOD dsa4_asn1_meth = {
.base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA4,
.pkey_flags = ASN1_PKEY_ALIAS,
};

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ec_ameth.c,v 1.50 2023/12/29 18:49:06 tb Exp $ */
/* $OpenBSD: ec_ameth.c,v 1.51 2024/01/04 17:01:26 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -1049,8 +1049,8 @@ ecdh_cms_encrypt(CMS_RecipientInfo *ri)
#endif
const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = {
.base_method = &eckey_asn1_meth,
.pkey_id = EVP_PKEY_EC,
.pkey_base_id = EVP_PKEY_EC,
.pem_str = "EC",
.info = "OpenSSL EC algorithm",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ecx_methods.c,v 1.10 2023/11/09 11:39:13 tb Exp $ */
/* $OpenBSD: ecx_methods.c,v 1.11 2024/01/04 17:01:26 tb Exp $ */
/*
* Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
*
@ -813,8 +813,8 @@ pkey_ecx_ed_ctrl(EVP_PKEY_CTX *pkey_ctx, int op, int arg1, void *arg2)
}
const EVP_PKEY_ASN1_METHOD x25519_asn1_meth = {
.base_method = &x25519_asn1_meth,
.pkey_id = EVP_PKEY_X25519,
.pkey_base_id = EVP_PKEY_X25519,
.pkey_flags = 0,
.pem_str = "X25519",
.info = "OpenSSL X25519 algorithm",
@ -851,8 +851,8 @@ const EVP_PKEY_METHOD x25519_pkey_meth = {
};
const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth = {
.base_method = &ed25519_asn1_meth,
.pkey_id = EVP_PKEY_ED25519,
.pkey_base_id = EVP_PKEY_ED25519,
.pkey_flags = 0,
.pem_str = "ED25519",
.info = "OpenSSL ED25519 algorithm",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_aes.c,v 1.55 2023/11/18 09:37:15 tb Exp $ */
/* $OpenBSD: e_aes.c,v 1.56 2024/01/04 17:38:36 tb Exp $ */
/* ====================================================================
* Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
*
@ -2550,7 +2550,6 @@ static const EVP_CIPHER aes_128_wrap = {
.set_asn1_parameters = NULL,
.get_asn1_parameters = NULL,
.ctrl = aes_wrap_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -2572,7 +2571,6 @@ static const EVP_CIPHER aes_192_wrap = {
.set_asn1_parameters = NULL,
.get_asn1_parameters = NULL,
.ctrl = aes_wrap_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -2594,7 +2592,6 @@ static const EVP_CIPHER aes_256_wrap = {
.set_asn1_parameters = NULL,
.get_asn1_parameters = NULL,
.ctrl = aes_wrap_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_bf.c,v 1.17 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_bf.c,v 1.18 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -170,7 +170,6 @@ static const EVP_CIPHER bf_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -192,7 +191,6 @@ static const EVP_CIPHER bf_cfb64 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -214,7 +212,6 @@ static const EVP_CIPHER bf_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -236,7 +233,6 @@ static const EVP_CIPHER bf_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_camellia.c,v 1.18 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_camellia.c,v 1.19 2024/01/04 17:38:36 tb Exp $ */
/* ====================================================================
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
*
@ -171,7 +171,6 @@ static const EVP_CIPHER camellia_128_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -193,7 +192,6 @@ static const EVP_CIPHER camellia_128_cfb128 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -215,7 +213,6 @@ static const EVP_CIPHER camellia_128_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -237,7 +234,6 @@ static const EVP_CIPHER camellia_128_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -329,7 +325,6 @@ static const EVP_CIPHER camellia_192_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -351,7 +346,6 @@ static const EVP_CIPHER camellia_192_cfb128 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -373,7 +367,6 @@ static const EVP_CIPHER camellia_192_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -395,7 +388,6 @@ static const EVP_CIPHER camellia_192_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -487,7 +479,6 @@ static const EVP_CIPHER camellia_256_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -509,7 +500,6 @@ static const EVP_CIPHER camellia_256_cfb128 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -531,7 +521,6 @@ static const EVP_CIPHER camellia_256_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -553,7 +542,6 @@ static const EVP_CIPHER camellia_256_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -597,7 +585,6 @@ static const EVP_CIPHER camellia_128_cfb1 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -641,7 +628,6 @@ static const EVP_CIPHER camellia_192_cfb1 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -685,7 +671,6 @@ static const EVP_CIPHER camellia_256_cfb1 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -728,7 +713,6 @@ static const EVP_CIPHER camellia_128_cfb8 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -770,7 +754,6 @@ static const EVP_CIPHER camellia_192_cfb8 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -812,7 +795,6 @@ static const EVP_CIPHER camellia_256_cfb8 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_cast.c,v 1.16 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_cast.c,v 1.17 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -170,7 +170,6 @@ static const EVP_CIPHER cast5_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -192,7 +191,6 @@ static const EVP_CIPHER cast5_cfb64 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -214,7 +212,6 @@ static const EVP_CIPHER cast5_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -236,7 +233,6 @@ static const EVP_CIPHER cast5_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_des.c,v 1.22 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_des.c,v 1.23 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -234,7 +234,6 @@ static const EVP_CIPHER des_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -256,7 +255,6 @@ static const EVP_CIPHER des_cfb64 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -278,7 +276,6 @@ static const EVP_CIPHER des_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -300,7 +297,6 @@ static const EVP_CIPHER des_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -322,7 +318,6 @@ static const EVP_CIPHER des_cfb1 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -344,7 +339,6 @@ static const EVP_CIPHER des_cfb8 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_des3.c,v 1.28 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_des3.c,v 1.29 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -266,7 +266,6 @@ static const EVP_CIPHER des_ede_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -288,7 +287,6 @@ static const EVP_CIPHER des_ede_cfb64 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -310,7 +308,6 @@ static const EVP_CIPHER des_ede_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -332,7 +329,6 @@ static const EVP_CIPHER des_ede_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -360,7 +356,6 @@ static const EVP_CIPHER des_ede3_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -382,7 +377,6 @@ static const EVP_CIPHER des_ede3_cfb64 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -404,7 +398,6 @@ static const EVP_CIPHER des_ede3_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -426,7 +419,6 @@ static const EVP_CIPHER des_ede3_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -449,7 +441,6 @@ static const EVP_CIPHER des_ede3_cfb1 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -472,7 +463,6 @@ static const EVP_CIPHER des_ede3_cfb8 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = des3_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_gost2814789.c,v 1.13 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_gost2814789.c,v 1.14 2024/01/04 17:38:36 tb Exp $ */
/*
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Copyright (c) 2005-2006 Cryptocom LTD
@ -260,7 +260,6 @@ static const EVP_CIPHER gost2814789_ecb = {
.set_asn1_parameters = gost2814789_set_asn1_params,
.get_asn1_parameters = gost2814789_get_asn1_params,
.ctrl = gost2814789_ctl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -282,7 +281,6 @@ static const EVP_CIPHER gost2814789_cfb64 = {
.set_asn1_parameters = gost2814789_set_asn1_params,
.get_asn1_parameters = gost2814789_get_asn1_params,
.ctrl = gost2814789_ctl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -304,7 +302,6 @@ static const EVP_CIPHER gost2814789_cnt = {
.set_asn1_parameters = gost2814789_set_asn1_params,
.get_asn1_parameters = gost2814789_get_asn1_params,
.ctrl = gost2814789_ctl,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_idea.c,v 1.20 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_idea.c,v 1.21 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -189,7 +189,6 @@ static const EVP_CIPHER idea_cbc = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -211,7 +210,6 @@ static const EVP_CIPHER idea_cfb64 = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -233,7 +231,6 @@ static const EVP_CIPHER idea_ofb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -255,7 +252,6 @@ static const EVP_CIPHER idea_ecb = {
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_null.c,v 1.18 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_null.c,v 1.19 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -80,7 +80,6 @@ static const EVP_CIPHER n_cipher = {
NULL,
NULL,
NULL,
NULL
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_rc2.c,v 1.25 2023/12/02 19:06:22 tb Exp $ */
/* $OpenBSD: e_rc2.c,v 1.26 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -172,7 +172,6 @@ static const EVP_CIPHER rc2_cbc = {
.set_asn1_parameters = rc2_set_asn1_type_and_iv,
.get_asn1_parameters = rc2_get_asn1_type_and_iv,
.ctrl = rc2_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -194,7 +193,6 @@ static const EVP_CIPHER rc2_cfb64 = {
.set_asn1_parameters = rc2_set_asn1_type_and_iv,
.get_asn1_parameters = rc2_get_asn1_type_and_iv,
.ctrl = rc2_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -216,7 +214,6 @@ static const EVP_CIPHER rc2_ofb = {
.set_asn1_parameters = rc2_set_asn1_type_and_iv,
.get_asn1_parameters = rc2_get_asn1_type_and_iv,
.ctrl = rc2_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -238,7 +235,6 @@ static const EVP_CIPHER rc2_ecb = {
.set_asn1_parameters = rc2_set_asn1_type_and_iv,
.get_asn1_parameters = rc2_get_asn1_type_and_iv,
.ctrl = rc2_ctrl,
.app_data = NULL,
};
const EVP_CIPHER *
@ -262,7 +258,6 @@ static const EVP_CIPHER r2_64_cbc_cipher = {
rc2_set_asn1_type_and_iv,
rc2_get_asn1_type_and_iv,
rc2_ctrl,
NULL
};
static const EVP_CIPHER r2_40_cbc_cipher = {
@ -276,7 +271,6 @@ static const EVP_CIPHER r2_40_cbc_cipher = {
rc2_set_asn1_type_and_iv,
rc2_get_asn1_type_and_iv,
rc2_ctrl,
NULL
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_rc4.c,v 1.17 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_rc4.c,v 1.18 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -93,7 +93,6 @@ static const EVP_CIPHER r4_cipher = {
NULL,
NULL,
NULL,
NULL
};
static const EVP_CIPHER r4_40_cipher = {
@ -107,7 +106,6 @@ static const EVP_CIPHER r4_40_cipher = {
NULL,
NULL,
NULL,
NULL
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_rc4_hmac_md5.c,v 1.12 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_rc4_hmac_md5.c,v 1.13 2024/01/04 17:38:36 tb Exp $ */
/* ====================================================================
* Copyright (c) 2011 The OpenSSL Project. All rights reserved.
*
@ -296,7 +296,6 @@ static EVP_CIPHER r4_hmac_md5_cipher = {
NULL,
NULL,
rc4_hmac_md5_ctrl,
NULL
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_sm4.c,v 1.11 2024/01/02 19:54:43 tb Exp $ */
/* $OpenBSD: e_sm4.c,v 1.12 2024/01/04 17:38:36 tb Exp $ */
/*
* Copyright (c) 2017, 2019 Ribose Inc
*
@ -157,7 +157,6 @@ static const EVP_CIPHER sm4_cbc = {
.set_asn1_parameters = NULL,
.get_asn1_parameters = NULL,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -179,7 +178,6 @@ static const EVP_CIPHER sm4_cfb128 = {
.set_asn1_parameters = NULL,
.get_asn1_parameters = NULL,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -201,7 +199,6 @@ static const EVP_CIPHER sm4_ofb = {
.set_asn1_parameters = NULL,
.get_asn1_parameters = NULL,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -223,7 +220,6 @@ static const EVP_CIPHER sm4_ecb = {
.set_asn1_parameters = NULL,
.get_asn1_parameters = NULL,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *
@ -256,7 +252,6 @@ static const EVP_CIPHER sm4_ctr_mode = {
.set_asn1_parameters = NULL,
.get_asn1_parameters = NULL,
.ctrl = NULL,
.app_data = NULL,
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: e_xcbc_d.c,v 1.15 2023/07/07 19:37:53 beck Exp $ */
/* $OpenBSD: e_xcbc_d.c,v 1.16 2024/01/04 17:38:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -94,7 +94,6 @@ static const EVP_CIPHER d_xcbc_cipher = {
EVP_CIPHER_set_asn1_iv,
EVP_CIPHER_get_asn1_iv,
NULL,
NULL
};
const EVP_CIPHER *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: evp_cipher.c,v 1.13 2024/01/02 21:27:39 tb Exp $ */
/* $OpenBSD: evp_cipher.c,v 1.15 2024/01/04 09:47:54 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -204,7 +204,8 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine,
case EVP_CIPH_CBC_MODE:
iv_len = EVP_CIPHER_CTX_iv_length(ctx);
if (iv_len < 0 || iv_len > sizeof(ctx->oiv)) {
if (iv_len < 0 || iv_len > sizeof(ctx->oiv) ||
iv_len > sizeof(ctx->iv)) {
EVPerror(EVP_R_IV_TOO_LARGE);
return 0;
}
@ -899,15 +900,24 @@ EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
*/
int
EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
{
if (ctx->cipher->set_asn1_parameters != NULL)
return ctx->cipher->set_asn1_parameters(ctx, type);
int i = 0;
int l;
if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0)
return EVP_CIPHER_set_asn1_iv(ctx, type);
return -1;
if (type != NULL) {
l = EVP_CIPHER_CTX_iv_length(ctx);
if (l < 0 || l > sizeof(ctx->oiv) || l > sizeof(ctx->iv)) {
EVPerror(EVP_R_IV_TOO_LARGE);
return 0;
}
i = ASN1_TYPE_get_octetstring(type, ctx->oiv, l);
if (i != l)
return (-1);
else if (i > 0)
memcpy(ctx->iv, ctx->oiv, l);
}
return (i);
}
int
@ -922,27 +932,6 @@ EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
return -1;
}
int
EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
{
int i = 0;
int l;
if (type != NULL) {
l = EVP_CIPHER_CTX_iv_length(ctx);
if (l < 0 || l > sizeof(ctx->iv)) {
EVPerror(EVP_R_IV_TOO_LARGE);
return 0;
}
i = ASN1_TYPE_get_octetstring(type, ctx->oiv, l);
if (i != l)
return (-1);
else if (i > 0)
memcpy(ctx->iv, ctx->oiv, l);
}
return (i);
}
int
EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
{
@ -951,7 +940,7 @@ EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
if (type != NULL) {
j = EVP_CIPHER_CTX_iv_length(ctx);
if (j < 0 || j > sizeof(ctx->iv)) {
if (j < 0 || j > sizeof(ctx->oiv)) {
EVPerror(EVP_R_IV_TOO_LARGE);
return 0;
}
@ -960,6 +949,18 @@ EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
return (i);
}
int
EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
{
if (ctx->cipher->set_asn1_parameters != NULL)
return ctx->cipher->set_asn1_parameters(ctx, type);
if ((ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) != 0)
return EVP_CIPHER_set_asn1_iv(ctx, type);
return -1;
}
/* Convert the various cipher NIDs and dummies to a proper OID NID */
int
EVP_CIPHER_type(const EVP_CIPHER *cipher)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: evp_local.h,v 1.11 2024/01/01 15:23:00 tb Exp $ */
/* $OpenBSD: evp_local.h,v 1.13 2024/01/04 17:38:36 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@ -90,8 +90,8 @@ struct ecx_key_st {
};
struct evp_pkey_asn1_method_st {
const EVP_PKEY_ASN1_METHOD *base_method;
int pkey_id;
int pkey_base_id;
unsigned long pkey_flags;
char *pem_str;
@ -223,7 +223,6 @@ struct evp_cipher_st {
int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
void *app_data; /* Application data */
} /* EVP_CIPHER */;
struct evp_cipher_ctx_st {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: p_lib.c,v 1.52 2024/01/01 15:23:00 tb Exp $ */
/* $OpenBSD: p_lib.c,v 1.57 2024/01/04 17:22:29 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@ -133,33 +133,40 @@
extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[];
extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD dsa1_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD dsa2_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD dsa3_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD dsa4_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD gostimit_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD gostr01_asn1_meths[];
extern const EVP_PKEY_ASN1_METHOD gostr01_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD gostr12_256_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD gostr12_512_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[];
extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD rsa2_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth;
extern const EVP_PKEY_ASN1_METHOD x25519_asn1_meth;
static const EVP_PKEY_ASN1_METHOD *asn1_methods[] = {
&cmac_asn1_meth,
&dh_asn1_meth,
&dsa_asn1_meths[0],
&dsa_asn1_meths[1],
&dsa_asn1_meths[2],
&dsa_asn1_meths[3],
&dsa_asn1_meths[4],
&dsa_asn1_meth,
&dsa1_asn1_meth,
&dsa2_asn1_meth,
&dsa3_asn1_meth,
&dsa4_asn1_meth,
&eckey_asn1_meth,
&ed25519_asn1_meth,
&gostimit_asn1_meth,
&gostr01_asn1_meths[0],
&gostr01_asn1_meths[1],
&gostr01_asn1_meths[2],
&gostr01_asn1_meth,
&gostr12_256_asn1_meth,
&gostr12_512_asn1_meth,
&hmac_asn1_meth,
&rsa_asn1_meths[0],
&rsa_asn1_meths[1],
&rsa_asn1_meth,
&rsa2_asn1_meth,
&rsa_pss_asn1_meth,
&x25519_asn1_meth,
};
@ -181,84 +188,71 @@ EVP_PKEY_asn1_get0(int idx)
return asn1_methods[idx];
}
static const EVP_PKEY_ASN1_METHOD *
pkey_asn1_find(int pkey_id)
const EVP_PKEY_ASN1_METHOD *
EVP_PKEY_asn1_find(ENGINE **engine, int pkey_id)
{
const EVP_PKEY_ASN1_METHOD *ameth;
int i;
size_t i;
for (i = EVP_PKEY_asn1_get_count() - 1; i >= 0; i--) {
ameth = EVP_PKEY_asn1_get0(i);
if (ameth->pkey_id == pkey_id)
return ameth;
if (engine != NULL)
*engine = NULL;
for (i = 0; i < N_ASN1_METHODS; i++) {
if (asn1_methods[i]->pkey_id == pkey_id)
return asn1_methods[i]->base_method;
}
return NULL;
}
/*
* XXX - fix this. In what looks like an infinite loop, this API only makes two
* calls to pkey_asn1_find(): If the type resolves to an aliased ASN.1 method,
* the second call will find the method it aliases. Codify this in regress and
* make this explicit in code.
*/
const EVP_PKEY_ASN1_METHOD *
EVP_PKEY_asn1_find(ENGINE **pe, int type)
{
const EVP_PKEY_ASN1_METHOD *mp;
if (pe != NULL)
*pe = NULL;
for (;;) {
if ((mp = pkey_asn1_find(type)) == NULL)
break;
if ((mp->pkey_flags & ASN1_PKEY_ALIAS) == 0)
break;
type = mp->pkey_base_id;
}
return mp;
}
const EVP_PKEY_ASN1_METHOD *
EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str, int len)
EVP_PKEY_asn1_find_str(ENGINE **engine, const char *str, int len)
{
const EVP_PKEY_ASN1_METHOD *ameth;
size_t str_len;
int i;
if (engine != NULL)
*engine = NULL;
if (len < -1)
return NULL;
if (len == -1)
len = strlen(str);
if (pe != NULL)
*pe = NULL;
for (i = EVP_PKEY_asn1_get_count() - 1; i >= 0; i--) {
ameth = EVP_PKEY_asn1_get0(i);
str_len = strlen(str);
else
str_len = len;
for (i = 0; i < N_ASN1_METHODS; i++) {
ameth = asn1_methods[i];
if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
continue;
if (((int)strlen(ameth->pem_str) == len) &&
!strncasecmp(ameth->pem_str, str, len))
if (strlen(ameth->pem_str) != str_len)
continue;
if (strncasecmp(ameth->pem_str, str, str_len) == 0)
return ameth;
}
return NULL;
}
int
EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags,
const char **pinfo, const char **ppem_str,
EVP_PKEY_asn1_get0_info(int *pkey_id, int *pkey_base_id, int *pkey_flags,
const char **info, const char **pem_str,
const EVP_PKEY_ASN1_METHOD *ameth)
{
if (!ameth)
if (ameth == NULL)
return 0;
if (ppkey_id)
*ppkey_id = ameth->pkey_id;
if (ppkey_base_id)
*ppkey_base_id = ameth->pkey_base_id;
if (ppkey_flags)
*ppkey_flags = ameth->pkey_flags;
if (pinfo)
*pinfo = ameth->info;
if (ppem_str)
*ppem_str = ameth->pem_str;
if (pkey_id != NULL)
*pkey_id = ameth->pkey_id;
if (pkey_base_id != NULL)
*pkey_base_id = ameth->base_method->pkey_id;
if (pkey_flags != NULL)
*pkey_flags = ameth->pkey_flags;
if (info != NULL)
*info = ameth->info;
if (pem_str != NULL)
*pem_str = ameth->pem_str;
return 1;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pmeth_lib.c,v 1.35 2023/11/29 21:35:57 tb Exp $ */
/* $OpenBSD: pmeth_lib.c,v 1.36 2024/01/04 20:15:01 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -71,9 +71,6 @@
#include "asn1_local.h"
#include "evp_local.h"
DECLARE_STACK_OF(EVP_PKEY_METHOD)
STACK_OF(EVP_PKEY_METHOD) *pkey_app_methods = NULL;
extern const EVP_PKEY_METHOD cmac_pkey_meth;
extern const EVP_PKEY_METHOD dh_pkey_meth;
extern const EVP_PKEY_METHOD dsa_pkey_meth;
@ -102,43 +99,15 @@ static const EVP_PKEY_METHOD *pkey_methods[] = {
&x25519_pkey_meth,
};
static const size_t pkey_methods_count =
sizeof(pkey_methods) / sizeof(pkey_methods[0]);
int
evp_pkey_meth_get_count(void)
{
int num = pkey_methods_count;
if (pkey_app_methods != NULL)
num += sk_EVP_PKEY_METHOD_num(pkey_app_methods);
return num;
}
const EVP_PKEY_METHOD *
evp_pkey_meth_get0(int idx)
{
int num = pkey_methods_count;
if (idx < 0)
return NULL;
if (idx < num)
return pkey_methods[idx];
idx -= num;
return sk_EVP_PKEY_METHOD_value(pkey_app_methods, idx);
}
#define N_PKEY_METHODS (sizeof(pkey_methods) / sizeof(pkey_methods[0]))
const EVP_PKEY_METHOD *
EVP_PKEY_meth_find(int type)
{
const EVP_PKEY_METHOD *pmeth;
int i;
size_t i;
for (i = evp_pkey_meth_get_count() - 1; i >= 0; i--) {
pmeth = evp_pkey_meth_get0(i);
for (i = 0; i < N_PKEY_METHODS; i++) {
const EVP_PKEY_METHOD *pmeth = pkey_methods[i];
if (pmeth->pkey_id == type)
return pmeth;
}
@ -275,16 +244,8 @@ EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
int
EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth)
{
if (pkey_app_methods == NULL) {
pkey_app_methods = sk_EVP_PKEY_METHOD_new(NULL);
if (pkey_app_methods == NULL)
return 0;
}
if (!sk_EVP_PKEY_METHOD_push(pkey_app_methods, pmeth))
return 0;
return 1;
EVPerror(ERR_R_DISABLED);
return 0;
}
void

View file

@ -1,4 +1,4 @@
/* $OpenBSD: gost89imit_ameth.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */
/* $OpenBSD: gost89imit_ameth.c,v 1.5 2024/01/04 17:01:26 tb Exp $ */
/*
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Copyright (c) 2005-2006 Cryptocom LTD
@ -75,8 +75,8 @@ mac_ctrl_gost(EVP_PKEY *pkey, int op, long arg1, void *arg2)
}
const EVP_PKEY_ASN1_METHOD gostimit_asn1_meth = {
.base_method = &gostimit_asn1_meth,
.pkey_id = EVP_PKEY_GOSTIMIT,
.pkey_base_id = EVP_PKEY_GOSTIMIT,
.pkey_flags = ASN1_PKEY_SIGPARAM_NULL,
.pem_str = "GOST-MAC",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: gostr341001_ameth.c,v 1.22 2023/12/28 21:53:09 tb Exp $ */
/* $OpenBSD: gostr341001_ameth.c,v 1.24 2024/01/04 17:01:26 tb Exp $ */
/*
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Copyright (c) 2005-2006 Cryptocom LTD
@ -682,46 +682,46 @@ pkey_ctrl_gost01(EVP_PKEY *pkey, int op, long arg1, void *arg2)
return 1;
}
const EVP_PKEY_ASN1_METHOD gostr01_asn1_meths[] = {
{
.pkey_id = EVP_PKEY_GOSTR01,
.pkey_base_id = EVP_PKEY_GOSTR01,
.pkey_flags = ASN1_PKEY_SIGPARAM_NULL,
const EVP_PKEY_ASN1_METHOD gostr01_asn1_meth = {
.base_method = &gostr01_asn1_meth,
.pkey_id = EVP_PKEY_GOSTR01,
.pkey_flags = ASN1_PKEY_SIGPARAM_NULL,
.pem_str = "GOST2001",
.info = "GOST R 34.10-2001",
.pem_str = "GOST2001",
.info = "GOST R 34.10-2001",
.pkey_free = pkey_free_gost01,
.pkey_ctrl = pkey_ctrl_gost01,
.pkey_free = pkey_free_gost01,
.pkey_ctrl = pkey_ctrl_gost01,
.priv_decode = priv_decode_gost01,
.priv_encode = priv_encode_gost01,
.priv_print = priv_print_gost01,
.priv_decode = priv_decode_gost01,
.priv_encode = priv_encode_gost01,
.priv_print = priv_print_gost01,
.param_decode = param_decode_gost01,
.param_encode = param_encode_gost01,
.param_missing = param_missing_gost01,
.param_copy = param_copy_gost01,
.param_cmp = param_cmp_gost01,
.param_print = param_print_gost01,
.param_decode = param_decode_gost01,
.param_encode = param_encode_gost01,
.param_missing = param_missing_gost01,
.param_copy = param_copy_gost01,
.param_cmp = param_cmp_gost01,
.param_print = param_print_gost01,
.pub_decode = pub_decode_gost01,
.pub_encode = pub_encode_gost01,
.pub_cmp = pub_cmp_gost01,
.pub_print = pub_print_gost01,
.pkey_size = pkey_size_gost01,
.pkey_bits = pkey_bits_gost01,
},
{
.pkey_id = EVP_PKEY_GOSTR12_256,
.pkey_base_id = EVP_PKEY_GOSTR01,
.pkey_flags = ASN1_PKEY_ALIAS
},
{
.pkey_id = EVP_PKEY_GOSTR12_512,
.pkey_base_id = EVP_PKEY_GOSTR01,
.pkey_flags = ASN1_PKEY_ALIAS
},
.pub_decode = pub_decode_gost01,
.pub_encode = pub_encode_gost01,
.pub_cmp = pub_cmp_gost01,
.pub_print = pub_print_gost01,
.pkey_size = pkey_size_gost01,
.pkey_bits = pkey_bits_gost01,
};
const EVP_PKEY_ASN1_METHOD gostr12_256_asn1_meth = {
.base_method = &gostr01_asn1_meth,
.pkey_id = EVP_PKEY_GOSTR12_256,
.pkey_flags = ASN1_PKEY_ALIAS,
};
const EVP_PKEY_ASN1_METHOD gostr12_512_asn1_meth = {
.base_method = &gostr01_asn1_meth,
.pkey_id = EVP_PKEY_GOSTR12_512,
.pkey_flags = ASN1_PKEY_ALIAS,
};
#endif

View file

@ -1,4 +1,4 @@
/* $OpenBSD: hm_ameth.c,v 1.19 2022/11/26 16:08:53 tb Exp $ */
/* $OpenBSD: hm_ameth.c,v 1.20 2024/01/04 17:01:26 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2007.
*/
@ -153,8 +153,8 @@ hmac_get_priv_key(const EVP_PKEY *pkey, unsigned char *priv, size_t *len)
}
const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = {
.base_method = &hmac_asn1_meth,
.pkey_id = EVP_PKEY_HMAC,
.pkey_base_id = EVP_PKEY_HMAC,
.pem_str = "HMAC",
.info = "OpenSSL HMAC method",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_ameth.c,v 1.54 2024/01/01 15:43:02 tb Exp $ */
/* $OpenBSD: rsa_ameth.c,v 1.56 2024/01/04 17:01:26 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -1148,52 +1148,50 @@ rsa_cms_encrypt(CMS_RecipientInfo *ri)
}
#endif
const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = {
{
.pkey_id = EVP_PKEY_RSA,
.pkey_base_id = EVP_PKEY_RSA,
.pkey_flags = ASN1_PKEY_SIGPARAM_NULL,
const EVP_PKEY_ASN1_METHOD rsa_asn1_meth = {
.base_method = &rsa_asn1_meth,
.pkey_id = EVP_PKEY_RSA,
.pkey_flags = ASN1_PKEY_SIGPARAM_NULL,
.pem_str = "RSA",
.info = "OpenSSL RSA method",
.pem_str = "RSA",
.info = "OpenSSL RSA method",
.pub_decode = rsa_pub_decode,
.pub_encode = rsa_pub_encode,
.pub_cmp = rsa_pub_cmp,
.pub_print = rsa_pub_print,
.pub_decode = rsa_pub_decode,
.pub_encode = rsa_pub_encode,
.pub_cmp = rsa_pub_cmp,
.pub_print = rsa_pub_print,
.priv_decode = rsa_priv_decode,
.priv_encode = rsa_priv_encode,
.priv_print = rsa_priv_print,
.priv_decode = rsa_priv_decode,
.priv_encode = rsa_priv_encode,
.priv_print = rsa_priv_print,
.pkey_size = rsa_size,
.pkey_bits = rsa_bits,
.pkey_security_bits = rsa_security_bits,
.pkey_size = rsa_size,
.pkey_bits = rsa_bits,
.pkey_security_bits = rsa_security_bits,
.sig_print = rsa_sig_print,
.sig_print = rsa_sig_print,
.pkey_free = rsa_free,
.pkey_ctrl = rsa_pkey_ctrl,
.old_priv_decode = old_rsa_priv_decode,
.old_priv_encode = old_rsa_priv_encode,
.item_verify = rsa_item_verify,
.item_sign = rsa_item_sign,
.pkey_free = rsa_free,
.pkey_ctrl = rsa_pkey_ctrl,
.old_priv_decode = old_rsa_priv_decode,
.old_priv_encode = old_rsa_priv_encode,
.item_verify = rsa_item_verify,
.item_sign = rsa_item_sign,
.pkey_check = rsa_pkey_check,
},
.pkey_check = rsa_pkey_check,
};
{
.pkey_id = EVP_PKEY_RSA2,
.pkey_base_id = EVP_PKEY_RSA,
.pkey_flags = ASN1_PKEY_ALIAS,
const EVP_PKEY_ASN1_METHOD rsa2_asn1_meth = {
.base_method = &rsa_asn1_meth,
.pkey_id = EVP_PKEY_RSA2,
.pkey_flags = ASN1_PKEY_ALIAS,
.pkey_check = rsa_pkey_check,
},
.pkey_check = rsa_pkey_check,
};
const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth = {
.base_method = &rsa_pss_asn1_meth,
.pkey_id = EVP_PKEY_RSA_PSS,
.pkey_base_id = EVP_PKEY_RSA_PSS,
.pkey_flags = ASN1_PKEY_SIGPARAM_NULL,
.pem_str = "RSA-PSS",