Store named key params in key objects (#1141)

- Store private and public params separately and by name in objects,
  instead of as an array

- Do not keep params in MPI form, but convert them to Uint8Arrays when
  generating/parsing the key

- Modify low-level crypto functions to always accept and return
  Uint8Arrays instead of BigIntegers

- Move PKCS1 padding to lower level functions
This commit is contained in:
larabr
2020-09-04 14:23:17 +02:00
committed by Daniel Huigens
parent 8854b097b4
commit 3a75eadaa0
24 changed files with 634 additions and 776 deletions

View File

@@ -2584,6 +2584,17 @@ function versionSpecificTests() {
}
module.exports = () => describe('Key', function() {
async function deepCopyKeyParams(params) {
const paramsCopy = {};
Object.keys(params).forEach(name => {
const param = params[name];
const copy = new Uint8Array(param.length);
copy.set(param);
paramsCopy[name] = copy;
});
return paramsCopy;
}
let rsaGenStub;
let v5KeysVal;
let aeadProtectVal;
@@ -2594,8 +2605,9 @@ module.exports = () => describe('Key', function() {
};
beforeEach(function() {
// We fake the generation function to speed up the tests
rsaGenStub = stub(openpgp.crypto.publicKey.rsa, 'generate');
rsaGenStub.callsFake(N => rsaGenValue[N]);
rsaGenStub.callsFake(async N => deepCopyKeyParams(await rsaGenValue[N]));
});
afterEach(function() {
@@ -2882,7 +2894,7 @@ module.exports = () => describe('Key', function() {
key.primaryKey.makeDummy();
expect(key.primaryKey.isDummy()).to.be.true;
await key.validate();
await expect(openpgp.reformatKey({ privateKey: key, userIds: 'test2 <b@a.com>' })).to.be.rejectedWith(/Missing private key parameters/);
await expect(openpgp.reformatKey({ privateKey: key, userIds: 'test2 <b@a.com>' })).to.be.rejectedWith(/Missing key parameters/);
});
it('makeDummy() - subkeys of the converted key can still sign', async function() {
@@ -2905,25 +2917,28 @@ module.exports = () => describe('Key', function() {
const key = await openpgp.key.readArmored(priv_key_rsa);
await key.decrypt('hello world');
const signingKeyPacket = key.subKeys[0].keyPacket;
const params = signingKeyPacket.params;
const privateParams = signingKeyPacket.privateParams;
await key.clearPrivateParams();
key.primaryKey.isEncrypted = false;
key.primaryKey.params = params;
key.primaryKey.privateParams = privateParams;
key.subKeys[0].keyPacket.isEncrypted = false;
key.subKeys[0].keyPacket.params = params;
await expect(key.validate()).to.be.rejectedWith('Missing key parameters');
key.subKeys[0].keyPacket.privateParams = privateParams;
await expect(key.validate()).to.be.rejectedWith('Key is invalid');
});
it('clearPrivateParams() - detect that private key parameters were zeroed out', async function() {
const key = await openpgp.key.readArmored(priv_key_rsa);
await key.decrypt('hello world');
const signingKeyPacket = key.subKeys[0].keyPacket;
const params = signingKeyPacket.params.slice();
const privateParams = {};
Object.entries(signingKeyPacket.privateParams).forEach(([name, value]) => {
privateParams[name] = value;
});
await key.clearPrivateParams();
key.primaryKey.isEncrypted = false;
key.primaryKey.params = params;
key.primaryKey.privateParams = privateParams;
key.subKeys[0].keyPacket.isEncrypted = false;
key.subKeys[0].keyPacket.params = params;
key.subKeys[0].keyPacket.privateParams = privateParams;
await expect(key.validate()).to.be.rejectedWith('Key is invalid');
});
@@ -3398,9 +3413,9 @@ VYGdb3eNlV8CfoEC
const subKey = newPrivateKey.subKeys[total];
expect(subKey).to.exist;
expect(newPrivateKey.subKeys.length).to.be.equal(total + 1);
const subkeyN = subKey.keyPacket.params[0];
const pkN = privateKey.primaryKey.params[0];
expect(subkeyN.byteLength()).to.be.equal(rsaBits ? (rsaBits / 8) : pkN.byteLength());
const subkeyN = subKey.keyPacket.publicParams.n;
const pkN = privateKey.primaryKey.publicParams.n;
expect(subkeyN.length).to.be.equal(rsaBits ? (rsaBits / 8) : pkN.length);
expect(subKey.getAlgorithmInfo().algorithm).to.be.equal('rsaEncryptSign');
expect(subKey.getAlgorithmInfo().rsaBits).to.be.equal(rsaBits || privateKey.getAlgorithmInfo().rsaBits);
await subKey.verify(newPrivateKey.primaryKey);
@@ -3446,8 +3461,8 @@ VYGdb3eNlV8CfoEC
expect(subKey1.getKeyId().toHex()).to.be.equal(subKey.getKeyId().toHex());
expect(subKey).to.exist;
expect(newPrivateKey.subKeys.length).to.be.equal(total + 1);
const subkeyOid = subKey.keyPacket.params[0];
const pkOid = privateKey.primaryKey.params[0];
const subkeyOid = subKey.keyPacket.publicParams.oid;
const pkOid = privateKey.primaryKey.publicParams.oid;
expect(subkeyOid.getName()).to.be.equal(pkOid.getName());
expect(subKey.getAlgorithmInfo().algorithm).to.be.equal('eddsa');
await subKey.verify(privateKey.primaryKey);
@@ -3464,7 +3479,7 @@ VYGdb3eNlV8CfoEC
const subKey = newPrivateKey.subKeys[total];
expect(subKey).to.exist;
expect(newPrivateKey.subKeys.length).to.be.equal(total + 1);
expect(subKey.keyPacket.params[0].getName()).to.be.equal(openpgp.enums.curve.curve25519);
expect(subKey.keyPacket.publicParams.oid.getName()).to.be.equal(openpgp.enums.curve.curve25519);
expect(subKey.getAlgorithmInfo().algorithm).to.be.equal('ecdh');
await subKey.verify(privateKey.primaryKey);
});
@@ -3479,8 +3494,8 @@ VYGdb3eNlV8CfoEC
const armoredKey = newPrivateKey.armor();
newPrivateKey = await openpgp.key.readArmored(armoredKey);
const subKey = newPrivateKey.subKeys[total];
const subkeyOid = subKey.keyPacket.params[0];
const pkOid = newPrivateKey.primaryKey.params[0];
const subkeyOid = subKey.keyPacket.publicParams.oid;
const pkOid = newPrivateKey.primaryKey.publicParams.oid;
expect(subkeyOid.getName()).to.be.equal(pkOid.getName());
expect(subKey.getAlgorithmInfo().algorithm).to.be.equal('eddsa');
await subKey.verify(newPrivateKey.primaryKey);

View File

@@ -549,13 +549,24 @@ function withCompression(tests) {
}
module.exports = () => describe('OpenPGP.js public api tests', function() {
async function deepCopyKeyParams(params) {
const paramsCopy = {};
Object.keys(params).forEach(name => {
const param = params[name];
const copy = new Uint8Array(param.length);
copy.set(param);
paramsCopy[name] = copy;
});
return paramsCopy;
}
let rsaGenStub;
let rsaGenValue = openpgp.crypto.publicKey.rsa.generate(openpgp.util.getWebCryptoAll() ? 2048 : 512, 65537);
const rsaGenValue = openpgp.crypto.publicKey.rsa.generate(openpgp.util.getWebCryptoAll() ? 2048 : 512, 65537);
beforeEach(function() {
// We fake the generation function to speed up the tests
rsaGenStub = stub(openpgp.crypto.publicKey.rsa, 'generate');
rsaGenStub.returns(rsaGenValue);
rsaGenStub.returns(async () => deepCopyKeyParams(await rsaGenValue()));
});
afterEach(function() {
@@ -2329,7 +2340,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
const pubKeyDE = await openpgp.key.readArmored(pub_key_de);
const privKeyDE = await openpgp.key.readArmored(priv_key_de);
// corrupt the public key params
privKeyDE.subKeys[0].keyPacket.params[0].data[0]++;
privKeyDE.subKeys[0].keyPacket.publicParams.p[0]++;
// validation will not check the decryption subkey and will succeed
await privKeyDE.decrypt(passphrase);
const encrypted = await openpgp.encrypt({

View File

@@ -6,6 +6,7 @@ chai.use(require('chai-as-promised'));
const { expect } = chai;
const input = require('./testInputs.js');
const { PacketList } = require('../../dist/node/openpgp.min');
function stringify(array) {
if (openpgp.util.isStream(array)) {
@@ -315,16 +316,10 @@ module.exports = () => describe("Packet", function() {
});
it('Public key encrypted symmetric key packet', function() {
const rsa = openpgp.crypto.publicKey.rsa;
const rsa = openpgp.enums.publicKey.rsaEncryptSign;
const keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys
return rsa.generate(keySize, 65537).then(function(mpiGen) {
let mpi = [mpiGen.n, mpiGen.e, mpiGen.d, mpiGen.p, mpiGen.q, mpiGen.u];
mpi = mpi.map(function(k) {
return new openpgp.MPI(k);
});
return openpgp.crypto.generateParams(rsa, keySize, 65537).then(function({ publicParams, privateParams }) {
const enc = new openpgp.PublicKeyEncryptedSessionKeyPacket();
const msg = new openpgp.PacketList();
const msg2 = new openpgp.PacketList();
@@ -333,14 +328,12 @@ module.exports = () => describe("Packet", function() {
enc.publicKeyAlgorithm = 'rsaEncryptSign';
enc.sessionKeyAlgorithm = 'aes256';
enc.publicKeyId.bytes = '12345678';
return enc.encrypt({ params: mpi, getFingerprintBytes() {} }).then(async () => {
return enc.encrypt({ publicParams, getFingerprintBytes() {} }).then(async () => {
msg.push(enc);
await msg2.read(msg.write(), openpgp);
return msg2[0].decrypt({ algorithm: 'rsaEncryptSign', params: mpi, getFingerprintBytes() {} }).then(() => {
return msg2[0].decrypt({ algorithm: 'rsaEncryptSign', publicParams, privateParams, getFingerprintBytes() {} }).then(() => {
expect(stringify(msg2[0].sessionKey)).to.equal(stringify(enc.sessionKey));
expect(msg2[0].sessionKeyAlgorithm).to.equal(enc.sessionKeyAlgorithm);
});
@@ -841,82 +834,67 @@ V+HOQJQxXJkVRYa3QrFUehiMzTeqqMdgC6ZqJy7+
expect(rawNotations[1].humanReadable).to.equal(true);
});
it('Writing and encryption of a secret key packet.', function() {
const key = new openpgp.PacketList();
key.push(new openpgp.SecretKeyPacket());
const rsa = openpgp.crypto.publicKey.rsa;
it('Writing and encryption of a secret key packet (AEAD)', async function() {
const rsa = openpgp.enums.publicKey.rsaEncryptSign;
const keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys
const { privateParams, publicParams } = await openpgp.crypto.generateParams(rsa, keySize, 65537);
return rsa.generate(keySize, 65537).then(async function(mpiGen) {
let mpi = [mpiGen.n, mpiGen.e, mpiGen.d, mpiGen.p, mpiGen.q, mpiGen.u];
mpi = mpi.map(function(k) {
return new openpgp.MPI(k);
});
const secretKeyPacket = new openpgp.SecretKeyPacket();
secretKeyPacket.privateParams = privateParams;
secretKeyPacket.publicParams = publicParams;
secretKeyPacket.algorithm = "rsaSign";
secretKeyPacket.isEncrypted = false;
await secretKeyPacket.encrypt('hello');
key[0].params = mpi;
key[0].algorithm = "rsaSign";
key[0].isEncrypted = false;
await key[0].encrypt('hello');
const raw = new openpgp.PacketList();
raw.push(secretKeyPacket);
const packetList = new openpgp.PacketList();
await packetList.read(raw.write(), openpgp);
const secretKeyPacket2 = packetList[0];
await secretKeyPacket2.decrypt('hello');
const raw = key.write();
const key2 = new openpgp.PacketList();
await key2.read(raw, openpgp);
await key2[0].decrypt('hello');
expect(key[0].params.toString()).to.equal(key2[0].params.toString());
});
expect(secretKeyPacket2.privateParams).to.deep.equal(secretKeyPacket.privateParams);
expect(secretKeyPacket2.publicParams).to.deep.equal(secretKeyPacket.publicParams);
});
it('Writing and encryption of a secret key packet. (AEAD)', async function() {
let aeadProtectVal = openpgp.config.aeadProtect;
openpgp.config.aeadProtect = true;
it('Writing and encryption of a secret key packet (CFB)', async function() {
const aeadProtectVal = openpgp.config.aeadProtect;
openpgp.config.aeadProtect = false;
const key = new openpgp.PacketList();
key.push(new openpgp.SecretKeyPacket());
const rsa = openpgp.crypto.publicKey.rsa;
const rsa = openpgp.enums.publicKey.rsaEncryptSign;
const keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys
try {
const mpiGen = await rsa.generate(keySize, 65537);
let mpi = [mpiGen.n, mpiGen.e, mpiGen.d, mpiGen.p, mpiGen.q, mpiGen.u];
mpi = mpi.map(function(k) {
return new openpgp.MPI(k);
});
const { privateParams, publicParams } = await openpgp.crypto.generateParams(rsa, keySize, 65537);
const secretKeyPacket = new openpgp.SecretKeyPacket();
secretKeyPacket.privateParams = privateParams;
secretKeyPacket.publicParams = publicParams;
secretKeyPacket.algorithm = "rsaSign";
secretKeyPacket.isEncrypted = false;
await secretKeyPacket.encrypt('hello');
key[0].params = mpi;
key[0].algorithm = "rsaSign";
key[0].isEncrypted = false;
await key[0].encrypt('hello');
const raw = key.write();
const key2 = new openpgp.PacketList();
await key2.read(raw, openpgp);
await key2[0].decrypt('hello');
expect(key[0].params.toString()).to.equal(key2[0].params.toString());
const raw = new openpgp.PacketList();
raw.push(secretKeyPacket);
const packetList = new openpgp.PacketList();
await packetList.read(raw.write(), openpgp);
const secretKeyPacket2 = packetList[0];
await secretKeyPacket2.decrypt('hello');
} finally {
openpgp.config.aeadProtect = aeadProtectVal;
}
});
it('Writing and verification of a signature packet.', function() {
it('Writing and verification of a signature packet', function() {
const key = new openpgp.SecretKeyPacket();
const rsa = openpgp.crypto.publicKey.rsa;
const rsa = openpgp.enums.publicKey.rsaEncryptSign;
const keySize = openpgp.util.getWebCryptoAll() ? 2048 : 512; // webkit webcrypto accepts minimum 2048 bit keys
return rsa.generate(keySize, 65537).then(function(mpiGen) {
let mpi = [mpiGen.n, mpiGen.e, mpiGen.d, mpiGen.p, mpiGen.q, mpiGen.u];
mpi = mpi.map(function(k) {
return new openpgp.MPI(k);
});
return openpgp.crypto.generateParams(rsa, keySize, 65537).then(function({ privateParams, publicParams }) {
const testText = input.createSomeMessage();
key.params = mpi;
key.publicParams = publicParams;
key.privateParams = privateParams;
key.algorithm = "rsaSign";
const signed = new openpgp.PacketList();

View File

@@ -877,9 +877,9 @@ hUhMKMuiM3pRwdIyDOItkUWQmjEEw7/XmhgInkXsCw==
expect(msg.signatures).to.have.length(1);
expect(msg.signatures[0].valid).to.be.true;
expect(msg.signatures[0].signature.packets.length).to.equal(1);
await expect(openpgp.sign({ message: openpgp.message.fromText('test'), privateKeys: [priv_key_gnupg_ext] })).to.eventually.be.rejectedWith('Missing private key parameters');
await expect(openpgp.reformatKey({ userIds: { name: 'test' }, privateKey: priv_key_gnupg_ext })).to.eventually.be.rejectedWith('Missing private key parameters');
await expect(openpgp.reformatKey({ userIds: { name: 'test' }, privateKey: priv_key_gnupg_ext_2, passphrase: 'test' })).to.eventually.be.rejectedWith('Missing private key parameters');
await expect(openpgp.sign({ message: openpgp.message.fromText('test'), privateKeys: [priv_key_gnupg_ext] })).to.eventually.be.rejectedWith(/Missing key parameters/);
await expect(openpgp.reformatKey({ userIds: { name: 'test' }, privateKey: priv_key_gnupg_ext })).to.eventually.be.rejectedWith(/Missing key parameters/);
await expect(openpgp.reformatKey({ userIds: { name: 'test' }, privateKey: priv_key_gnupg_ext_2, passphrase: 'test' })).to.eventually.be.rejectedWith(/Missing key parameters/);
await priv_key_gnupg_ext.encrypt("abcd");
expect(priv_key_gnupg_ext.isDecrypted()).to.be.false;
const primaryKey_packet2 = priv_key_gnupg_ext.primaryKey.write();

View File

@@ -1,18 +1,17 @@
/**
* Generates a 64 character long javascript string out of the whole utf-8 range.
*/
function createSomeMessage(){
let arr = [];
for (let i = 0; i < 30; i++) {
arr.push(Math.floor(Math.random() * 10174) + 1);
}
for (let i = 0; i < 10; i++) {
arr.push(0x1F600 + Math.floor(Math.random() * (0x1F64F - 0x1F600)) + 1);
}
return ' \t' + String.fromCodePoint(...arr).replace(/\r/g, '\n') + ' \t\n한국어/조선말';
const arr = [];
for (let i = 0; i < 30; i++) {
arr.push(Math.floor(Math.random() * 10174) + 1);
}
for (let i = 0; i < 10; i++) {
arr.push(0x1F600 + Math.floor(Math.random() * (0x1F64F - 0x1F600)) + 1);
}
return ' \t' + String.fromCodePoint(...arr).replace(/\r/g, '\n') + ' \t\n한국어/조선말';
}
module.exports = {
createSomeMessage: createSomeMessage
createSomeMessage: createSomeMessage
};

View File

@@ -219,22 +219,24 @@ module.exports = () => (openpgp.config.ci ? describe.skip : describe)('X25519 Cr
const { publicKey } = openpgp.crypto.publicKey.nacl.sign.keyPair.fromSeed(openpgp.util.hexToUint8Array(vector.SECRET_KEY));
expect(publicKey).to.deep.equal(openpgp.util.hexToUint8Array(vector.PUBLIC_KEY));
const data = util.strToUint8Array(vector.MESSAGE);
const keyIntegers = [
new openpgp.OID(curve.oid),
new openpgp.MPI(util.hexToStr('40'+vector.PUBLIC_KEY)),
new openpgp.MPI(util.hexToStr(vector.SECRET_KEY))
];
const privateParams = {
seed: util.hexToUint8Array(vector.SECRET_KEY)
};
const publicParams = {
oid: new openpgp.OID(curve.oid),
Q: util.hexToUint8Array('40' + vector.PUBLIC_KEY)
};
const msg_MPIs = [
new openpgp.MPI(util.uint8ArrayToStr(util.hexToUint8Array(vector.SIGNATURE.R).reverse())),
new openpgp.MPI(util.uint8ArrayToStr(util.hexToUint8Array(vector.SIGNATURE.S).reverse()))
];
return Promise.all([
signature.sign(22, undefined, keyIntegers, undefined, data).then(signed => {
const len = ((signed[0] << 8| signed[1]) + 7) / 8;
signature.sign(22, undefined, publicParams, privateParams, undefined, data).then(signed => {
const len = (((signed[0] << 8) | signed[1]) + 7) / 8;
expect(util.hexToUint8Array(vector.SIGNATURE.R)).to.deep.eq(signed.slice(2, 2 + len));
expect(util.hexToUint8Array(vector.SIGNATURE.S)).to.deep.eq(signed.slice(4 + len));
}),
signature.verify(22, undefined, msg_MPIs, keyIntegers, undefined, data).then(result => {
signature.verify(22, undefined, msg_MPIs, publicParams, undefined, data).then(result => {
expect(result).to.be.true;
})
]);
@@ -242,63 +244,44 @@ module.exports = () => (openpgp.config.ci ? describe.skip : describe)('X25519 Cr
it('Signature of empty string', function () {
return testVector({
SECRET_KEY:
['9d61b19deffd5a60ba844af492ec2cc4',
'4449c5697b326919703bac031cae7f60'].join(''),
PUBLIC_KEY:
['d75a980182b10ab7d54bfed3c964073a',
'0ee172f3daa62325af021a68f707511a'].join(''),
SECRET_KEY: '9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60',
PUBLIC_KEY: 'd75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a',
MESSAGE: '',
SIGNATURE:
{ R: ['e5564300c360ac729086e2cc806e828a',
'84877f1eb8e5d974d873e06522490155'].join(''),
S: ['5fb8821590a33bacc61e39701cf9b46b',
'd25bf5f0595bbe24655141438e7a100b'].join('') }
SIGNATURE: {
R: 'e5564300c360ac729086e2cc806e828a84877f1eb8e5d974d873e06522490155',
S: '5fb8821590a33bacc61e39701cf9b46bd25bf5f0595bbe24655141438e7a100b'
}
});
});
it('Signature of single byte', function () {
return testVector({
SECRET_KEY:
['4ccd089b28ff96da9db6c346ec114e0f',
'5b8a319f35aba624da8cf6ed4fb8a6fb'].join(''),
PUBLIC_KEY:
['3d4017c3e843895a92b70aa74d1b7ebc',
'9c982ccf2ec4968cc0cd55f12af4660c'].join(''),
SECRET_KEY: '4ccd089b28ff96da9db6c346ec114e0f5b8a319f35aba624da8cf6ed4fb8a6fb',
PUBLIC_KEY: '3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c',
MESSAGE: util.hexToStr('72'),
SIGNATURE:
{ R: ['92a009a9f0d4cab8720e820b5f642540',
'a2b27b5416503f8fb3762223ebdb69da'].join(''),
S: ['085ac1e43e15996e458f3613d0f11d8c',
'387b2eaeb4302aeeb00d291612bb0c00'].join('') }
SIGNATURE: {
R: '92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da',
S: '085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00'
}
});
});
it('Signature of two bytes', function () {
return testVector({
SECRET_KEY:
['c5aa8df43f9f837bedb7442f31dcb7b1',
'66d38535076f094b85ce3a2e0b4458f7'].join(''),
PUBLIC_KEY:
['fc51cd8e6218a1a38da47ed00230f058',
'0816ed13ba3303ac5deb911548908025'].join(''),
SECRET_KEY: 'c5aa8df43f9f837bedb7442f31dcb7b166d38535076f094b85ce3a2e0b4458f7',
PUBLIC_KEY: 'fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025',
MESSAGE: util.hexToStr('af82'),
SIGNATURE:
{ R: ['6291d657deec24024827e69c3abe01a3',
'0ce548a284743a445e3680d7db5ac3ac'].join(''),
S: ['18ff9b538d16f290ae67f760984dc659',
'4a7c15e9716ed28dc027beceea1ec40a'].join('') }
SIGNATURE: {
R: '6291d657deec24024827e69c3abe01a30ce548a284743a445e3680d7db5ac3ac',
S: '18ff9b538d16f290ae67f760984dc6594a7c15e9716ed28dc027beceea1ec40a'
}
});
});
it('Signature of 1023 bytes', function () {
return testVector({
SECRET_KEY:
['f5e5767cf153319517630f226876b86c',
'8160cc583bc013744c6bf255f5cc0ee5'].join(''),
PUBLIC_KEY:
['278117fc144c72340f67d0f2316e8386',
'ceffbf2b2428c9c51fef7c597f1d426e'].join(''),
SECRET_KEY: 'f5e5767cf153319517630f226876b86c8160cc583bc013744c6bf255f5cc0ee5',
PUBLIC_KEY: '278117fc144c72340f67d0f2316e8386ceffbf2b2428c9c51fef7c597f1d426e',
MESSAGE: util.hexToStr([
'08b8b2b733424243760fe426a4b54908',
'632110a66c2f6591eabd3345e3e4eb98',
@@ -365,39 +348,32 @@ module.exports = () => (openpgp.config.ci ? describe.skip : describe)('X25519 Cr
'0618983f8741c5ef68d3a101e8a3b8ca',
'c60c905c15fc910840b94c00a0b9d0'
].join('')),
SIGNATURE:
{ R: ['0aab4c900501b3e24d7cdf4663326a3a',
'87df5e4843b2cbdb67cbf6e460fec350'].join(''),
S: ['aa5371b1508f9f4528ecea23c436d94b',
'5e8fcd4f681e30a6ac00a9704a188a03'].join('') }
SIGNATURE: {
R: '0aab4c900501b3e24d7cdf4663326a3a87df5e4843b2cbdb67cbf6e460fec350',
S: 'aa5371b1508f9f4528ecea23c436d94b5e8fcd4f681e30a6ac00a9704a188a03'
}
});
});
it('Signature of SHA(abc)', function () {
return testVector({
SECRET_KEY:
['833fe62409237b9d62ec77587520911e',
'9a759cec1d19755b7da901b96dca3d42'].join(''),
PUBLIC_KEY:
['ec172b93ad5e563bf4932c70e1245034',
'c35467ef2efd4d64ebf819683467e2bf'].join(''),
SECRET_KEY: '833fe62409237b9d62ec77587520911e9a759cec1d19755b7da901b96dca3d42',
PUBLIC_KEY: 'ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf',
MESSAGE: util.hexToStr([
'ddaf35a193617abacc417349ae204131',
'12e6fa4e89a97ea20a9eeee64b55d39a',
'2192992a274fc1a836ba3c23a3feebbd',
'454d4423643ce80e2a9ac94fa54ca49f'
].join('')),
SIGNATURE:
{ R: ['dc2a4459e7369633a52b1bf277839a00',
'201009a3efbf3ecb69bea2186c26b589'].join(''),
S: ['09351fc9ac90b3ecfdfbc7c66431e030',
'3dca179c138ac17ad9bef1177331a704'].join('') }
SIGNATURE: {
R: 'dc2a4459e7369633a52b1bf277839a00201009a3efbf3ecb69bea2186c26b589',
S: '09351fc9ac90b3ecfdfbc7c66431e0303dca179c138ac17ad9bef1177331a704'
}
});
});
});
/* TODO how does GPG2 accept this?
it('Should handle little-endian parameters in EdDSA', function () {
it('Should handle little-endian parameters in EdDSA', async function () {
const pubKey = [
'-----BEGIN PGP PUBLIC KEY BLOCK-----',
'Version: OpenPGP.js v3.0.0',
@@ -412,19 +388,18 @@ module.exports = () => (openpgp.config.ci ? describe.skip : describe)('X25519 Cr
'FQIbDAAAhNQBAKmy4gPorjbwTwy5usylHttP28XnTdaGkZ1E7Rc3G9luAQCs',
'Gbm1oe83ZB+0aSp5m34YkpHQNb80y8PGFy7nIexiAA==',
'=xeG/',
'-----END PGP PUBLIC KEY BLOCK-----'].join('\n');
'-----END PGP PUBLIC KEY BLOCK-----'
].join('\n');
const hi = await openpgp.key.readArmored(pubKey);
const results = hi.getPrimaryUser();
const results = await hi.getPrimaryUser();
// console.log(results);
expect(results).to.exist;
expect(results.user).to.exist;
const user = results.user;
expect(user.selfCertifications[0].verify(
hi.primaryKey, {userId: user.userId, key: hi.primaryKey}
)).to.eventually.be.true;
await user.verifyCertificate(
hi.primaryKey, user.selfCertifications[0], [hi]
);
}); */
});
describe('X25519 Omnibus Tests', omnibus);
});