Skip to content

Commit

Permalink
Drop AES_ECB
Browse files Browse the repository at this point in the history
No longer needed by OpenPGP.js, as AES_CBC can be used instead.
  • Loading branch information
larabr committed Feb 9, 2024
1 parent 26ab9e1 commit c0a71ad
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 104 deletions.
31 changes: 0 additions & 31 deletions src/aes/ecb.ts

This file was deleted.

74 changes: 1 addition & 73 deletions test/aes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AES_ECB } from '@openpgp/asmcrypto.js/aes/ecb.js';
import { AES_CBC } from '@openpgp/asmcrypto.js/aes/cbc.js';
import { AES_CFB } from '@openpgp/asmcrypto.js/aes/cfb.js';
import { AES_GCM } from '@openpgp/asmcrypto.js/aes/gcm.js';
Expand All @@ -12,77 +11,6 @@ function base64_to_bytes(str) {
}

describe('AES', () => {
describe('ECB', () => {
const ecb_aes_vectors = [
// AES-ECB-128
[
'2b7e151628aed2a6abf7158809cf4f3c', // key
'6bc1bee22e409f96e93d7e117393172a', // clear text
'3ad77bb40d7a3660a89ecaf32466ef97', // cipher text
],
[
'2b7e151628aed2a6abf7158809cf4f3c', // key
'ae2d8a571e03ac9c9eb76fac45af8e51', // clear text
'f5d3d58503b9699de785895a96fdbaaf', // cipher text
],
[
'2b7e151628aed2a6abf7158809cf4f3c', // key
'30c81c46a35ce411e5fbc1191a0a52ef', // clear text
'43b1cd7f598ece23881b00e3ed030688', // cipher text
],
[
'2b7e151628aed2a6abf7158809cf4f3c', // key
'f69f2445df4f9b17ad2b417be66c3710', // clear text
'7b0c785e27e8ad3f8223207104725dd4', // cipher text
],
[
// Two blocks
'2b7e151628aed2a6abf7158809cf4f3c', // key
'f69f2445df4f9b17ad2b417be66c3710f69f2445df4f9b17ad2b417be66c3710', // clear text
'7b0c785e27e8ad3f8223207104725dd47b0c785e27e8ad3f8223207104725dd4', // cipher text
],
// AES-ECB-256
[
'603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4', // key
'6bc1bee22e409f96e93d7e117393172a', // clear text
'f3eed1bdb5d2a03c064b5a7e3db181f8', // cipher text
],
[
'603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4', // key
'ae2d8a571e03ac9c9eb76fac45af8e51', // clear text
'591ccb10d410ed26dc5ba74a31362870', // cipher text
],
[
'603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4', // key
'30c81c46a35ce411e5fbc1191a0a52ef', // clear text
'b6ed21b99ca6f4f9f153e7b1beafed1d', // cipher text
],
[
// Two blocks
'603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4', // key
'30c81c46a35ce411e5fbc1191a0a52ef30c81c46a35ce411e5fbc1191a0a52ef', // clear text
'b6ed21b99ca6f4f9f153e7b1beafed1db6ed21b99ca6f4f9f153e7b1beafed1d', // cipher text
],
[
'603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4', // key
'f69f2445df4f9b17ad2b417be66c3710', // clear text
'23304b7a39f9f3ff067d8d8f9e24ecc7', // cipher text
],
];

it('AES_ECB.encrypt / AES_ECB.decrypt', function () {
for (let i = 0; i < ecb_aes_vectors.length; ++i) {
const key = new Uint8Array(utils.hex_to_bytes(ecb_aes_vectors[i][0]));
const clear = new Uint8Array(utils.hex_to_bytes(ecb_aes_vectors[i][1]));
const cipher = new Uint8Array(utils.hex_to_bytes(ecb_aes_vectors[i][2]));

expect(AES_ECB.encrypt(clear, key), `encrypt vector ${i}`).to.deep.equal(cipher);

expect(AES_ECB.decrypt(cipher, key), `decrypt vector ${i}`).to.deep.equal(clear);
}
});
});

describe('CBC', () => {
const cbc_aes_vectors = [
[ // key
Expand Down Expand Up @@ -375,7 +303,7 @@ describe('AES', () => {
],
];

it("AES_GCM.encrypt", function () {
it("AES_GCM.encrypt / AES_GCM.decrypt", function () {
for (let i = 0; i < gcm_aes_vectors.length; ++i) {
const key = gcm_aes_vectors[i][0];
const nonce = gcm_aes_vectors[i][1];
Expand Down

0 comments on commit c0a71ad

Please sign in to comment.