mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-19 22:58:38 +00:00
Update to Mocha v10 in tests, declare lib as module and add exports to package.json
Mocha v10 requires the lib to be esm compliant. ESM mandates the use of file extensions in imports, so to minimize the changes (for now), we rely on the flag `experimental-specifier-resolution=node` and on `ts-node` (needed only for Node 20). Breaking changes: downstream bundlers might be affected by the package.json changes depending on how they load the library. NB: legacy package.json entrypoints are still available.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
const { expect } = require('chai');
|
||||
import { expect } from 'chai';
|
||||
|
||||
const { aes128: AES128 } = require('../../../src/crypto/cipher');
|
||||
import { aes128 as AES128 } from '../../../src/crypto/cipher';
|
||||
|
||||
module.exports = () => describe('AES Rijndael cipher test with test vectors from ecb_tbl.txt', function() {
|
||||
export default () => describe('AES Rijndael cipher test with test vectors from ecb_tbl.txt', function() {
|
||||
function test_aes(input, key, output) {
|
||||
const aes = new AES128(new Uint8Array(key));
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const { expect } = require('chai');
|
||||
import { expect } from 'chai';
|
||||
|
||||
const BF = require('../../../src/crypto/cipher/blowfish');
|
||||
const util = require('../../../src/util');
|
||||
import BF from '../../../src/crypto/cipher/blowfish';
|
||||
import util from '../../../src/util.js';
|
||||
|
||||
module.exports = () => it('Blowfish cipher test with test vectors from https://www.schneier.com/code/vectors.txt', function(done) {
|
||||
export default () => it('Blowfish cipher test with test vectors from https://www.schneier.com/code/vectors.txt', function(done) {
|
||||
function test_bf(input, key, output) {
|
||||
const blowfish = new BF(util.uint8ArrayToString(key));
|
||||
const result = blowfish.encrypt(input);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const { expect } = require('chai');
|
||||
import { expect } from 'chai';
|
||||
|
||||
const CAST5 = require('../../../src/crypto/cipher/cast5');
|
||||
const util = require('../../../src/util');
|
||||
import CAST5 from '../../../src/crypto/cipher/cast5.js';
|
||||
import util from '../../../src/util.js';
|
||||
|
||||
module.exports = () => it('CAST-128 cipher test with test vectors from RFC2144', function (done) {
|
||||
export default () => it('CAST-128 cipher test with test vectors from RFC2144', function (done) {
|
||||
function test_cast(input, key, output) {
|
||||
const cast5 = new CAST5(key);
|
||||
const result = cast5.encrypt(input);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const { expect } = require('chai');
|
||||
import { expect } from 'chai';
|
||||
|
||||
const { DES, TripleDES } = require('../../../src/crypto/cipher/des');
|
||||
const util = require('../../../src/util');
|
||||
import { DES, TripleDES } from '../../../src/crypto/cipher/des.js';
|
||||
import util from '../../../src/util.js';
|
||||
|
||||
module.exports = () => describe('TripleDES (EDE) cipher test with test vectors from NIST SP 800-20', function() {
|
||||
export default () => describe('TripleDES (EDE) cipher test with test vectors from NIST SP 800-20', function() {
|
||||
// see https://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf
|
||||
const key = new Uint8Array([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]);
|
||||
const testvectors = [[[0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0x95,0xF8,0xA5,0xE5,0xDD,0x31,0xD9,0x00]],
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
module.exports = () => describe('Cipher', function () {
|
||||
require('./aes')();
|
||||
require('./blowfish')();
|
||||
require('./cast5')();
|
||||
require('./des')();
|
||||
require('./twofish')();
|
||||
import testAES from './aes';
|
||||
import testBlowfish from './blowfish';
|
||||
import testCAST5 from './cast5';
|
||||
import testDES from './des';
|
||||
import testTwofish from './twofish';
|
||||
|
||||
export default () => describe('Cipher', function () {
|
||||
testAES();
|
||||
testBlowfish();
|
||||
testCAST5();
|
||||
testDES();
|
||||
testTwofish();
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const { expect } = require('chai');
|
||||
import { expect } from 'chai';
|
||||
|
||||
const TF = require('../../../src/crypto/cipher/twofish');
|
||||
const util = require('../../../src/util');
|
||||
import TF from '../../../src/crypto/cipher/twofish.js';
|
||||
import util from '../../../src/util.js';
|
||||
|
||||
module.exports = () => it('Twofish with test vectors from https://www.schneier.com/code/ecb_ival.txt', function(done) {
|
||||
export default () => it('Twofish with test vectors from https://www.schneier.com/code/ecb_ival.txt', function(done) {
|
||||
function tfencrypt(block, key) {
|
||||
const tf = new TF(util.stringToUint8Array(key));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user