Skip to content

Commit

Permalink
Remove SHA-1 from default preferred hash algorithms (#1067)
Browse files Browse the repository at this point in the history
Also, remove SHA-1 from the (unused) KDF params constructor defaults.
  • Loading branch information
larabr committed Jan 13, 2021
1 parent 3b6fb11 commit 09db2dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/key/factory.js
Expand Up @@ -191,10 +191,9 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPackets, options) {
], config.aead_mode);
}
signaturePacket.preferredHashAlgorithms = createdPreferredAlgos([
// prefer fast asm.js implementations (SHA-256). SHA-1 will not be secure much longer...move to bottom of list
// prefer fast asm.js implementations (SHA-256)
enums.hash.sha256,
enums.hash.sha512,
enums.hash.sha1
enums.hash.sha512
], config.prefer_hash_algorithm);
signaturePacket.preferredCompressionAlgorithms = createdPreferredAlgos([
enums.compression.zlib,
Expand Down
4 changes: 2 additions & 2 deletions test/general/key.js
Expand Up @@ -1981,7 +1981,7 @@ function versionSpecificTests() {
expect(key.users[0].selfCertifications[0].preferredAeadAlgorithms).to.eql([aead.eax, aead.ocb]);
}
const hash = openpgp.enums.hash;
expect(key.users[0].selfCertifications[0].preferredHashAlgorithms).to.eql([hash.sha256, hash.sha512, hash.sha1]);
expect(key.users[0].selfCertifications[0].preferredHashAlgorithms).to.eql([hash.sha256, hash.sha512]);
const compr = openpgp.enums.compression;
expect(key.users[0].selfCertifications[0].preferredCompressionAlgorithms).to.eql([compr.zlib, compr.zip, compr.uncompressed]);

Expand Down Expand Up @@ -2031,7 +2031,7 @@ function versionSpecificTests() {
expect(key.users[0].selfCertifications[0].preferredAeadAlgorithms).to.eql([aead.experimental_gcm, aead.eax, aead.ocb]);
}
const hash = openpgp.enums.hash;
expect(key.users[0].selfCertifications[0].preferredHashAlgorithms).to.eql([hash.sha224, hash.sha256, hash.sha512, hash.sha1]);
expect(key.users[0].selfCertifications[0].preferredHashAlgorithms).to.eql([hash.sha224, hash.sha256, hash.sha512]);
const compr = openpgp.enums.compression;
expect(key.users[0].selfCertifications[0].preferredCompressionAlgorithms).to.eql([compr.zlib, compr.zip, compr.uncompressed]);

Expand Down

0 comments on commit 09db2dc

Please sign in to comment.