Skip native Crypto tests if native lib is not available
This commit is contained in:
parent
dcd28fadc6
commit
66844826c6
|
@ -125,6 +125,7 @@ function testAESEAX() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable no-invalid-this */
|
||||||
module.exports = () => describe('Symmetric AES-EAX', function() {
|
module.exports = () => describe('Symmetric AES-EAX', function() {
|
||||||
let sinonSandbox;
|
let sinonSandbox;
|
||||||
let getWebCryptoStub;
|
let getWebCryptoStub;
|
||||||
|
@ -142,6 +143,11 @@ module.exports = () => describe('Symmetric AES-EAX', function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Symmetric AES-EAX (native)', function() {
|
describe('Symmetric AES-EAX (native)', function() {
|
||||||
|
before(function () {
|
||||||
|
const detectNative = () => !!(util.getWebCrypto() || util.getNodeCrypto());
|
||||||
|
if (!detectNative()) { this.skip(); }
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
sinonSandbox = sandbox.create();
|
sinonSandbox = sandbox.create();
|
||||||
enableNative();
|
enableNative();
|
||||||
|
|
|
@ -25,6 +25,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
|
||||||
sinonSandbox.restore();
|
sinonSandbox.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const detectNative = () => !!(util.getWebCrypto() || util.getNodeCrypto());
|
||||||
|
|
||||||
const disableNative = () => {
|
const disableNative = () => {
|
||||||
enableNative();
|
enableNative();
|
||||||
// stubbed functions return undefined
|
// stubbed functions return undefined
|
||||||
|
@ -105,6 +107,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('compare native crypto and bnSign', async function() {
|
it('compare native crypto and bnSign', async function() {
|
||||||
|
if (!detectNative()) { this.skip(); }
|
||||||
|
|
||||||
const bits = 1024;
|
const bits = 1024;
|
||||||
const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits);
|
const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits);
|
||||||
const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };
|
const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };
|
||||||
|
@ -120,6 +124,8 @@ module.exports = () => describe('basic RSA cryptography', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('compare native crypto and bnVerify', async function() {
|
it('compare native crypto and bnVerify', async function() {
|
||||||
|
if (!detectNative()) { this.skip(); }
|
||||||
|
|
||||||
const bits = 1024;
|
const bits = 1024;
|
||||||
const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits);
|
const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits);
|
||||||
const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };
|
const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user