From 5ab9d59ee19ec1a50976d98344d331015180f7c9 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 4 Jul 2025 14:19:26 +0900 Subject: common:ecc: Have a field if the curve of ECC is Weierstrass. * common/util.h (struct gnupg_ecc_params): Add is_weierstrauss. * common/kem.c (ecc_table): Update. Also add secp256k1. -- GnuPG-bug-id: 7698 Signed-off-by: NIIBE Yutaka --- common/kem.c | 26 +++++++++++++++++--------- common/util.h | 1 + 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/common/kem.c b/common/kem.c index 5d994f0d6..94ad13457 100644 --- a/common/kem.c +++ b/common/kem.c @@ -256,51 +256,59 @@ static const struct gnupg_ecc_params ecc_table[] = "Curve25519", 33, 32, 32, GCRY_MD_SHA3_256, GCRY_KEM_RAW_X25519, - 1, 1 + 1, 1, 0 }, { "X448", 56, 56, 56, GCRY_MD_SHA3_512, GCRY_KEM_RAW_X448, - 0, 0 + 0, 0, 0 }, { "NIST P-256", 65, 32, 65, GCRY_MD_SHA3_256, GCRY_KEM_RAW_P256R1, - 0, 0 + 0, 0, 1 }, { "NIST P-384", 97, 48, 97, GCRY_MD_SHA3_512, GCRY_KEM_RAW_P384R1, - 0, 0 + 0, 0, 1 }, { "NIST P-521", 133, 66, 133, GCRY_MD_SHA3_512, GCRY_KEM_RAW_P521R1, - 0, 0 + 0, 0, 1 }, { "brainpoolP256r1", 65, 32, 65, GCRY_MD_SHA3_256, GCRY_KEM_RAW_BP256, - 0, 0 + 0, 0, 1 }, { "brainpoolP384r1", 97, 48, 97, GCRY_MD_SHA3_512, GCRY_KEM_RAW_BP384, - 0, 0 + 0, 0, 1 }, { "brainpoolP512r1", 129, 64, 129, GCRY_MD_SHA3_512, GCRY_KEM_RAW_BP512, - 0, 0 + 0, 0, 1 }, - { NULL, 0, 0, 0, 0, 0, 0, 0 } +#ifdef GCRY_KEM_RAW_P256K1 + { + "secp256k1", + 65, 32, 65, + GCRY_MD_SHA3_256, GCRY_KEM_RAW_P256K1, + 0, 0, 1 + }, +#endif + { NULL, 0, 0, 0, 0, 0, 0, 0, 0 } }; diff --git a/common/util.h b/common/util.h index b13f4300d..e8e6ed409 100644 --- a/common/util.h +++ b/common/util.h @@ -335,6 +335,7 @@ struct gnupg_ecc_params int kem_algo; int scalar_reverse; /* Byte-oder is reverse. */ int may_have_prefix; /* Point representation may have prefix. */ + int is_weierstrauss; /* True if it is Weierstrass curve. */ }; const struct gnupg_ecc_params *gnupg_get_ecc_params (const char *curve); -- cgit v1.2.3