diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-01-04 17:01:27 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-01-04 17:01:27 +0000 |
commit | 2c4b111fba1317ee5a15319a903809eec21fbd99 (patch) | |
tree | f6ba736f5241f7b37a5fa751d09eb3f3cd9717db /lib | |
parent | dac9b6c46b49def383c859a08230dbfac9a4309b (diff) |
Replace .pkey_base_id with a .base_method pointer
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/cmac/cm_ameth.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/dh/dh_ameth.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/dsa/dsa_ameth.c | 12 | ||||
-rw-r--r-- | lib/libcrypto/ec/ec_ameth.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/ec/ecx_methods.c | 6 | ||||
-rw-r--r-- | lib/libcrypto/evp/evp_local.h | 4 | ||||
-rw-r--r-- | lib/libcrypto/evp/p_lib.c | 6 | ||||
-rw-r--r-- | lib/libcrypto/gost/gost89imit_ameth.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/gost/gostr341001_ameth.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/hmac/hm_ameth.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/rsa/rsa_ameth.c | 8 |
11 files changed, 32 insertions, 32 deletions
diff --git a/lib/libcrypto/cmac/cm_ameth.c b/lib/libcrypto/cmac/cm_ameth.c index 04e0eb836f8..50db61756c5 100644 --- a/lib/libcrypto/cmac/cm_ameth.c +++ b/lib/libcrypto/cmac/cm_ameth.c @@ -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", diff --git a/lib/libcrypto/dh/dh_ameth.c b/lib/libcrypto/dh/dh_ameth.c index 43beb469f22..d51a5bea4c2 100644 --- a/lib/libcrypto/dh/dh_ameth.c +++ b/lib/libcrypto/dh/dh_ameth.c @@ -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", diff --git a/lib/libcrypto/dsa/dsa_ameth.c b/lib/libcrypto/dsa/dsa_ameth.c index d4cce72fcb8..f9b6a9e7d3f 100644 --- a/lib/libcrypto/dsa/dsa_ameth.c +++ b/lib/libcrypto/dsa/dsa_ameth.c @@ -1,4 +1,4 @@ -/* $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. */ @@ -675,8 +675,8 @@ dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) } 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", @@ -709,25 +709,25 @@ const EVP_PKEY_ASN1_METHOD dsa_asn1_meth = { }; 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, }; diff --git a/lib/libcrypto/ec/ec_ameth.c b/lib/libcrypto/ec/ec_ameth.c index c22f38b345a..7ca5b18020c 100644 --- a/lib/libcrypto/ec/ec_ameth.c +++ b/lib/libcrypto/ec/ec_ameth.c @@ -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", diff --git a/lib/libcrypto/ec/ecx_methods.c b/lib/libcrypto/ec/ecx_methods.c index 75988d99ade..cd512a447f1 100644 --- a/lib/libcrypto/ec/ecx_methods.c +++ b/lib/libcrypto/ec/ecx_methods.c @@ -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", diff --git a/lib/libcrypto/evp/evp_local.h b/lib/libcrypto/evp/evp_local.h index eaede4409a7..52fa8e1e528 100644 --- a/lib/libcrypto/evp/evp_local.h +++ b/lib/libcrypto/evp/evp_local.h @@ -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.12 2024/01/04 17:01:26 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; diff --git a/lib/libcrypto/evp/p_lib.c b/lib/libcrypto/evp/p_lib.c index f46666a0086..b43a0fcd5dc 100644 --- a/lib/libcrypto/evp/p_lib.c +++ b/lib/libcrypto/evp/p_lib.c @@ -1,4 +1,4 @@ -/* $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. * @@ -222,7 +222,7 @@ EVP_PKEY_asn1_find(ENGINE **pe, int type) break; if ((mp->pkey_flags & ASN1_PKEY_ALIAS) == 0) break; - type = mp->pkey_base_id; + type = mp->base_method->pkey_id; } return mp; @@ -259,7 +259,7 @@ EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags, 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) diff --git a/lib/libcrypto/gost/gost89imit_ameth.c b/lib/libcrypto/gost/gost89imit_ameth.c index e300b528016..76e285b2d8d 100644 --- a/lib/libcrypto/gost/gost89imit_ameth.c +++ b/lib/libcrypto/gost/gost89imit_ameth.c @@ -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", diff --git a/lib/libcrypto/gost/gostr341001_ameth.c b/lib/libcrypto/gost/gostr341001_ameth.c index f917827f7a7..e8e8c8aa821 100644 --- a/lib/libcrypto/gost/gostr341001_ameth.c +++ b/lib/libcrypto/gost/gostr341001_ameth.c @@ -1,4 +1,4 @@ -/* $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 @@ -683,8 +683,8 @@ pkey_ctrl_gost01(EVP_PKEY *pkey, int op, long arg1, void *arg2) } 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", @@ -713,14 +713,14 @@ const EVP_PKEY_ASN1_METHOD gostr01_asn1_meth = { }; 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, }; diff --git a/lib/libcrypto/hmac/hm_ameth.c b/lib/libcrypto/hmac/hm_ameth.c index 7e6ad6d69e1..8bb1dc786f7 100644 --- a/lib/libcrypto/hmac/hm_ameth.c +++ b/lib/libcrypto/hmac/hm_ameth.c @@ -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", diff --git a/lib/libcrypto/rsa/rsa_ameth.c b/lib/libcrypto/rsa/rsa_ameth.c index 918e7b89012..b8957c0d1c8 100644 --- a/lib/libcrypto/rsa/rsa_ameth.c +++ b/lib/libcrypto/rsa/rsa_ameth.c @@ -1,4 +1,4 @@ -/* $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. */ @@ -1149,8 +1149,8 @@ rsa_cms_encrypt(CMS_RecipientInfo *ri) #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", @@ -1182,16 +1182,16 @@ const EVP_PKEY_ASN1_METHOD rsa_asn1_meth = { }; 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", |