Every EVP_PKEY_ASN1_METHOD is either an ASN.1 method or an alias.
As such it resolves to an underlying ASN.1 method (in one step).
This information can be stored in a base_method pointer in allusion
to the pkey_base_id, which is the name for the nid (aka pkey_id aka
type) of the underlying method.
For an ASN.1 method, the base method is itself, so the base method
is set as a pointer to itself. For an alias it is of course a pointer
to the underlying method. Then obviously ameth->pkey_base_id is the
same as ameth->base_method->pkey_id, so rework all ASN.1 methods to
follow that.
ok jsing
-/* $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.
*/
}
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",
-/* $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.
*/
}
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",
-/* $OpenBSD: dsa_ameth.c,v 1.56 2024/01/04 16:41:56 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.
*/
}
const EVP_PKEY_ASN1_METHOD dsa_asn1_meth = {
+ .base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA,
- .pkey_base_id = EVP_PKEY_DSA,
.pem_str = "DSA",
.info = "OpenSSL DSA method",
};
const EVP_PKEY_ASN1_METHOD dsa1_asn1_meth = {
+ .base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA1,
- .pkey_base_id = EVP_PKEY_DSA,
.pkey_flags = ASN1_PKEY_ALIAS,
};
const EVP_PKEY_ASN1_METHOD dsa2_asn1_meth = {
+ .base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA2,
- .pkey_base_id = EVP_PKEY_DSA,
.pkey_flags = ASN1_PKEY_ALIAS,
};
const EVP_PKEY_ASN1_METHOD dsa3_asn1_meth = {
+ .base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA3,
- .pkey_base_id = EVP_PKEY_DSA,
.pkey_flags = ASN1_PKEY_ALIAS,
};
const EVP_PKEY_ASN1_METHOD dsa4_asn1_meth = {
+ .base_method = &dsa_asn1_meth,
.pkey_id = EVP_PKEY_DSA4,
- .pkey_base_id = EVP_PKEY_DSA,
.pkey_flags = ASN1_PKEY_ALIAS,
};
-/* $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.
*/
#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",
-/* $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>
*
}
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",
};
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",
-/* $OpenBSD: evp_local.h,v 1.11 2024/01/01 15:23:00 tb Exp $ */
+/* $OpenBSD: evp_local.h,v 1.12 2024/01/04 17:01:26 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
};
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;
-/* $OpenBSD: p_lib.c,v 1.53 2024/01/04 16:41:56 tb Exp $ */
+/* $OpenBSD: p_lib.c,v 1.54 2024/01/04 17:01:26 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
break;
if ((mp->pkey_flags & ASN1_PKEY_ALIAS) == 0)
break;
- type = mp->pkey_base_id;
+ type = mp->base_method->pkey_id;
}
return mp;
if (ppkey_id)
*ppkey_id = ameth->pkey_id;
if (ppkey_base_id)
- *ppkey_base_id = ameth->pkey_base_id;
+ *ppkey_base_id = ameth->base_method->pkey_id;
if (ppkey_flags)
*ppkey_flags = ameth->pkey_flags;
if (pinfo)
-/* $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
}
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",
-/* $OpenBSD: gostr341001_ameth.c,v 1.23 2024/01/04 16:41:56 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
}
const EVP_PKEY_ASN1_METHOD gostr01_asn1_meth = {
+ .base_method = &gostr01_asn1_meth,
.pkey_id = EVP_PKEY_GOSTR01,
- .pkey_base_id = EVP_PKEY_GOSTR01,
.pkey_flags = ASN1_PKEY_SIGPARAM_NULL,
.pem_str = "GOST2001",
};
const EVP_PKEY_ASN1_METHOD gostr12_256_asn1_meth = {
+ .base_method = &gostr01_asn1_meth,
.pkey_id = EVP_PKEY_GOSTR12_256,
- .pkey_base_id = EVP_PKEY_GOSTR01,
.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_base_id = EVP_PKEY_GOSTR01,
.pkey_flags = ASN1_PKEY_ALIAS,
};
-/* $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.
*/
}
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",
-/* $OpenBSD: rsa_ameth.c,v 1.55 2024/01/04 16:41:56 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.
*/
#endif
const EVP_PKEY_ASN1_METHOD rsa_asn1_meth = {
+ .base_method = &rsa_asn1_meth,
.pkey_id = EVP_PKEY_RSA,
- .pkey_base_id = EVP_PKEY_RSA,
.pkey_flags = ASN1_PKEY_SIGPARAM_NULL,
.pem_str = "RSA",
};
const EVP_PKEY_ASN1_METHOD rsa2_asn1_meth = {
+ .base_method = &rsa_asn1_meth,
.pkey_id = EVP_PKEY_RSA2,
- .pkey_base_id = EVP_PKEY_RSA,
.pkey_flags = ASN1_PKEY_ALIAS,
.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",