Use V5 keys by default (#1063)
This commit is contained in:
parent
a7640bce52
commit
4c93abb9f9
|
@ -69,12 +69,11 @@ export default {
|
||||||
aead_chunk_size_byte: 12,
|
aead_chunk_size_byte: 12,
|
||||||
/**
|
/**
|
||||||
* Use V5 keys.
|
* Use V5 keys.
|
||||||
* **NOT INTEROPERABLE WITH OTHER OPENPGP IMPLEMENTATIONS**
|
* Note: not all OpenPGP implementations are compatible with this option
|
||||||
* **FUTURE OPENPGP.JS VERSIONS MAY BREAK COMPATIBILITY WHEN USING THIS OPTION**
|
|
||||||
* @memberof module:config
|
* @memberof module:config
|
||||||
* @property {Boolean} v5_keys
|
* @property {Boolean} v5_keys
|
||||||
*/
|
*/
|
||||||
v5_keys: false,
|
v5_keys: true,
|
||||||
/**
|
/**
|
||||||
* {@link https://tools.ietf.org/html/rfc4880#section-3.7.1.3|RFC4880 3.7.1.3}:
|
* {@link https://tools.ietf.org/html/rfc4880#section-3.7.1.3|RFC4880 3.7.1.3}:
|
||||||
* Iteration Count Byte for S2K (String to Key)
|
* Iteration Count Byte for S2K (String to Key)
|
||||||
|
|
|
@ -99,8 +99,6 @@ function Signature(date = new Date()) {
|
||||||
/**
|
/**
|
||||||
* parsing function for a signature packet (tag 2).
|
* parsing function for a signature packet (tag 2).
|
||||||
* @param {String} bytes payload of a tag 2 packet
|
* @param {String} bytes payload of a tag 2 packet
|
||||||
* @param {Integer} position position to start reading from the bytes string
|
|
||||||
* @param {Integer} len length of the packet or the remaining length of bytes at position
|
|
||||||
* @returns {module:packet.Signature} object representation
|
* @returns {module:packet.Signature} object representation
|
||||||
*/
|
*/
|
||||||
Signature.prototype.read = function (bytes) {
|
Signature.prototype.read = function (bytes) {
|
||||||
|
|
|
@ -2545,6 +2545,8 @@ function versionSpecificTests() {
|
||||||
|
|
||||||
describe('Key', function() {
|
describe('Key', function() {
|
||||||
let rsaGenStub;
|
let rsaGenStub;
|
||||||
|
let v5_keysVal;
|
||||||
|
let aead_protectVal;
|
||||||
let rsaGenValue = openpgp.crypto.publicKey.rsa.generate(openpgp.util.getWebCryptoAll() ? 2048 : 512, "10001");
|
let rsaGenValue = openpgp.crypto.publicKey.rsa.generate(openpgp.util.getWebCryptoAll() ? 2048 : 512, "10001");
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
@ -2557,11 +2559,25 @@ describe('Key', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
tryTests('V4', versionSpecificTests, {
|
tryTests('V4', versionSpecificTests, {
|
||||||
if: !openpgp.config.ci
|
if: !openpgp.config.ci,
|
||||||
|
beforeEach: function() {
|
||||||
|
v5_keysVal = openpgp.config.v5_keys;
|
||||||
|
openpgp.config.v5_keys = false;
|
||||||
|
},
|
||||||
|
afterEach: function() {
|
||||||
|
openpgp.config.v5_keys = v5_keysVal;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tryTests('V4 - With Worker', versionSpecificTests, {
|
tryTests('V4 - With Worker', versionSpecificTests, {
|
||||||
if: typeof window !== 'undefined' && window.Worker,
|
if: typeof window !== 'undefined' && window.Worker,
|
||||||
|
beforeEach: function() {
|
||||||
|
v5_keysVal = openpgp.config.v5_keys;
|
||||||
|
openpgp.config.v5_keys = false;
|
||||||
|
},
|
||||||
|
afterEach: function() {
|
||||||
|
openpgp.config.v5_keys = v5_keysVal;
|
||||||
|
},
|
||||||
before: async function() {
|
before: async function() {
|
||||||
try {
|
try {
|
||||||
await openpgp.initWorker({ path: '../dist/openpgp.worker.js' });
|
await openpgp.initWorker({ path: '../dist/openpgp.worker.js' });
|
||||||
|
@ -2574,8 +2590,6 @@ describe('Key', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let v5_keysVal;
|
|
||||||
let aead_protectVal;
|
|
||||||
tryTests('V5', versionSpecificTests, {
|
tryTests('V5', versionSpecificTests, {
|
||||||
if: !openpgp.config.ci,
|
if: !openpgp.config.ci,
|
||||||
beforeEach: function() {
|
beforeEach: function() {
|
||||||
|
|
|
@ -910,41 +910,41 @@ V+HOQJQxXJkVRYa3QrFUehiMzTeqqMdgC6ZqJy7+
|
||||||
const keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys
|
const keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys
|
||||||
|
|
||||||
return rsa.generate(keySize, "10001").then(function(mpiGen) {
|
return rsa.generate(keySize, "10001").then(function(mpiGen) {
|
||||||
let mpi = [mpiGen.n, mpiGen.e, mpiGen.d, mpiGen.p, mpiGen.q, mpiGen.u];
|
let mpi = [mpiGen.n, mpiGen.e, mpiGen.d, mpiGen.p, mpiGen.q, mpiGen.u];
|
||||||
mpi = mpi.map(function(k) {
|
mpi = mpi.map(function(k) {
|
||||||
return new openpgp.MPI(k);
|
return new openpgp.MPI(k);
|
||||||
});
|
});
|
||||||
const testText = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
|
||||||
key.params = mpi;
|
key.params = mpi;
|
||||||
key.algorithm = "rsa_sign";
|
key.algorithm = "rsa_sign";
|
||||||
|
|
||||||
const signed = new openpgp.packet.List();
|
const signed = new openpgp.packet.List();
|
||||||
const literal = new openpgp.packet.Literal();
|
const literal = new openpgp.packet.Literal();
|
||||||
const signature = new openpgp.packet.Signature();
|
const signature = new openpgp.packet.Signature();
|
||||||
|
|
||||||
literal.setText(testText);
|
literal.setText(testText);
|
||||||
|
|
||||||
signature.hashAlgorithm = 'sha256';
|
signature.hashAlgorithm = openpgp.enums.hash.sha256;
|
||||||
signature.publicKeyAlgorithm = 'rsa_sign';
|
signature.publicKeyAlgorithm = openpgp.enums.publicKey.rsa_sign;
|
||||||
signature.signatureType = 'text';
|
signature.signatureType = openpgp.enums.signature.text;
|
||||||
|
|
||||||
return signature.sign(key, literal).then(async () => {
|
return signature.sign(key, literal).then(async () => {
|
||||||
|
|
||||||
signed.push(literal);
|
signed.push(literal);
|
||||||
signed.push(signature);
|
signed.push(signature);
|
||||||
|
|
||||||
const raw = signed.write();
|
const raw = signed.write();
|
||||||
|
|
||||||
const signed2 = new openpgp.packet.List();
|
const signed2 = new openpgp.packet.List();
|
||||||
await signed2.read(raw);
|
await signed2.read(raw);
|
||||||
signed2.concat(await openpgp.stream.readToEnd(signed2.stream, arr => arr));
|
signed2.concat(await openpgp.stream.readToEnd(signed2.stream, arr => arr));
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
expect(signed2[1].verify(key, openpgp.enums.signature.text, signed2[0])).to.eventually.be.true,
|
expect(signed2[1].verify(key, openpgp.enums.signature.text, signed2[0])).to.eventually.be.true,
|
||||||
openpgp.stream.pipe(signed2[0].getBytes(), new openpgp.stream.WritableStream())
|
openpgp.stream.pipe(signed2[0].getBytes(), new openpgp.stream.WritableStream())
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user