Skip to content

Commit 00c31f8

Browse files
committed
gpg: New option --disable-pqc-encryption.
* g10/options.h (flags): Add field disable_pqc_encryption. * g10/gpg.c (oDisablePQCEncryption): New. (opts): Add --option. (main): Set option. * g10/getkey.c (finish_lookup): Skip subkeys if option is set. -- This option can be used to avoid the use of Kyber encryption subkeys if this does not make sense (i.e. protection of local files).
1 parent da9fb6b commit 00c31f8

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

doc/gpg.texi

+7
Original file line numberDiff line numberDiff line change
@@ -3157,6 +3157,13 @@ ML-KEM1024) algorithms and AES-256 are considered quantum-resistant;
31573157
Kyber is always used in a composite scheme along with a classic ECC
31583158
algorithm.
31593159

3160+
@item --disable-pqc-encryption
3161+
@opindex disable-pqc-encryption
3162+
This option disables the use of quantum-resistant subkeys and uses a
3163+
subkey with a non-quantum-resistant algorithm if available or throw an
3164+
error otherwise. The option is ignored if
3165+
@option{--require-pqc-encryption} is active.
3166+
31603167
@item --require-compliance
31613168
@opindex require-compliance
31623169
To check that data has been encrypted according to the rules of the

doc/keyformat.txt

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ The UTC time the key was created in ISO compressed format
8989
(yyyymmddThhmmss). This information can be used to re-create an
9090
OpenPGP key.
9191

92+
*** Link
93+
For a composite key this item gives the keygrip of the other key part.
94+
In particular Kyber keys may use this to link to the ECC part and vice versa.
95+
9296
*** Label
9397
This is a short human readable description for the key which can be
9498
used by the software to describe the key in a user interface. For

g10/getkey.c

+8
Original file line numberDiff line numberDiff line change
@@ -3804,6 +3804,14 @@ finish_lookup (kbnode_t keyblock, unsigned int req_usage, int want_exact,
38043804
req_usage, pk->pubkey_usage);
38053805
continue;
38063806
}
3807+
if (opt.flags.disable_pqc_encryption
3808+
&& pk->pubkey_algo == PUBKEY_ALGO_KYBER)
3809+
{
3810+
if (DBG_LOOKUP)
3811+
log_debug ("\tsubkey skipped due to option %s\n",
3812+
"--disable-pqc-encryption");
3813+
continue;
3814+
}
38073815

38083816
n_subkeys++;
38093817
if (pk->flags.revoked)

g10/gpg.c

+7
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ enum cmd_and_opt_values
461461
oAssertPubkeyAlgo,
462462
oKbxBufferSize,
463463
oRequirePQCEncryption,
464+
oDisablePQCEncryption,
464465
oProcAllSigs,
465466

466467
oNoop
@@ -907,6 +908,7 @@ static gpgrt_opt_t opts[] = {
907908
ARGPARSE_s_s (oDigestAlgo, "digest-algo", "@"),
908909
ARGPARSE_s_s (oCertDigestAlgo, "cert-digest-algo", "@"),
909910
ARGPARSE_s_n (oRequirePQCEncryption, "require-pqc-encryption", "@"),
911+
ARGPARSE_s_n (oDisablePQCEncryption, "disable-pqc-encryption", "@"),
910912

911913
ARGPARSE_header (NULL, N_("Options for unattended use")),
912914

@@ -3095,6 +3097,11 @@ main (int argc, char **argv)
30953097
case oMinRSALength: opt.min_rsa_length = pargs.r.ret_ulong; break;
30963098
case oRequirePQCEncryption:
30973099
opt.flags.require_pqc_encryption = 1;
3100+
opt.flags.disable_pqc_encryption = 0;
3101+
break;
3102+
case oDisablePQCEncryption:
3103+
if (!opt.flags.require_pqc_encryption)
3104+
opt.flags.disable_pqc_encryption = 1;
30983105
break;
30993106

31003107
case oRFC2440Text: opt.rfc2440_text=1; break;

g10/options.h

+3
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ struct
308308
unsigned int require_compliance:1;
309309
/* Fail encryption unless a PQC algorithm is used. */
310310
unsigned int require_pqc_encryption:1;
311+
/* Do not use PQC subkeys for encryption. This is never set if
312+
* require_pqc_encryption is also set. */
313+
unsigned int disable_pqc_encryption:1;
311314
/* Process all signatures even in batch mode. */
312315
unsigned int proc_all_sigs:1;
313316
} flags;

0 commit comments

Comments
 (0)