aboutsummaryrefslogtreecommitdiffstats
path: root/common/util.h
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2025-07-03 06:45:52 +0000
committerNIIBE Yutaka <[email protected]>2025-07-03 06:45:52 +0000
commit5e623b71d5cebbab7f814d3ef6236d20912ecd0e (patch)
tree0a871e0e82e2231a62845218178f2a50e890abb1 /common/util.h
parentdirmngr: Use wrapper function for Windows LDAP peculiarities. (diff)
downloadgnupg-5e623b71d5cebbab7f814d3ef6236d20912ecd0e.tar.gz
gnupg-5e623b71d5cebbab7f814d3ef6236d20912ecd0e.zip
common:kem: Factor out a function to retrieve ECC parameters.
* common/util.h (struct gnupg_ecc_params, gnupg_get_ecc_params): New. (ECC_SCALAR_LEN_MAX, ECC_POINT_LEN_MAX, ECC_HASH_LEN_MAX): New. * agent/pkdecrypt.c (ecc_extract_pk_from_key, ecc_extract_sk_from_key): Follow the change of gnupg_get_ecc_params. (ecc_raw_kem, ecc_pgp_kem_decap, composite_pgp_kem_decrypt): Likewise. (ecc_kem_decrypt): Likewise. (get_ecc_params): Move to... * common/kem.c (gnupg_get_ecc_params): ... here * g10/pkglue.c (ECC_POINT_LEN_MAX, ECC_HASH_LEN_MAX): Remove duplicates. -- GnuPG-bug-id: 7649 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'common/util.h')
-rw-r--r--common/util.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index b81664c3e..b13f4300d 100644
--- a/common/util.h
+++ b/common/util.h
@@ -324,6 +324,27 @@ gpg_error_t gnupg_kem_combiner (void *kek, size_t kek_len,
const void *mlkem_ct, size_t mlkem_ct_len,
const void *fixedinfo, size_t fixedinfo_len);
+/* ECC parameters for KEM encryption/decryption. */
+struct gnupg_ecc_params
+{
+ const char *curve; /* Canonical name of the curve. */
+ size_t pubkey_len; /* Pubkey length in the SEXP representation. */
+ size_t scalar_len;
+ size_t point_len;
+ int hash_algo; /* Hash algo when it's used for composite KEM. */
+ int kem_algo;
+ int scalar_reverse; /* Byte-oder is reverse. */
+ int may_have_prefix; /* Point representation may have prefix. */
+};
+
+const struct gnupg_ecc_params *gnupg_get_ecc_params (const char *curve);
+
+/* Maximum buffer sizes required for ECC KEM. */
+#define ECC_SCALAR_LEN_MAX 66
+#define ECC_POINT_LEN_MAX (1+2*ECC_SCALAR_LEN_MAX)
+#define ECC_HASH_LEN_MAX 64
+
+
/*-- miscellaneous.c --*/
/* This function is called at startup to tell libgcrypt to use our own