aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2020-06-23 01:10:29 +0000
committerNIIBE Yutaka <[email protected]>2020-06-23 01:10:29 +0000
commitc94eea15d6847c08d2d9ff1c7608953f25fea67d (patch)
tree5f7568a7e6bdde48a2ddb677172e210ef904c803
parentagent: Use get_pk_algo_from_key. (diff)
downloadgnupg-c94eea15d6847c08d2d9ff1c7608953f25fea67d.tar.gz
gnupg-c94eea15d6847c08d2d9ff1c7608953f25fea67d.zip
ecc: Use "cv448" to specify key using X448.
* common/openpgp-oid.c (oidtable): Use "cv448". (oid_cv448): Rename from oid_x448. (openpgp_oidbuf_is_cv448, openpgp_oid_is_cv448): Likewise. * common/util.h (openpgp_oid_is_cv448): Follow the change. * g10/ecdh.c (pk_ecdh_generate_ephemeral_key): Likewise. * g10/keygen.c (gen_ecc, ask_algo): Use "cv448". (parse_key_parameter_part): Likewise. * g10/pkglue.c (get_data_from_sexp): Fix for debug output. Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--common/openpgp-oid.c23
-rw-r--r--common/util.h2
-rw-r--r--g10/ecdh.c2
-rw-r--r--g10/keygen.c8
-rw-r--r--g10/pkglue.c3
5 files changed, 23 insertions, 15 deletions
diff --git a/common/openpgp-oid.c b/common/openpgp-oid.c
index 8404b01a5..605caa679 100644
--- a/common/openpgp-oid.c
+++ b/common/openpgp-oid.c
@@ -48,7 +48,7 @@ static struct {
{ "Curve25519", "1.3.6.1.4.1.3029.1.5.1", 255, "cv25519", PUBKEY_ALGO_ECDH },
{ "Ed25519", "1.3.6.1.4.1.11591.15.1", 255, "ed25519", PUBKEY_ALGO_EDDSA },
- { "X448", "1.3.101.111", 448, "x448", PUBKEY_ALGO_ECDH },
+ { "X448", "1.3.101.111", 448, "cv448", PUBKEY_ALGO_ECDH },
{ "NIST P-256", "1.2.840.10045.3.1.7", 256, "nistp256" },
{ "NIST P-384", "1.3.132.0.34", 384, "nistp384" },
@@ -72,8 +72,15 @@ static const char oid_ed25519[] =
static const char oid_cv25519[] =
{ 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x97, 0x55, 0x01, 0x05, 0x01 };
-/* The OID for X448 in OpenPGP format. */
-static const char oid_x448[] = { 0x03, 0x2b, 0x65, 0x6f };
+/* The OID for X448 in OpenPGP format. */
+/*
+ * Here, we have a little semantic discrepancy. X448 is the name of
+ * the ECDH computation and the OID is assigned to the algorithm in
+ * RFC 8410. Note that this OID is not the one which is assigned to
+ * the curve itself (originally in 8410). Nevertheless, we use "X448"
+ * for the curve in libgcrypt.
+ */
+static const char oid_cv448[] = { 0x03, 0x2b, 0x65, 0x6f };
/* A table to store keyalgo strings like "rsa2048 or "ed25519" so that
* we do not need to allocate them. This is currently a simple array
@@ -340,10 +347,10 @@ openpgp_oidbuf_is_cv25519 (const void *buf, size_t len)
/* Return true if (BUF,LEN) represents the OID for X448. */
static int
-openpgp_oidbuf_is_x448 (const void *buf, size_t len)
+openpgp_oidbuf_is_cv448 (const void *buf, size_t len)
{
- return (buf && len == DIM (oid_x448)
- && !memcmp (buf, oid_x448, DIM (oid_x448)));
+ return (buf && len == DIM (oid_cv448)
+ && !memcmp (buf, oid_cv448, DIM (oid_cv448)));
}
@@ -364,7 +371,7 @@ openpgp_oid_is_cv25519 (gcry_mpi_t a)
/* Return true if the MPI A represents the OID for X448. */
int
-openpgp_oid_is_x448 (gcry_mpi_t a)
+openpgp_oid_is_cv448 (gcry_mpi_t a)
{
const unsigned char *buf;
unsigned int nbits;
@@ -373,7 +380,7 @@ openpgp_oid_is_x448 (gcry_mpi_t a)
return 0;
buf = gcry_mpi_get_opaque (a, &nbits);
- return openpgp_oidbuf_is_x448 (buf, (nbits+7)/8);
+ return openpgp_oidbuf_is_cv448 (buf, (nbits+7)/8);
}
diff --git a/common/util.h b/common/util.h
index d8914772d..490c443d8 100644
--- a/common/util.h
+++ b/common/util.h
@@ -238,7 +238,7 @@ int openpgp_oidbuf_is_ed25519 (const void *buf, size_t len);
int openpgp_oid_is_ed25519 (gcry_mpi_t a);
int openpgp_oidbuf_is_cv25519 (const void *buf, size_t len);
int openpgp_oid_is_cv25519 (gcry_mpi_t a);
-int openpgp_oid_is_x448 (gcry_mpi_t a);
+int openpgp_oid_is_cv448 (gcry_mpi_t a);
const char *openpgp_curve_to_oid (const char *name,
unsigned int *r_nbits, int *r_algo);
const char *openpgp_oid_to_curve (const char *oid, int canon);
diff --git a/g10/ecdh.c b/g10/ecdh.c
index 230602462..ac2883cf4 100644
--- a/g10/ecdh.c
+++ b/g10/ecdh.c
@@ -456,7 +456,7 @@ pk_ecdh_generate_ephemeral_key (gcry_mpi_t *pkey, gcry_mpi_t *r_k)
int is_little_endian = 0;
int require_opaque = 0;
- if (openpgp_oid_is_x448 (pkey[0]))
+ if (openpgp_oid_is_cv448 (pkey[0]))
{
is_little_endian = 1;
require_opaque = 1;
diff --git a/g10/keygen.c b/g10/keygen.c
index aab5929ef..590536726 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -1748,7 +1748,7 @@ gen_ecc (int algo, const char *curve, kbnode_t pub_root,
curve = "Curve25519";
else if (!ascii_strcasecmp (curve, "ed25519"))
curve = "Ed25519";
- else if (!ascii_strcasecmp (curve, "x448"))
+ else if (!ascii_strcasecmp (curve, "cv448"))
curve = "X448";
/* Note that we use the "comp" flag with EdDSA to request the use of
@@ -2328,7 +2328,7 @@ ask_algo (ctrl_t ctrl, int addmode, int *r_subkey_algo, unsigned int *r_usage,
kpi->algo = PUBKEY_ALGO_EDDSA;
else if (!strcmp (algostr, "cv25519"))
kpi->algo = PUBKEY_ALGO_ECDH;
- else if (!strcmp (algostr, "x448"))
+ else if (!strcmp (algostr, "cv448"))
kpi->algo = PUBKEY_ALGO_ECDH;
else if ((kpi->usage & GCRY_PK_USAGE_ENCR))
kpi->algo = PUBKEY_ALGO_ECDH;
@@ -3483,7 +3483,7 @@ parse_key_parameter_part (ctrl_t ctrl,
algo = PUBKEY_ALGO_EDDSA;
else if (!strcmp (algostr, "cv25519"))
algo = PUBKEY_ALGO_ECDH;
- else if (!strcmp (algostr, "x448"))
+ else if (!strcmp (algostr, "cv448"))
algo = PUBKEY_ALGO_ECDH;
else if ((kpi->usage & GCRY_PK_USAGE_ENCR))
algo = PUBKEY_ALGO_ECDH;
@@ -3612,7 +3612,7 @@ parse_key_parameter_part (ctrl_t ctrl,
* elg2048 := Elgamal with 2048 bit.
* ed25519 := EDDSA using curve Ed25519.
* cv25519 := ECDH using curve Curve25519.
- * x448 := ECDH using curve X448.
+ * cv448 := ECDH using curve X448.
* nistp256:= ECDSA or ECDH using curve NIST P-256
*
* All strings with an unknown prefix are considered an elliptic
diff --git a/g10/pkglue.c b/g10/pkglue.c
index a659a5b06..eda13009b 100644
--- a/g10/pkglue.c
+++ b/g10/pkglue.c
@@ -106,7 +106,8 @@ get_data_from_sexp (gcry_sexp_t sexp, const char *item, size_t *r_size)
const char *value;
byte *v;
- log_printsexp ("get_data_from_sexp:", sexp);
+ if (DBG_CRYPTO)
+ log_printsexp ("get_data_from_sexp:", sexp);
list = gcry_sexp_find_token (sexp, item, 0);
log_assert (list);