mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
gpg: Add algo constants for PQC.
* common/openpgpdefs.h (PUBKEY_ALGO_KY768_25519): New. (PUBKEY_ALGO_KY1024_448): New. (PUBKEY_ALGO_DIL3_25519): New. (PUBKEY_ALGO_DIL5_448): New. (PUBKEY_ALGO_SPHINX_SHA2): New. * g10/keygen.c (parse_key_parameter_part): Force v5 keys for these algos. * g10/keyid.c (pubkey_string): Add mapping. * g10/misc.c (openpgp_pk_algo_usage): Add standard key usage. -- See draft-wussler-openpgp-pqc-01.txt for the code points. To limit the number of algorithms, only MUST and SHOULD algorithms are considered.
This commit is contained in:
parent
8cacfce898
commit
9f39e4da29
@ -168,7 +168,12 @@ typedef enum
|
||||
PUBKEY_ALGO_ECDSA = 19, /* RFC-6637 */
|
||||
PUBKEY_ALGO_ELGAMAL = 20, /* Elgamal encrypt+sign (legacy). */
|
||||
/* 21 reserved by OpenPGP. */
|
||||
PUBKEY_ALGO_EDDSA = 22, /* EdDSA (not yet assigned). */
|
||||
PUBKEY_ALGO_EDDSA = 22, /* EdDSA. */
|
||||
PUBKEY_ALGO_KY768_25519 = 29, /* Kyber768 + X25519 */
|
||||
PUBKEY_ALGO_KY1024_448 = 30, /* Kyber1024 + X448 */
|
||||
PUBKEY_ALGO_DIL3_25519 = 35, /* Dilithium3 + Ed25519 */
|
||||
PUBKEY_ALGO_DIL5_448 = 36, /* Dilithium5 + Ed448 */
|
||||
PUBKEY_ALGO_SPHINX_SHA2 = 41, /* SPHINX+-simple-SHA2 */
|
||||
PUBKEY_ALGO_PRIVATE10 = 110
|
||||
}
|
||||
pubkey_algo_t;
|
||||
|
31
g10/keygen.c
31
g10/keygen.c
@ -3278,6 +3278,7 @@ parse_key_parameter_part (ctrl_t ctrl,
|
||||
char *keygrip = NULL;
|
||||
u32 keytime = 0;
|
||||
int is_448 = 0;
|
||||
int is_pqc = 0;
|
||||
|
||||
if (!string || !*string)
|
||||
return 0; /* Success. */
|
||||
@ -3312,6 +3313,32 @@ parse_key_parameter_part (ctrl_t ctrl,
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
}
|
||||
}
|
||||
else if (!ascii_strcasecmp (string, "ky768"))
|
||||
{
|
||||
algo = PUBKEY_ALGO_KY768_25519;
|
||||
is_pqc = 1;
|
||||
}
|
||||
else if (!ascii_strcasecmp (string, "ky1024"))
|
||||
{
|
||||
algo = PUBKEY_ALGO_KY1024_448;
|
||||
is_pqc = 1;
|
||||
}
|
||||
else if (!ascii_strcasecmp (string, "dil3"))
|
||||
{
|
||||
algo = PUBKEY_ALGO_DIL3_25519;
|
||||
is_pqc = 1;
|
||||
}
|
||||
else if (!ascii_strcasecmp (string, "dil5"))
|
||||
{
|
||||
algo = PUBKEY_ALGO_DIL5_448;
|
||||
is_pqc = 1;
|
||||
}
|
||||
else if (!ascii_strcasecmp (string, "sphinx")
|
||||
|| !ascii_strcasecmp (string, "sphinx_sha2"))
|
||||
{
|
||||
algo = PUBKEY_ALGO_SPHINX_SHA2;
|
||||
is_pqc = 1;
|
||||
}
|
||||
else if ((curve = openpgp_is_curve_supported (string, &algo, &size)))
|
||||
{
|
||||
if (!algo)
|
||||
@ -3560,8 +3587,8 @@ parse_key_parameter_part (ctrl_t ctrl,
|
||||
return gpg_error (GPG_ERR_WRONG_KEY_USAGE);
|
||||
}
|
||||
|
||||
/* Ed448 and X448 must only be used as v5 keys. */
|
||||
if (is_448)
|
||||
/* Ed448, X448 and the PQC algos must only be used as v5 keys. */
|
||||
if (is_448 || is_pqc)
|
||||
{
|
||||
if (keyversion == 4)
|
||||
log_info (_("WARNING: v4 is specified, but overridden by v5.\n"));
|
||||
|
@ -115,6 +115,11 @@ pubkey_string (PKT_public_key *pk, char *buffer, size_t bufsize)
|
||||
case PUBKEY_ALGO_ECDH:
|
||||
case PUBKEY_ALGO_ECDSA:
|
||||
case PUBKEY_ALGO_EDDSA: prefix = ""; break;
|
||||
case PUBKEY_ALGO_KY768_25519: prefix = "ky768"; break;
|
||||
case PUBKEY_ALGO_KY1024_448: prefix = "ky1024"; break;
|
||||
case PUBKEY_ALGO_DIL3_25519: prefix = "dil3"; break;
|
||||
case PUBKEY_ALGO_DIL5_448: prefix = "dil5"; break;
|
||||
case PUBKEY_ALGO_SPHINX_SHA2: prefix = "sphinx_sha2"; break;
|
||||
}
|
||||
|
||||
if (prefix && *prefix)
|
||||
|
13
g10/misc.c
13
g10/misc.c
@ -799,6 +799,19 @@ openpgp_pk_algo_usage ( int algo )
|
||||
case PUBKEY_ALGO_ECDSA:
|
||||
case PUBKEY_ALGO_EDDSA:
|
||||
use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH;
|
||||
break;
|
||||
|
||||
case PUBKEY_ALGO_KY768_25519:
|
||||
case PUBKEY_ALGO_KY1024_448:
|
||||
use = PUBKEY_USAGE_ENC | PUBKEY_USAGE_RENC;
|
||||
break;
|
||||
|
||||
case PUBKEY_ALGO_DIL3_25519:
|
||||
case PUBKEY_ALGO_DIL5_448:
|
||||
case PUBKEY_ALGO_SPHINX_SHA2:
|
||||
use = PUBKEY_USAGE_CERT | PUBKEY_USAGE_SIG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user