change some variable names in tests to camelCase
This commit is contained in:
parent
1eb3902a96
commit
4beb31333e
|
@ -223,12 +223,12 @@ describe('Brainpool Cryptography', function () {
|
||||||
const bye = secondKey.key;
|
const bye = secondKey.key;
|
||||||
const pubBye = bye.toPublic();
|
const pubBye = bye.toPublic();
|
||||||
|
|
||||||
const testdata = input.createSomeMessage();
|
const testData = input.createSomeMessage();
|
||||||
const testdata2 = input.createSomeMessage();
|
const testData2 = input.createSomeMessage();
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
// Signing message
|
// Signing message
|
||||||
openpgp.sign(
|
openpgp.sign(
|
||||||
{ data: testdata, privateKeys: hi }
|
{ data: testData, privateKeys: hi }
|
||||||
).then(signed => {
|
).then(signed => {
|
||||||
const msg = openpgp.cleartext.readArmored(signed.data);
|
const msg = openpgp.cleartext.readArmored(signed.data);
|
||||||
// Verifying signed message
|
// Verifying signed message
|
||||||
|
@ -238,7 +238,7 @@ describe('Brainpool Cryptography', function () {
|
||||||
).then(output => expect(output.signatures[0].valid).to.be.true),
|
).then(output => expect(output.signatures[0].valid).to.be.true),
|
||||||
// Verifying detached signature
|
// Verifying detached signature
|
||||||
openpgp.verify(
|
openpgp.verify(
|
||||||
{ message: openpgp.message.fromText(testdata),
|
{ message: openpgp.message.fromText(testData),
|
||||||
publicKeys: pubHi,
|
publicKeys: pubHi,
|
||||||
signature: openpgp.signature.readArmored(signed.data) }
|
signature: openpgp.signature.readArmored(signed.data) }
|
||||||
).then(output => expect(output.signatures[0].valid).to.be.true)
|
).then(output => expect(output.signatures[0].valid).to.be.true)
|
||||||
|
@ -246,7 +246,7 @@ describe('Brainpool Cryptography', function () {
|
||||||
}),
|
}),
|
||||||
// Encrypting and signing
|
// Encrypting and signing
|
||||||
openpgp.encrypt(
|
openpgp.encrypt(
|
||||||
{ data: testdata2,
|
{ data: testData2,
|
||||||
publicKeys: [pubBye],
|
publicKeys: [pubBye],
|
||||||
privateKeys: [hi] }
|
privateKeys: [hi] }
|
||||||
).then(encrypted => {
|
).then(encrypted => {
|
||||||
|
@ -257,7 +257,7 @@ describe('Brainpool Cryptography', function () {
|
||||||
privateKeys: bye,
|
privateKeys: bye,
|
||||||
publicKeys: [pubHi] }
|
publicKeys: [pubHi] }
|
||||||
).then(output => {
|
).then(output => {
|
||||||
expect(output.data).to.equal(testdata2);
|
expect(output.data).to.equal(testData2);
|
||||||
expect(output.signatures[0].valid).to.be.true;
|
expect(output.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
@ -239,8 +239,8 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
function omnibus() {
|
function omnibus() {
|
||||||
it('Omnibus NIST P-256 Test', function () {
|
it('Omnibus NIST P-256 Test', function () {
|
||||||
const options = { userIds: {name: "Hi", email: "hi@hel.lo"}, curve: "p256" };
|
const options = { userIds: {name: "Hi", email: "hi@hel.lo"}, curve: "p256" };
|
||||||
const testdata = input.createSomeMessage();
|
const testData = input.createSomeMessage();
|
||||||
const testdata2 = input.createSomeMessage();
|
const testData2 = input.createSomeMessage();
|
||||||
return openpgp.generateKey(options).then(function (firstKey) {
|
return openpgp.generateKey(options).then(function (firstKey) {
|
||||||
const hi = firstKey.key;
|
const hi = firstKey.key;
|
||||||
const pubHi = hi.toPublic();
|
const pubHi = hi.toPublic();
|
||||||
|
@ -254,7 +254,7 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
// Signing message
|
// Signing message
|
||||||
|
|
||||||
openpgp.sign(
|
openpgp.sign(
|
||||||
{ data: testdata, privateKeys: hi }
|
{ data: testData, privateKeys: hi }
|
||||||
).then(signed => {
|
).then(signed => {
|
||||||
const msg = openpgp.cleartext.readArmored(signed.data);
|
const msg = openpgp.cleartext.readArmored(signed.data);
|
||||||
// Verifying signed message
|
// Verifying signed message
|
||||||
|
@ -264,7 +264,7 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
).then(output => expect(output.signatures[0].valid).to.be.true),
|
).then(output => expect(output.signatures[0].valid).to.be.true),
|
||||||
// Verifying detached signature
|
// Verifying detached signature
|
||||||
openpgp.verify(
|
openpgp.verify(
|
||||||
{ message: openpgp.message.fromText(testdata),
|
{ message: openpgp.message.fromText(testData),
|
||||||
publicKeys: pubHi,
|
publicKeys: pubHi,
|
||||||
signature: openpgp.signature.readArmored(signed.data) }
|
signature: openpgp.signature.readArmored(signed.data) }
|
||||||
).then(output => expect(output.signatures[0].valid).to.be.true)
|
).then(output => expect(output.signatures[0].valid).to.be.true)
|
||||||
|
@ -272,7 +272,7 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
}),
|
}),
|
||||||
// Encrypting and signing
|
// Encrypting and signing
|
||||||
openpgp.encrypt(
|
openpgp.encrypt(
|
||||||
{ data: testdata2,
|
{ data: testData2,
|
||||||
publicKeys: [pubBye],
|
publicKeys: [pubBye],
|
||||||
privateKeys: [hi] }
|
privateKeys: [hi] }
|
||||||
).then(encrypted => {
|
).then(encrypted => {
|
||||||
|
@ -283,7 +283,7 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
privateKeys: bye,
|
privateKeys: bye,
|
||||||
publicKeys: [pubHi] }
|
publicKeys: [pubHi] }
|
||||||
).then(output => {
|
).then(output => {
|
||||||
expect(output.data).to.equal(testdata2);
|
expect(output.data).to.equal(testData2);
|
||||||
expect(output.signatures[0].valid).to.be.true;
|
expect(output.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
@ -59,10 +59,10 @@ describe("Packet", function() {
|
||||||
|
|
||||||
it('Symmetrically encrypted packet', async function() {
|
it('Symmetrically encrypted packet', async function() {
|
||||||
const message = new openpgp.packet.List();
|
const message = new openpgp.packet.List();
|
||||||
const testtext = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
|
||||||
const literal = new openpgp.packet.Literal();
|
const literal = new openpgp.packet.Literal();
|
||||||
literal.setText(testtext);
|
literal.setText(testText);
|
||||||
|
|
||||||
const enc = new openpgp.packet.SymmetricallyEncrypted();
|
const enc = new openpgp.packet.SymmetricallyEncrypted();
|
||||||
message.push(enc);
|
message.push(enc);
|
||||||
|
@ -83,10 +83,10 @@ describe("Packet", function() {
|
||||||
|
|
||||||
it('Symmetrically encrypted packet - MDC error for modern cipher', async function() {
|
it('Symmetrically encrypted packet - MDC error for modern cipher', async function() {
|
||||||
const message = new openpgp.packet.List();
|
const message = new openpgp.packet.List();
|
||||||
const testtext = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
|
||||||
const literal = new openpgp.packet.Literal();
|
const literal = new openpgp.packet.Literal();
|
||||||
literal.setText(testtext);
|
literal.setText(testText);
|
||||||
|
|
||||||
const enc = new openpgp.packet.SymmetricallyEncrypted();
|
const enc = new openpgp.packet.SymmetricallyEncrypted();
|
||||||
message.push(enc);
|
message.push(enc);
|
||||||
|
@ -105,14 +105,14 @@ describe("Packet", function() {
|
||||||
it('Sym. encrypted integrity protected packet', async function() {
|
it('Sym. encrypted integrity protected packet', async function() {
|
||||||
const key = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]);
|
const key = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]);
|
||||||
const algo = 'aes256';
|
const algo = 'aes256';
|
||||||
const testtext = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
|
||||||
const literal = new openpgp.packet.Literal();
|
const literal = new openpgp.packet.Literal();
|
||||||
const enc = new openpgp.packet.SymEncryptedIntegrityProtected();
|
const enc = new openpgp.packet.SymEncryptedIntegrityProtected();
|
||||||
const msg = new openpgp.packet.List();
|
const msg = new openpgp.packet.List();
|
||||||
|
|
||||||
msg.push(enc);
|
msg.push(enc);
|
||||||
literal.setText(testtext);
|
literal.setText(testText);
|
||||||
enc.packets.push(literal);
|
enc.packets.push(literal);
|
||||||
await enc.encrypt(algo, key);
|
await enc.encrypt(algo, key);
|
||||||
|
|
||||||
|
@ -127,13 +127,13 @@ describe("Packet", function() {
|
||||||
it('Sym. encrypted AEAD protected packet', function() {
|
it('Sym. encrypted AEAD protected packet', function() {
|
||||||
const key = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]);
|
const key = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]);
|
||||||
const algo = 'aes256';
|
const algo = 'aes256';
|
||||||
const testtext = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
const literal = new openpgp.packet.Literal();
|
const literal = new openpgp.packet.Literal();
|
||||||
const enc = new openpgp.packet.SymEncryptedAEADProtected();
|
const enc = new openpgp.packet.SymEncryptedAEADProtected();
|
||||||
const msg = new openpgp.packet.List();
|
const msg = new openpgp.packet.List();
|
||||||
|
|
||||||
msg.push(enc);
|
msg.push(enc);
|
||||||
literal.setText(testtext);
|
literal.setText(testText);
|
||||||
enc.packets.push(literal);
|
enc.packets.push(literal);
|
||||||
|
|
||||||
const msg2 = new openpgp.packet.List();
|
const msg2 = new openpgp.packet.List();
|
||||||
|
@ -151,7 +151,7 @@ describe("Packet", function() {
|
||||||
let aead_protect_versionVal = openpgp.config.aead_protect_version;
|
let aead_protect_versionVal = openpgp.config.aead_protect_version;
|
||||||
openpgp.config.aead_protect = true;
|
openpgp.config.aead_protect = true;
|
||||||
openpgp.config.aead_protect_version = 4;
|
openpgp.config.aead_protect_version = 4;
|
||||||
const testtext = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
|
||||||
const key = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]);
|
const key = new Uint8Array([1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2]);
|
||||||
const algo = 'aes256';
|
const algo = 'aes256';
|
||||||
|
@ -161,7 +161,7 @@ describe("Packet", function() {
|
||||||
const msg = new openpgp.packet.List();
|
const msg = new openpgp.packet.List();
|
||||||
|
|
||||||
msg.push(enc);
|
msg.push(enc);
|
||||||
literal.setText(testtext);
|
literal.setText(testText);
|
||||||
enc.packets.push(literal);
|
enc.packets.push(literal);
|
||||||
|
|
||||||
const msg2 = new openpgp.packet.List();
|
const msg2 = new openpgp.packet.List();
|
||||||
|
@ -398,7 +398,7 @@ describe("Packet", function() {
|
||||||
it('Sym. encrypted session key reading/writing', async function() {
|
it('Sym. encrypted session key reading/writing', async function() {
|
||||||
const passphrase = 'hello';
|
const passphrase = 'hello';
|
||||||
const algo = 'aes256';
|
const algo = 'aes256';
|
||||||
const testtext = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
|
||||||
const literal = new openpgp.packet.Literal();
|
const literal = new openpgp.packet.Literal();
|
||||||
const key_enc = new openpgp.packet.SymEncryptedSessionKey();
|
const key_enc = new openpgp.packet.SymEncryptedSessionKey();
|
||||||
|
@ -413,7 +413,7 @@ describe("Packet", function() {
|
||||||
|
|
||||||
const key = key_enc.sessionKey;
|
const key = key_enc.sessionKey;
|
||||||
|
|
||||||
literal.setText(testtext);
|
literal.setText(testText);
|
||||||
enc.packets.push(literal);
|
enc.packets.push(literal);
|
||||||
await enc.encrypt(algo, key);
|
await enc.encrypt(algo, key);
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ describe("Packet", function() {
|
||||||
try {
|
try {
|
||||||
const passphrase = 'hello';
|
const passphrase = 'hello';
|
||||||
const algo = 'aes256';
|
const algo = 'aes256';
|
||||||
const testtext = input.createSomeMessage();
|
const testText = input.createSomeMessage();
|
||||||
|
|
||||||
const literal = new openpgp.packet.Literal();
|
const literal = new openpgp.packet.Literal();
|
||||||
const key_enc = new openpgp.packet.SymEncryptedSessionKey();
|
const key_enc = new openpgp.packet.SymEncryptedSessionKey();
|
||||||
|
@ -451,7 +451,7 @@ describe("Packet", function() {
|
||||||
|
|
||||||
const key = key_enc.sessionKey;
|
const key = key_enc.sessionKey;
|
||||||
|
|
||||||
literal.setText(testtext);
|
literal.setText(testText);
|
||||||
enc.packets.push(literal);
|
enc.packets.push(literal);
|
||||||
await enc.encrypt(algo, key);
|
await enc.encrypt(algo, key);
|
||||||
|
|
||||||
|
@ -781,7 +781,7 @@ describe("Packet", function() {
|
||||||
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";
|
||||||
|
@ -790,7 +790,7 @@ describe("Packet", function() {
|
||||||
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 = 'sha256';
|
||||||
signature.publicKeyAlgorithm = 'rsa_sign';
|
signature.publicKeyAlgorithm = 'rsa_sign';
|
||||||
|
|
|
@ -170,15 +170,15 @@ describe('X25519 Cryptography', function () {
|
||||||
|
|
||||||
it('Sign message', async function () {
|
it('Sign message', async function () {
|
||||||
const name = 'light';
|
const name = 'light';
|
||||||
const randomdata = input.createSomeMessage();
|
const randomData = input.createSomeMessage();
|
||||||
const priv = await load_priv_key(name);
|
const priv = await load_priv_key(name);
|
||||||
const signed = await openpgp.sign({ privateKeys: [priv], data: randomdata});
|
const signed = await openpgp.sign({ privateKeys: [priv], data: randomData});
|
||||||
const pub = load_pub_key(name);
|
const pub = load_pub_key(name);
|
||||||
const msg = openpgp.cleartext.readArmored(signed.data);
|
const msg = openpgp.cleartext.readArmored(signed.data);
|
||||||
const result = await openpgp.verify({ publicKeys: [pub], message: msg});
|
const result = await openpgp.verify({ publicKeys: [pub], message: msg});
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(randomdata);
|
expect(result.data.trim()).to.equal(randomData);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
@ -199,8 +199,8 @@ describe('X25519 Cryptography', function () {
|
||||||
it('Encrypt and sign message', async function () {
|
it('Encrypt and sign message', async function () {
|
||||||
const nightPublic = load_pub_key('night');
|
const nightPublic = load_pub_key('night');
|
||||||
const lightPrivate = await load_priv_key('light');
|
const lightPrivate = await load_priv_key('light');
|
||||||
const randomdata = input.createSomeMessage();
|
const randomData = input.createSomeMessage();
|
||||||
const encrypted = await openpgp.encrypt({ publicKeys: [nightPublic], privateKeys: [lightPrivate], data: randomdata });
|
const encrypted = await openpgp.encrypt({ publicKeys: [nightPublic], privateKeys: [lightPrivate], data: randomData });
|
||||||
|
|
||||||
const message = openpgp.message.readArmored(encrypted.data);
|
const message = openpgp.message.readArmored(encrypted.data);
|
||||||
const lightPublic = load_pub_key('light');
|
const lightPublic = load_pub_key('light');
|
||||||
|
@ -208,7 +208,7 @@ describe('X25519 Cryptography', function () {
|
||||||
const result = await openpgp.decrypt({ privateKeys: nightPrivate, publicKeys: [lightPublic], message: message });
|
const result = await openpgp.decrypt({ privateKeys: nightPrivate, publicKeys: [lightPublic], message: message });
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(randomdata);
|
expect(result.data.trim()).to.equal(randomData);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user