Skip to content

Commit 422275f

Browse files
committed
PQC: remove hash algo binding for ML-DSA signatures
1 parent 1049a71 commit 422275f

3 files changed

Lines changed: 2 additions & 30 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { generate, sign, verify, validateParams, getRequiredHashAlgo } from './signature';
1+
export { generate, sign, verify, validateParams } from './signature';
22
export { expandSecretSeed as mldsaExpandSecretSeed } from './ml_dsa';

src/crypto/public_key/post_quantum/signature/signature.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ export async function generate(algo) {
1515
}
1616

1717
export async function sign(signatureAlgo, hashAlgo, eccSecretKey, eccPublicKey, mldsaSecretKey, dataDigest) {
18-
if (hashAlgo !== getRequiredHashAlgo(signatureAlgo)) {
19-
// The signature hash algo MUST be set to the specified algorithm, see
20-
// https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-pqc#section-5.2.1.
21-
throw new Error('Unexpected hash algorithm for PQC signature');
22-
}
23-
2418
switch (signatureAlgo) {
2519
case enums.publicKey.pqc_mldsa_ed25519: {
2620
const { eccSignature } = await eccdsa.sign(signatureAlgo, hashAlgo, eccSecretKey, eccPublicKey, dataDigest);
@@ -34,12 +28,6 @@ export async function sign(signatureAlgo, hashAlgo, eccSecretKey, eccPublicKey,
3428
}
3529

3630
export async function verify(signatureAlgo, hashAlgo, eccPublicKey, mldsaPublicKey, dataDigest, { eccSignature, mldsaSignature }) {
37-
if (hashAlgo !== getRequiredHashAlgo(signatureAlgo)) {
38-
// The signature hash algo MUST be set to the specified algorithm, see
39-
// https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-pqc#section-5.2.1.
40-
throw new Error('Unexpected hash algorithm for PQC signature');
41-
}
42-
4331
switch (signatureAlgo) {
4432
case enums.publicKey.pqc_mldsa_ed25519: {
4533
const eccVerifiedPromise = eccdsa.verify(signatureAlgo, hashAlgo, eccPublicKey, dataDigest, eccSignature);
@@ -52,16 +40,6 @@ export async function verify(signatureAlgo, hashAlgo, eccPublicKey, mldsaPublicK
5240
}
5341
}
5442

55-
export function getRequiredHashAlgo(signatureAlgo) {
56-
// See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-pqc#section-5.2.1.
57-
switch (signatureAlgo) {
58-
case enums.publicKey.pqc_mldsa_ed25519:
59-
return enums.hash.sha3_256;
60-
default:
61-
throw new Error('Unsupported signature algorithm');
62-
}
63-
}
64-
6543
export async function validateParams(algo, eccPublicKey, eccSecretKey, mldsaPublicKey, mldsaSeed) {
6644
const eccValidationPromise = eccdsa.validateParams(algo, eccPublicKey, eccSecretKey);
6745
const mldsaValidationPromise = mldsa.validateParams(algo, mldsaPublicKey, mldsaSeed);

src/key/helper.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
SignaturePacket
1010
} from '../packet';
1111
import enums from '../enums';
12-
import { getPreferredCurveHashAlgo, getHashByteLength, publicKey } from '../crypto';
12+
import { getPreferredCurveHashAlgo, getHashByteLength } from '../crypto';
1313
import util from '../util';
1414
import defaultConfig from '../config';
1515

@@ -117,12 +117,6 @@ export async function createBindingSignature(subkey, primaryKey, options, config
117117
* @async
118118
*/
119119
export async function getPreferredHashAlgo(targetKeys, signingKeyPacket, date = new Date(), targetUserIDs = [], config) {
120-
if (signingKeyPacket.algorithm === enums.publicKey.pqc_mldsa_ed25519) {
121-
// For PQC, the returned hash algo MUST be set to the specified algorithm, see
122-
// https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-pqc#section-5.2.1.
123-
return publicKey.postQuantum.signature.getRequiredHashAlgo(signingKeyPacket.algorithm);
124-
}
125-
126120
/**
127121
* If `preferredSenderAlgo` appears in the prefs of all recipients, we pick it; otherwise, we use the
128122
* strongest supported algo (`defaultAlgo` is always implicitly supported by all keys).

0 commit comments

Comments
 (0)