diff --git a/src/key/factory.js b/src/key/factory.js index 9843ad1ca..e1faeefc9 100644 --- a/src/key/factory.js +++ b/src/key/factory.js @@ -220,8 +220,7 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPackets, options, conf // prefer fast asm.js implementations (SHA-256) enums.hash.sha256, enums.hash.sha512, - enums.hash.sha3_256, - enums.hash.sha3_512 + ...(secretKeyPacket.version === 6 ? [enums.hash.sha3_256, enums.hash.sha3_512] : []) ], config.preferredHashAlgorithm); signatureProperties.preferredCompressionAlgorithms = createPreferredAlgos([ enums.compression.uncompressed, diff --git a/test/general/key.js b/test/general/key.js index 4990bef0f..086579605 100644 --- a/test/general/key.js +++ b/test/general/key.js @@ -2261,7 +2261,11 @@ function versionSpecificTests() { ]); } const hash = openpgp.enums.hash; - expect(selfSignature.preferredHashAlgorithms).to.eql([hash.sha256, hash.sha512, hash.sha3_256, hash.sha3_512]); + expect(selfSignature.preferredHashAlgorithms).to.eql( + openpgp.config.v6Keys ? + [hash.sha256, hash.sha512, hash.sha3_256, hash.sha3_512] : + [hash.sha256, hash.sha512] + ); const compr = openpgp.enums.compression; expect(selfSignature.preferredCompressionAlgorithms).to.eql([compr.uncompressed, compr.zlib, compr.zip]); @@ -2316,7 +2320,11 @@ function versionSpecificTests() { ]); } const hash = openpgp.enums.hash; - expect(selfSignature.preferredHashAlgorithms).to.eql([hash.sha224, hash.sha256, hash.sha512, hash.sha3_256, hash.sha3_512]); + expect(selfSignature.preferredHashAlgorithms).to.eql( + openpgp.config.v6Keys ? + [hash.sha224, hash.sha256, hash.sha512, hash.sha3_256, hash.sha3_512] : + [hash.sha224, hash.sha256, hash.sha512] + ); const compr = openpgp.enums.compression; expect(selfSignature.preferredCompressionAlgorithms).to.eql([compr.zlib, compr.uncompressed, compr.zip]);