diff --git a/src/webcrypto/aes.ts b/src/webcrypto/aes.ts index c0a13f1..cfbf13f 100644 --- a/src/webcrypto/aes.ts +++ b/src/webcrypto/aes.ts @@ -1,25 +1,51 @@ import { ensureBytes } from '../utils.js'; import { getWebcryptoSubtle } from './utils.js'; -function generate(algo: string, length: number) { +/** + * AAD is only effective on AES-256-GCM or AES-128-GCM. Otherwise it'll be ignored + */ +export type Cipher = ( + key: Uint8Array, + nonce: Uint8Array, + AAD?: Uint8Array +) => { + keyLength: number; + encrypt(plaintext: Uint8Array): Promise; + decrypt(ciphertext: Uint8Array): Promise; +}; + +type Algo = 'AES-CTR' | 'AES-GCM' | 'AES-CBC'; +type BitLength = 128 | 256; + +function getCryptParams( + algo: Algo, + nonce: Uint8Array, + AAD?: Uint8Array +): AesCbcParams | AesCtrParams | AesGcmParams { + const params = { name: algo }; + if (algo === 'AES-CTR') { + return { ...params, counter: nonce, length: 64 } as AesCtrParams; + } else if (algo === 'AES-GCM') { + return { ...params, iv: nonce, additionalData: AAD } as AesGcmParams; + } else if (algo === 'AES-CBC') { + return { ...params, iv: nonce } as AesCbcParams; + } else { + throw new Error('unknown aes cipher'); + } +} + +function generate(algo: Algo, length: BitLength): Cipher { const keyLength = length / 8; const keyParams = { name: algo, length }; - const cryptParams: Record = { name: algo }; - // const params: Record = ({ e: algo, i: { name: algo, length } }); - return (key: Uint8Array, nonce: Uint8Array) => { + return (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => { ensureBytes(key, keyLength); - if (algo === 'AES-CTR') { - cryptParams.counter = nonce; - cryptParams.length = 64; - } else { - cryptParams.iv = nonce; - } + const cryptParams = getCryptParams(algo, nonce, AAD); return { keyLength, - async encrypt(plaintext: Uint8Array): Promise { + async encrypt(plaintext: Uint8Array) { ensureBytes(plaintext); const cr = getWebcryptoSubtle(); const iKey = await cr.importKey('raw', key, keyParams, true, ['encrypt']); @@ -27,7 +53,7 @@ function generate(algo: string, length: number) { return new Uint8Array(cipher); }, - async decrypt(ciphertext: Uint8Array): Promise { + async decrypt(ciphertext: Uint8Array) { ensureBytes(ciphertext); const cr = getWebcryptoSubtle(); const iKey = await cr.importKey('raw', key, keyParams, true, ['decrypt']); diff --git a/test/gcm-siv.test.js b/test/gcm-siv.test.js new file mode 100644 index 0000000..ea39b95 --- /dev/null +++ b/test/gcm-siv.test.js @@ -0,0 +1,74 @@ +const { deepStrictEqual, rejects } = require('assert'); +const { should, describe } = require('micro-should'); +const { hex } = require('@scure/base'); +const utils = require('../utils.js'); +const siv = require('../webcrypto/siv.js'); +const { polyval } = require('../_polyval.js'); + +// https://datatracker.ietf.org/doc/html/rfc8452#appendix-C +const VECTORS = require('./vectors/siv.json'); +const aes_gcm_siv_test = require('./wycheproof/aes_gcm_siv_test.json'); + +describe('AES-GCM-SIV', () => { + should('Polyval', () => { + const h = polyval( + hex.decode('25629347589242761d31f826ba4b757b'), + hex.decode('4f4f95668c83dfb6401762bb2d01a262d1a24ddd2721d006bbe45f20d3c9f362') + ); + deepStrictEqual(hex.encode(h), 'f7a3b47b846119fae5b7866cf5e5b77e'); + }); + for (const flavor of ['aes128', 'aes256', 'counterWrap']) { + for (let i = 0; i < VECTORS[flavor].length; i++) { + const v = VECTORS[flavor][i]; + should(`${flavor}(${i}): init`, async () => { + const { encKey, authKey } = await siv.deriveKeys(hex.decode(v.key), hex.decode(v.nonce)); + deepStrictEqual(encKey, hex.decode(v.encKey)); + deepStrictEqual(authKey, hex.decode(v.authKey)); + }); + should(`${flavor}(${i}): polyval`, async () => { + deepStrictEqual( + polyval(hex.decode(v.authKey), hex.decode(v.polyvalInput)), + hex.decode(v.polyvalResult) + ); + }); + should(`${flavor}(${i}).encrypt`, async () => { + let a = await siv.aes_256_gcm_siv( + hex.decode(v.key), + hex.decode(v.nonce), + hex.decode(v.AAD) + ); + deepStrictEqual(await a.encrypt(hex.decode(v.plaintext)), hex.decode(v.result)); + }); + should(`${flavor}(${i}).decrypt`, async () => { + let a = await siv.aes_256_gcm_siv( + hex.decode(v.key), + hex.decode(v.nonce), + hex.decode(v.AAD) + ); + deepStrictEqual(await a.decrypt(hex.decode(v.result)), hex.decode(v.plaintext)); + }); + } + } +}); + +describe('Wycheproof', () => { + for (const g of aes_gcm_siv_test.testGroups) { + const name = `Wycheproof/${g.ivSize}/${g.keySize}/${g.tagSize}/${g.type}`; + for (let i = 0; i < g.tests.length; i++) { + const t = g.tests[i]; + should(`${name}: ${i}`, async () => { + const a = await siv.aes_256_gcm_siv(hex.decode(t.key), hex.decode(t.iv), hex.decode(t.aad)); + const ct = utils.concatBytes(hex.decode(t.ct), hex.decode(t.tag)); + const msg = hex.decode(t.msg); + if (t.result === 'valid') { + deepStrictEqual(await a.decrypt(ct), msg); + deepStrictEqual(await a.encrypt(msg), ct); + } else { + await rejects(async () => await a.decrypt(ct)); + } + }); + } + } +}); + +if (require.main === module) should.run(); diff --git a/test/gcm.test.js b/test/gcm.test.js index 6f879b2..0943570 100644 --- a/test/gcm.test.js +++ b/test/gcm.test.js @@ -1,937 +1,67 @@ const { deepStrictEqual, rejects } = require('assert'); const { should, describe } = require('micro-should'); const utils = require('../utils.js'); -const { aes_256_gcm } = require('../webcrypto/aes.js'); -const siv = require('../webcrypto/siv.js'); +const { aes_256_gcm, aes_128_gcm } = require('../webcrypto/aes.js'); const { randomBytes } = require('../webcrypto/utils.js'); -const { hex } = require('@scure/base'); -const aes_gcm_siv_test = require('./wycheproof/aes_gcm_siv_test.json'); const aes_gcm_test = require('./wycheproof/aes_gcm_test.json'); -const { polyval } = require('../_polyval.js'); describe('AES-GCM', () => { - should('should encrypt and decrypt', async () => { - const key = Uint8Array.from([ + should('encrypt and decrypt', async () => { + const plaintext = utils.utf8ToBytes('Hello world'); + const knownKey = Uint8Array.from([ 64, 196, 127, 247, 172, 2, 34, 159, 6, 241, 30, 174, 183, 229, 41, 114, 253, 122, 119, 168, 177, 243, 155, 236, 164, 159, 98, 72, 162, 243, 224, 195, ]); - const plaintext = 'Hello world'; - const gcm = aes_256_gcm(key, randomBytes(12)); - const ciphertext = await gcm.encrypt(utils.utf8ToBytes(plaintext)); - const plaintext2 = await gcm.decrypt(ciphertext); - deepStrictEqual(utils.bytesToUtf8(plaintext2), plaintext); + const settings = [ + [aes_256_gcm, knownKey], + [aes_128_gcm, randomBytes(16)], + ]; + const aads = [randomBytes(16), new Uint8Array(), utils.utf8ToBytes('data'), undefined]; + for (const [cipher, key] of settings) { + for (const aad of aads) { + const gcm = cipher(key, randomBytes(12), aad); + const ciphertext = await gcm.encrypt(plaintext); + const plaintext2 = await gcm.decrypt(ciphertext); + deepStrictEqual(plaintext2, plaintext); + } + } }); - // describe('Wycheproof', () => { - // for (const g of aes_gcm_test.testGroups) { - // if (g.keySize !== 256) continue; - // const name = `Wycheproof/${g.ivSize}/${g.keySize}/${g.tagSize}/${g.type}`; - // for (let i = 0; i < g.tests.length; i++) { - // const t = g.tests[i]; - // should(`${name}: ${i}`, async () => { - // const key = hex.decode(t.key); - // const ct = t.ct + t.tag; - // const iv = hex.decode(t.iv); - // const msg = hex.decode(t.msg); - // if (t.result === 'valid') { - // console.log('TTT', t); - // deepStrictEqual(hex.encode(await gcm.encrypt(key, msg, iv)), ct); - // // deepStrictEqual(await gcm.decrypt(key, ct), msg); - // // deepStrictEqual(await a.encrypt(msg, AAD), ct); - // } else { - // //await rejects(async () => await a.decrypt(ct, AAD)); - // } - // }); - // } - // } - // }); }); -// https://datatracker.ietf.org/doc/html/rfc8452#appendix-C -const VECTORS = {}; -VECTORS.aes128 = [ - { - plaintext: '', - AAD: '', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: '00000000000000000000000000000000', - polyvalResult: '00000000000000000000000000000000', - polyvalResultXOR: '03000000000000000000000000000000', - polyvalResultMasked: '03000000000000000000000000000000', - tag: 'dc20e2d83f25705bb49e439eca56de25', - counter: 'dc20e2d83f25705bb49e439eca56dea5', - result: 'dc20e2d83f25705bb49e439eca56de25', - }, - { - plaintext: '0100000000000000', - AAD: '', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: '0100000000000000000000000000000000000000000000004000000000000000', - polyvalResult: 'eb93b7740962c5e49d2a90a7dc5cec74', - polyvalResultXOR: 'e893b7740962c5e49d2a90a7dc5cec74', - polyvalResultMasked: 'e893b7740962c5e49d2a90a7dc5cec74', - tag: '578782fff6013b815b287c22493a364c', - counter: '578782fff6013b815b287c22493a36cc', - result: 'b5d839330ac7b786578782fff6013b815b287c22493a364c', - }, - { - plaintext: '010000000000000000000000', - AAD: '', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: '0100000000000000000000000000000000000000000000006000000000000000', - polyvalResult: '48eb6c6c5a2dbe4a1dde508fee06361b', - polyvalResultXOR: '4beb6c6c5a2dbe4a1dde508fee06361b', - polyvalResultMasked: '4beb6c6c5a2dbe4a1dde508fee06361b', - tag: 'a4978db357391a0bc4fdec8b0d106639', - counter: 'a4978db357391a0bc4fdec8b0d1066b9', - result: '7323ea61d05932260047d942a4978db357391a0bc4fdec8b0d106639', - }, - { - plaintext: '01000000000000000000000000000000', - AAD: '', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: '0100000000000000000000000000000000000000000000008000000000000000', - polyvalResult: '20806c26e3c1de019e111255708031d6', - polyvalResultXOR: '23806c26e3c1de019e111255708031d6', - polyvalResultMasked: '23806c26e3c1de019e11125570803156', - tag: '303aaf90f6fe21199c6068577437a0c4', - counter: '303aaf90f6fe21199c6068577437a0c4', - result: '743f7c8077ab25f8624e2e948579cf77303aaf90f6fe21199c6068577437a0c4', - }, - { - plaintext: '0100000000000000000000000000000002000000000000000000000000000000', - AAD: '', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000000000000000000000001000000000000', - polyvalResult: 'ce6edc9a50b36d9a98986bbf6a261c3b', - polyvalResultXOR: 'cd6edc9a50b36d9a98986bbf6a261c3b', - polyvalResultMasked: 'cd6edc9a50b36d9a98986bbf6a261c3b', - tag: '1a8e45dcd4578c667cd86847bf6155ff', - counter: '1a8e45dcd4578c667cd86847bf6155ff', - result: - '84e07e62ba83a6585417245d7ec413a9fe427d6315c09b57ce45f2e3936a94451a8e45dcd4578c667cd86847bf6155ff', - }, - { - plaintext: - '010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000', - AAD: '', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000000000000000000008001000000000000', - polyvalResult: '81388746bc22d26b2abc3dcb15754222', - polyvalResultXOR: '82388746bc22d26b2abc3dcb15754222', - polyvalResultMasked: '82388746bc22d26b2abc3dcb15754222', - tag: '5e6e311dbf395d35b0fe39c2714388f8', - counter: '5e6e311dbf395d35b0fe39c2714388f8', - result: - '3fd24ce1f5a67b75bf2351f181a475c7b800a5b4d3dcf70106b1eea82fa1d64df42bf7226122fa92e17a40eeaac1201b5e6e311dbf395d35b0fe39c2714388f8', - }, - { - plaintext: - '01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000', - AAD: '', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '0100000000000000000000000000000002000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000000000000000000000002000000000000', - polyvalResult: '1e39b6d3344d348f6044f89935d1cf78', - polyvalResultXOR: '1d39b6d3344d348f6044f89935d1cf78', - polyvalResultMasked: '1d39b6d3344d348f6044f89935d1cf78', - tag: '8a263dd317aa88d56bdf3936dba75bb8', - counter: '8a263dd317aa88d56bdf3936dba75bb8', - result: - '2433668f1058190f6d43e360f4f35cd8e475127cfca7028ea8ab5c20f7ab2af02516a2bdcbc08d521be37ff28c152bba36697f25b4cd169c6590d1dd39566d3f8a263dd317aa88d56bdf3936dba75bb8', - }, - { - plaintext: '0200000000000000', - AAD: '01', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000008000000000000004000000000000000', - polyvalResult: 'b26781e7e2c1376f96bec195f3709b2a', - polyvalResultXOR: 'b16781e7e2c1376f96bec195f3709b2a', - polyvalResultMasked: 'b16781e7e2c1376f96bec195f3709b2a', - tag: '3b0a1a2560969cdf790d99759abd1508', - counter: '3b0a1a2560969cdf790d99759abd1588', - result: '1e6daba35669f4273b0a1a2560969cdf790d99759abd1508', - }, - { - plaintext: '020000000000000000000000', - AAD: '01', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000008000000000000006000000000000000', - polyvalResult: '111f5affb18e4cc1164a01bdc12a4145', - polyvalResultXOR: '121f5affb18e4cc1164a01bdc12a4145', - polyvalResultMasked: '121f5affb18e4cc1164a01bdc12a4145', - tag: '08299c5102745aaa3a0c469fad9e075a', - counter: '08299c5102745aaa3a0c469fad9e07da', - result: '296c7889fd99f41917f4462008299c5102745aaa3a0c469fad9e075a', - }, - { - plaintext: '02000000000000000000000000000000', - AAD: '01', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000008000000000000008000000000000000', - polyvalResult: '79745ab508622c8a958543675fac4688', - polyvalResultXOR: '7a745ab508622c8a958543675fac4688', - polyvalResultMasked: '7a745ab508622c8a958543675fac4608', - tag: '8f8936ec039e4e4bb97ebd8c4457441f', - counter: '8f8936ec039e4e4bb97ebd8c4457449f', - result: 'e2b0c5da79a901c1745f700525cb335b8f8936ec039e4e4bb97ebd8c4457441f', - }, - { - plaintext: '0200000000000000000000000000000003000000000000000000000000000000', - AAD: '01', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000008000000000000000001000000000000', - polyvalResult: '2ce7daaf7c89490822051255b12eca6b', - polyvalResultXOR: '2fe7daaf7c89490822051255b12eca6b', - polyvalResultMasked: '2fe7daaf7c89490822051255b12eca6b', - tag: 'e6af6a7f87287da059a71684ed3498e1', - counter: 'e6af6a7f87287da059a71684ed3498e1', - result: - '620048ef3c1e73e57e02bb8562c416a319e73e4caac8e96a1ecb2933145a1d71e6af6a7f87287da059a71684ed3498e1', - }, - { - plaintext: - '020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000', - AAD: '01', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '0100000000000000000000000000000002000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000008000000000000008001000000000000', - polyvalResult: '9ca987715d69c1786711dfcd22f830fc', - polyvalResultXOR: '9fa987715d69c1786711dfcd22f830fc', - polyvalResultMasked: '9fa987715d69c1786711dfcd22f8307c', - tag: '6a8cc3865f76897c2e4b245cf31c51f2', - counter: '6a8cc3865f76897c2e4b245cf31c51f2', - result: - '50c8303ea93925d64090d07bd109dfd9515a5a33431019c17d93465999a8b0053201d723120a8562b838cdff25bf9d1e6a8cc3865f76897c2e4b245cf31c51f2', - }, - { - plaintext: - '02000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000005000000000000000000000000000000', - AAD: '01', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000040000000000000000000000000000000500000000000000000000000000000008000000000000000002000000000000', - polyvalResult: 'ffcd05d5770f34ad9267f0a59994b15a', - polyvalResultXOR: 'fccd05d5770f34ad9267f0a59994b15a', - polyvalResultMasked: 'fccd05d5770f34ad9267f0a59994b15a', - tag: 'cdc46ae475563de037001ef84ae21744', - counter: 'cdc46ae475563de037001ef84ae217c4', - result: - '2f5c64059db55ee0fb847ed513003746aca4e61c711b5de2e7a77ffd02da42feec601910d3467bb8b36ebbaebce5fba30d36c95f48a3e7980f0e7ac299332a80cdc46ae475563de037001ef84ae21744', - }, - { - plaintext: '02000000', - AAD: '010000000000000000000000', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000060000000000000002000000000000000', - polyvalResult: 'f6ce9d3dcd68a2fd603c7ecc18fb9918', - polyvalResultXOR: 'f5ce9d3dcd68a2fd603c7ecc18fb9918', - polyvalResultMasked: 'f5ce9d3dcd68a2fd603c7ecc18fb9918', - tag: '07eb1f84fb28f8cb73de8e99e2f48a14', - counter: '07eb1f84fb28f8cb73de8e99e2f48a94', - result: 'a8fe3e8707eb1f84fb28f8cb73de8e99e2f48a14', - }, - { - plaintext: '0300000000000000000000000000000004000000', - AAD: '010000000000000000000000000000000200', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000040000000000000000000000000000009000000000000000a000000000000000', - polyvalResult: '4781d492cb8f926c504caa36f61008fe', - polyvalResultXOR: '4481d492cb8f926c504caa36f61008fe', - polyvalResultMasked: '4481d492cb8f926c504caa36f610087e', - tag: '24afc9805e976f451e6d87f6fe106514', - counter: '24afc9805e976f451e6d87f6fe106594', - result: '6bb0fecf5ded9b77f902c7d5da236a4391dd029724afc9805e976f451e6d87f6fe106514', - }, - { - plaintext: '030000000000000000000000000000000400', - AAD: '0100000000000000000000000000000002000000', - key: '01000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'd9b360279694941ac5dbc6987ada7377', - encKey: '4004a0dcd862f2a57360219d2d44ef6c', - polyvalInput: - '01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000a0000000000000009000000000000000', - polyvalResult: '75cbc23a1a10e348aeb8e384b5cc79fd', - polyvalResultXOR: '76cbc23a1a10e348aeb8e384b5cc79fd', - polyvalResultMasked: '76cbc23a1a10e348aeb8e384b5cc797d', - tag: 'bff9b2ef00fb47920cc72a0c0f13b9fd', - counter: 'bff9b2ef00fb47920cc72a0c0f13b9fd', - result: '44d0aaf6fb2f1f34add5e8064e83e12a2adabff9b2ef00fb47920cc72a0c0f13b9fd', - }, - { - plaintext: '', - AAD: '', - key: 'e66021d5eb8e4f4066d4adb9c33560e4', - nonce: 'f46e44bb3da0015c94f70887', - authKey: '036ee1fe2d7926af68898095e54e7b3c', - encKey: '5e46482396008223b5c1d25173d87539', - polyvalInput: '00000000000000000000000000000000', - polyvalResult: '00000000000000000000000000000000', - polyvalResultXOR: 'f46e44bb3da0015c94f7088700000000', - polyvalResultMasked: 'f46e44bb3da0015c94f7088700000000', - tag: 'a4194b79071b01a87d65f706e3949578', - counter: 'a4194b79071b01a87d65f706e39495f8', - result: 'a4194b79071b01a87d65f706e3949578', - }, - { - plaintext: '7a806c', - AAD: '46bb91c3c5', - key: '36864200e0eaf5284d884a0e77d31646', - nonce: 'bae8e37fc83441b16034566b', - authKey: '3e28de1120b2981a0155795ca2812af6', - encKey: '6d4b78b31a4c9c03d8db0f42f7507fae', - polyvalInput: - '46bb91c3c500000000000000000000007a806c0000000000000000000000000028000000000000001800000000000000', - polyvalResult: '43d9a745511dcfa21b96dd606f1d5720', - polyvalResultXOR: 'f931443a99298e137ba28b0b6f1d5720', - polyvalResultMasked: 'f931443a99298e137ba28b0b6f1d5720', - tag: '711bd85bc1e4d3e0a462e074eea428a8', - counter: '711bd85bc1e4d3e0a462e074eea428a8', - result: 'af60eb711bd85bc1e4d3e0a462e074eea428a8', - }, - { - plaintext: 'bdc66f146545', - AAD: 'fc880c94a95198874296', - key: 'aedb64a6c590bc84d1a5e269e4b47801', - nonce: 'afc0577e34699b9e671fdd4f', - authKey: '43b8de9cea62330d15cccfc84a33e8c8', - encKey: '8e54631607e431e095b54852868e3a27', - polyvalInput: - 'fc880c94a95198874296000000000000bdc66f1465450000000000000000000050000000000000003000000000000000', - polyvalResult: '26498e0d2b1ef004e808c458e8f2f515', - polyvalResultXOR: '8989d9731f776b9a8f171917e8f2f515', - polyvalResultMasked: '8989d9731f776b9a8f171917e8f2f515', - tag: 'd6a9c45545cfc11f03ad743dba20f966', - counter: 'd6a9c45545cfc11f03ad743dba20f9e6', - result: 'bb93a3e34d3cd6a9c45545cfc11f03ad743dba20f966', - }, - { - plaintext: '1177441f195495860f', - AAD: '046787f3ea22c127aaf195d1894728', - key: 'd5cc1fd161320b6920ce07787f86743b', - nonce: '275d1ab32f6d1f0434d8848c', - authKey: '8a51df64d93eaf667c2c09bd454ce5c5', - encKey: '43ab276c2b4a473918ca73f2dd85109c', - polyvalInput: - '046787f3ea22c127aaf195d1894728001177441f195495860f0000000000000078000000000000004800000000000000', - polyvalResult: '63a3451c0b23345ad02bba59956517cf', - polyvalResultXOR: '44fe5faf244e2b5ee4f33ed5956517cf', - polyvalResultMasked: '44fe5faf244e2b5ee4f33ed59565174f', - tag: '1d02fd0cd174c84fc5dae2f60f52fd2b', - counter: '1d02fd0cd174c84fc5dae2f60f52fdab', - result: '4f37281f7ad12949d01d02fd0cd174c84fc5dae2f60f52fd2b', - }, - { - plaintext: '9f572c614b4745914474e7c7', - AAD: 'c9882e5386fd9f92ec489c8fde2be2cf97e74e93', - key: 'b3fed1473c528b8426a582995929a149', - nonce: '9e9ad8780c8d63d0ab4149c0', - authKey: '22f50707a95dd416df069d670cb775e8', - encKey: 'f674a5584ee21fe97b4cebc468ab61e4', - polyvalInput: - 'c9882e5386fd9f92ec489c8fde2be2cf97e74e930000000000000000000000009f572c614b4745914474e7c700000000a0000000000000006000000000000000', - polyvalResult: '0cca0423fba9d77fe7e2e6963b08cdd0', - polyvalResultXOR: '9250dc5bf724b4af4ca3af563b08cdd0', - polyvalResultMasked: '9250dc5bf724b4af4ca3af563b08cd50', - tag: 'c1dc2f871fb7561da1286e655e24b7b0', - counter: 'c1dc2f871fb7561da1286e655e24b7b0', - result: 'f54673c5ddf710c745641c8bc1dc2f871fb7561da1286e655e24b7b0', - }, - { - plaintext: '0d8c8451178082355c9e940fea2f58', - AAD: '2950a70d5a1db2316fd568378da107b52b0da55210cc1c1b0a', - key: '2d4ed87da44102952ef94b02b805249b', - nonce: 'ac80e6f61455bfac8308a2d4', - authKey: '0b00a29a83e7e95b92e3a0783b29f140', - encKey: 'a430c27f285aed913005975c42eed5f3', - polyvalInput: - '2950a70d5a1db2316fd568378da107b52b0da55210cc1c1b0a000000000000000d8c8451178082355c9e940fea2f5800c8000000000000007800000000000000', - polyvalResult: '1086ef25247aa41009bbc40871d9b350', - polyvalResultXOR: 'bc0609d3302f1bbc8ab366dc71d9b350', - polyvalResultMasked: 'bc0609d3302f1bbc8ab366dc71d9b350', - tag: '83b3449b9f39552de99dc214a1190b0b', - counter: '83b3449b9f39552de99dc214a1190b8b', - result: 'c9ff545e07b88a015f05b274540aa183b3449b9f39552de99dc214a1190b0b', - }, - { - plaintext: '6b3db4da3d57aa94842b9803a96e07fb6de7', - AAD: '1860f762ebfbd08284e421702de0de18baa9c9596291b08466f37de21c7f', - key: 'bde3b2f204d1e9f8b06bc47f9745b3d1', - nonce: 'ae06556fb6aa7890bebc18fe', - authKey: '21c874a8bad3603d1c3e8784df5b3f9f', - encKey: 'd1c16d72651c3df504eae27129d818e8', - polyvalInput: - '1860f762ebfbd08284e421702de0de18baa9c9596291b08466f37de21c7f00006b3db4da3d57aa94842b9803a96e07fb6de70000000000000000000000000000f0000000000000009000000000000000', - polyvalResult: '55462a5afa0da8d646481e049ef9c764', - polyvalResultXOR: 'fb407f354ca7d046f8f406fa9ef9c764', - polyvalResultMasked: 'fb407f354ca7d046f8f406fa9ef9c764', - tag: '3e377094f04709f64d7b985310a4db84', - counter: '3e377094f04709f64d7b985310a4db84', - result: '6298b296e24e8cc35dce0bed484b7f30d5803e377094f04709f64d7b985310a4db84', - }, - { - plaintext: 'e42a3c02c25b64869e146d7b233987bddfc240871d', - AAD: '7576f7028ec6eb5ea7e298342a94d4b202b370ef9768ec6561c4fe6b7e7296fa859c21', - key: 'f901cfe8a69615a93fdf7a98cad48179', - nonce: '6245709fb18853f68d833640', - authKey: '3724f55f1d22ac0ab830da0b6a995d74', - encKey: '75ac87b70c05db287de779006105a344', - polyvalInput: - '7576f7028ec6eb5ea7e298342a94d4b202b370ef9768ec6561c4fe6b7e7296fa859c2100000000000000000000000000e42a3c02c25b64869e146d7b233987bddfc240871d00000000000000000000001801000000000000a800000000000000', - polyvalResult: '4cbba090f03f7d1188ea55749fa6c7bd', - polyvalResultXOR: '2efed00f41b72ee7056963349fa6c7bd', - polyvalResultMasked: '2efed00f41b72ee7056963349fa6c73d', - tag: '2d15506c84a9edd65e13e9d24a2a6e70', - counter: '2d15506c84a9edd65e13e9d24a2a6ef0', - result: '391cc328d484a4f46406181bcd62efd9b3ee197d052d15506c84a9edd65e13e9d24a2a6e70', - }, -]; +describe('Wycheproof', () => { + for (const g of aes_gcm_test.testGroups) { + let cipher; + if (g.keySize === 256) { + cipher = aes_256_gcm; + } else if (g.keySize === 128) { + cipher = aes_128_gcm; + } else { + continue; + } -VECTORS.aes256 = [ - { - plaintext: '', - AAD: '', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: '00000000000000000000000000000000', - polyvalResult: '00000000000000000000000000000000', - polyvalResultXOR: '03000000000000000000000000000000', - polyvalResultMasked: '03000000000000000000000000000000', - tag: '07f5f4169bbf55a8400cd47ea6fd400f', - counter: '07f5f4169bbf55a8400cd47ea6fd408f', - result: '07f5f4169bbf55a8400cd47ea6fd400f', - }, - { - plaintext: '0100000000000000', - AAD: '', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: '0100000000000000000000000000000000000000000000004000000000000000', - polyvalResult: '05230f62f0eac8aa14fe4d646b59cd41', - polyvalResultXOR: '06230f62f0eac8aa14fe4d646b59cd41', - polyvalResultMasked: '06230f62f0eac8aa14fe4d646b59cd41', - tag: '843122130f7364b761e0b97427e3df28', - counter: '843122130f7364b761e0b97427e3dfa8', - result: 'c2ef328e5c71c83b843122130f7364b761e0b97427e3df28', - }, - { - plaintext: '010000000000000000000000', - AAD: '', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: '0100000000000000000000000000000000000000000000006000000000000000', - polyvalResult: '6d81a24732fd6d03ae5af544720a1c13', - polyvalResultXOR: '6e81a24732fd6d03ae5af544720a1c13', - polyvalResultMasked: '6e81a24732fd6d03ae5af544720a1c13', - tag: '8ca50da9ae6559e48fd10f6e5c9ca17e', - counter: '8ca50da9ae6559e48fd10f6e5c9ca1fe', - result: '9aab2aeb3faa0a34aea8e2b18ca50da9ae6559e48fd10f6e5c9ca17e', - }, - { - plaintext: '01000000000000000000000000000000', - AAD: '', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: '0100000000000000000000000000000000000000000000008000000000000000', - polyvalResult: '74eee2bf7c9a165f8b25dea73db32a6d', - polyvalResultXOR: '77eee2bf7c9a165f8b25dea73db32a6d', - polyvalResultMasked: '77eee2bf7c9a165f8b25dea73db32a6d', - tag: 'c9eac6fa700942702e90862383c6c366', - counter: 'c9eac6fa700942702e90862383c6c3e6', - result: '85a01b63025ba19b7fd3ddfc033b3e76c9eac6fa700942702e90862383c6c366', - }, - { - plaintext: '0100000000000000000000000000000002000000000000000000000000000000', - AAD: '', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000000000000000000000001000000000000', - polyvalResult: '899b6381b3d46f0def7aa0517ba188f5', - polyvalResultXOR: '8a9b6381b3d46f0def7aa0517ba188f5', - polyvalResultMasked: '8a9b6381b3d46f0def7aa0517ba18875', - tag: 'e819e63abcd020b006a976397632eb5d', - counter: 'e819e63abcd020b006a976397632ebdd', - result: - '4a6a9db4c8c6549201b9edb53006cba821ec9cf850948a7c86c68ac7539d027fe819e63abcd020b006a976397632eb5d', - }, - { - plaintext: - '010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000', - AAD: '', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000000000000000000008001000000000000', - polyvalResult: 'c1f8593d8fc29b0c290cae1992f71f51', - polyvalResultXOR: 'c2f8593d8fc29b0c290cae1992f71f51', - polyvalResultMasked: 'c2f8593d8fc29b0c290cae1992f71f51', - tag: '790bc96880a99ba804bd12c0e6a22cc4', - counter: '790bc96880a99ba804bd12c0e6a22cc4', - result: - 'c00d121893a9fa603f48ccc1ca3c57ce7499245ea0046db16c53c7c66fe717e39cf6c748837b61f6ee3adcee17534ed5790bc96880a99ba804bd12c0e6a22cc4', - }, - { - plaintext: - '01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000', - AAD: '', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '0100000000000000000000000000000002000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000000000000000000000002000000000000', - polyvalResult: '6ef38b06046c7c0e225efaef8e2ec4c4', - polyvalResultXOR: '6df38b06046c7c0e225efaef8e2ec4c4', - polyvalResultMasked: '6df38b06046c7c0e225efaef8e2ec444', - tag: '112864c269fc0d9d88c61fa47e39aa08', - counter: '112864c269fc0d9d88c61fa47e39aa88', - result: - 'c2d5160a1f8683834910acdafc41fbb1632d4a353e8b905ec9a5499ac34f96c7e1049eb080883891a4db8caaa1f99dd004d80487540735234e3744512c6f90ce112864c269fc0d9d88c61fa47e39aa08', - }, - { - plaintext: '0200000000000000', - AAD: '01', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000008000000000000004000000000000000', - polyvalResult: '34e57bafe011b9b36fc6821b7ffb3354', - polyvalResultXOR: '37e57bafe011b9b36fc6821b7ffb3354', - polyvalResultMasked: '37e57bafe011b9b36fc6821b7ffb3354', - tag: '91213f267e3b452f02d01ae33e4ec854', - counter: '91213f267e3b452f02d01ae33e4ec8d4', - result: '1de22967237a813291213f267e3b452f02d01ae33e4ec854', - }, - { - plaintext: '020000000000000000000000', - AAD: '01', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000008000000000000006000000000000000', - polyvalResult: '5c47d68a22061c1ad5623a3b66a8e206', - polyvalResultXOR: '5f47d68a22061c1ad5623a3b66a8e206', - polyvalResultMasked: '5f47d68a22061c1ad5623a3b66a8e206', - tag: 'c1a4a19ae800941ccdc57cc8413c277f', - counter: 'c1a4a19ae800941ccdc57cc8413c27ff', - result: '163d6f9cc1b346cd453a2e4cc1a4a19ae800941ccdc57cc8413c277f', - }, - { - plaintext: '02000000000000000000000000000000', - AAD: '01', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000008000000000000008000000000000000', - polyvalResult: '452896726c616746f01d11d82911d478', - polyvalResultXOR: '462896726c616746f01d11d82911d478', - polyvalResultMasked: '462896726c616746f01d11d82911d478', - tag: 'b292d28ff61189e8e49f3875ef91aff7', - counter: 'b292d28ff61189e8e49f3875ef91aff7', - result: 'c91545823cc24f17dbb0e9e807d5ec17b292d28ff61189e8e49f3875ef91aff7', - }, - { - plaintext: '0200000000000000000000000000000003000000000000000000000000000000', - AAD: '01', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000008000000000000000001000000000000', - polyvalResult: '4e58c1e341c9bb0ae34eda9509dfc90c', - polyvalResultXOR: '4d58c1e341c9bb0ae34eda9509dfc90c', - polyvalResultMasked: '4d58c1e341c9bb0ae34eda9509dfc90c', - tag: 'aea1bad12702e1965604374aab96dbbc', - counter: 'aea1bad12702e1965604374aab96dbbc', - result: - '07dad364bfc2b9da89116d7bef6daaaf6f255510aa654f920ac81b94e8bad365aea1bad12702e1965604374aab96dbbc', - }, - { - plaintext: - '020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000', - AAD: '01', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '0100000000000000000000000000000002000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000008000000000000008001000000000000', - polyvalResult: '2566a4aff9a525df9772c16d4eaf8d2a', - polyvalResultXOR: '2666a4aff9a525df9772c16d4eaf8d2a', - polyvalResultMasked: '2666a4aff9a525df9772c16d4eaf8d2a', - tag: '03332742b228c647173616cfd44c54eb', - counter: '03332742b228c647173616cfd44c54eb', - result: - 'c67a1f0f567a5198aa1fcc8e3f21314336f7f51ca8b1af61feac35a86416fa47fbca3b5f749cdf564527f2314f42fe2503332742b228c647173616cfd44c54eb', - }, - { - plaintext: - '02000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000005000000000000000000000000000000', - AAD: '01', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000040000000000000000000000000000000500000000000000000000000000000008000000000000000002000000000000', - polyvalResult: 'da58d2f61b0a9d343b2f37fb0c519733', - polyvalResultXOR: 'd958d2f61b0a9d343b2f37fb0c519733', - polyvalResultMasked: 'd958d2f61b0a9d343b2f37fb0c519733', - tag: '5bde0285037c5de81e5b570a049b62a0', - counter: '5bde0285037c5de81e5b570a049b62a0', - result: - '67fd45e126bfb9a79930c43aad2d36967d3f0e4d217c1e551f59727870beefc98cb933a8fce9de887b1e40799988db1fc3f91880ed405b2dd298318858467c895bde0285037c5de81e5b570a049b62a0', - }, - { - plaintext: '02000000', - AAD: '010000000000000000000000', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000060000000000000002000000000000000', - polyvalResult: '6dc76ae84b88916e073a303aafde05cf', - polyvalResultXOR: '6ec76ae84b88916e073a303aafde05cf', - polyvalResultMasked: '6ec76ae84b88916e073a303aafde054f', - tag: '1835e517741dfddccfa07fa4661b74cf', - counter: '1835e517741dfddccfa07fa4661b74cf', - result: '22b3f4cd1835e517741dfddccfa07fa4661b74cf', - }, - { - plaintext: '0300000000000000000000000000000004000000', - AAD: '010000000000000000000000000000000200', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000040000000000000000000000000000009000000000000000a000000000000000', - polyvalResult: '973ef4fd04bd31d193816ab26f8655ca', - polyvalResultXOR: '943ef4fd04bd31d193816ab26f8655ca', - polyvalResultMasked: '943ef4fd04bd31d193816ab26f86554a', - tag: 'b879ad976d8242acc188ab59cabfe307', - counter: 'b879ad976d8242acc188ab59cabfe387', - result: '43dd0163cdb48f9fe3212bf61b201976067f342bb879ad976d8242acc188ab59cabfe307', - }, - { - plaintext: '030000000000000000000000000000000400', - AAD: '0100000000000000000000000000000002000000', - key: '0100000000000000000000000000000000000000000000000000000000000000', - nonce: '030000000000000000000000', - authKey: 'b5d3c529dfafac43136d2d11be284d7f', - encKey: 'b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222', - polyvalInput: - '01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000a0000000000000009000000000000000', - polyvalResult: '2cbb6b7ab2dbffefb797f825f826870c', - polyvalResultXOR: '2fbb6b7ab2dbffefb797f825f826870c', - polyvalResultMasked: '2fbb6b7ab2dbffefb797f825f826870c', - tag: 'cfcdf5042112aa29685c912fc2056543', - counter: 'cfcdf5042112aa29685c912fc20565c3', - result: '462401724b5ce6588d5a54aae5375513a075cfcdf5042112aa29685c912fc2056543', - }, - { - plaintext: '', - AAD: '', - key: 'e66021d5eb8e4f4066d4adb9c33560e4f46e44bb3da0015c94f7088736864200', - nonce: 'e0eaf5284d884a0e77d31646', - authKey: 'e40d26f82774aa27f47b047b608b9585', - encKey: '7c7c3d9a542cef53dde0e6de9b5800400f82e73ec5f7ee41b7ba8dcb9ba078c3', - polyvalInput: '00000000000000000000000000000000', - polyvalResult: '00000000000000000000000000000000', - polyvalResultXOR: 'e0eaf5284d884a0e77d3164600000000', - polyvalResultMasked: 'e0eaf5284d884a0e77d3164600000000', - tag: '169fbb2fbf389a995f6390af22228a62', - counter: '169fbb2fbf389a995f6390af22228ae2', - result: '169fbb2fbf389a995f6390af22228a62', - }, - { - plaintext: '671fdd', - AAD: '4fbdc66f14', - key: 'bae8e37fc83441b16034566b7a806c46bb91c3c5aedb64a6c590bc84d1a5e269', - nonce: 'e4b47801afc0577e34699b9e', - authKey: 'b546f5a850d0a90adfe39e95c2510fc6', - encKey: 'b9d1e239d62cbb5c49273ddac8838bdcc53bca478a770f07087caa4e0a924a55', - polyvalInput: - '4fbdc66f140000000000000000000000671fdd0000000000000000000000000028000000000000001800000000000000', - polyvalResult: 'b91f91f96b159a7c611c05035b839e92', - polyvalResultXOR: '5dabe9f8c4d5cd0255759e9d5b839e92', - polyvalResultMasked: '5dabe9f8c4d5cd0255759e9d5b839e12', - tag: '93da9bb81333aee0c785b240d319719d', - counter: '93da9bb81333aee0c785b240d319719d', - result: '0eaccb93da9bb81333aee0c785b240d319719d', - }, - { - plaintext: '195495860f04', - AAD: '6787f3ea22c127aaf195', - key: '6545fc880c94a95198874296d5cc1fd161320b6920ce07787f86743b275d1ab3', - nonce: '2f6d1f0434d8848c1177441f', - authKey: 'e156e1f9b0b07b780cbe30f259e3c8da', - encKey: '6fc1c494519f944aae52fcd8b14e5b171b5a9429d3b76e430d49940c0021d612', - polyvalInput: - '6787f3ea22c127aaf195000000000000195495860f040000000000000000000050000000000000003000000000000000', - polyvalResult: '2c480ed9d236b1df24c6eec109bd40c1', - polyvalResultXOR: '032511dde6ee355335b1aade09bd40c1', - polyvalResultMasked: '032511dde6ee355335b1aade09bd4041', - tag: '6b62b84dc40c84636a5ec12020ec8c2c', - counter: '6b62b84dc40c84636a5ec12020ec8cac', - result: 'a254dad4f3f96b62b84dc40c84636a5ec12020ec8c2c', - }, - { - plaintext: 'c9882e5386fd9f92ec', - AAD: '489c8fde2be2cf97e74e932d4ed87d', - key: 'd1894728b3fed1473c528b8426a582995929a1499e9ad8780c8d63d0ab4149c0', - nonce: '9f572c614b4745914474e7c7', - authKey: '0533fd71f4119257361a3ff1469dd4e5', - encKey: '4feba89799be8ac3684fa2bb30ade0ea51390e6d87dcf3627d2ee44493853abe', - polyvalInput: - '489c8fde2be2cf97e74e932d4ed87d00c9882e5386fd9f92ec0000000000000078000000000000004800000000000000', - polyvalResult: 'bf160bc9ded8c63057d2c38aae552fb4', - polyvalResultXOR: '204127a8959f83a113a6244dae552fb4', - polyvalResultMasked: '204127a8959f83a113a6244dae552f34', - tag: 'c0fd3dc6628dfe55ebb0b9fb2295c8c2', - counter: 'c0fd3dc6628dfe55ebb0b9fb2295c8c2', - result: '0df9e308678244c44bc0fd3dc6628dfe55ebb0b9fb2295c8c2', - }, - { - plaintext: '1db2316fd568378da107b52b', - AAD: '0da55210cc1c1b0abde3b2f204d1e9f8b06bc47f', - key: 'a44102952ef94b02b805249bac80e6f61455bfac8308a2d40d8c845117808235', - nonce: '5c9e940fea2f582950a70d5a', - authKey: '64779ab10ee8a280272f14cc8851b727', - encKey: '25f40fc63f49d3b9016a8eeeb75846e0d72ca36ddbd312b6f5ef38ad14bd2651', - polyvalInput: - '0da55210cc1c1b0abde3b2f204d1e9f8b06bc47f0000000000000000000000001db2316fd568378da107b52b00000000a0000000000000006000000000000000', - polyvalResult: 'cc86ee22c861e1fd474c84676b42739c', - polyvalResultXOR: '90187a2d224eb9d417eb893d6b42739c', - polyvalResultMasked: '90187a2d224eb9d417eb893d6b42731c', - tag: '404099c2587f64979f21826706d497d5', - counter: '404099c2587f64979f21826706d497d5', - result: '8dbeb9f7255bf5769dd56692404099c2587f64979f21826706d497d5', - }, - { - plaintext: '21702de0de18baa9c9596291b08466', - AAD: 'f37de21c7ff901cfe8a69615a93fdf7a98cad481796245709f', - key: '9745b3d1ae06556fb6aa7890bebc18fe6b3db4da3d57aa94842b9803a96e07fb', - nonce: '6de71860f762ebfbd08284e4', - authKey: '27c2959ed4daea3b1f52e849478de376', - encKey: '307a38a5a6cf231c0a9af3b527f23a62e9a6ff09aff8ae669f760153e864fc93', - polyvalInput: - 'f37de21c7ff901cfe8a69615a93fdf7a98cad481796245709f0000000000000021702de0de18baa9c9596291b0846600c8000000000000007800000000000000', - polyvalResult: 'c4fa5e5b713853703bcf8e6424505fa5', - polyvalResultXOR: 'a91d463b865ab88beb4d0a8024505fa5', - polyvalResultMasked: 'a91d463b865ab88beb4d0a8024505f25', - tag: 'b3080d28f6ebb5d3648ce97bd5ba67fd', - counter: 'b3080d28f6ebb5d3648ce97bd5ba67fd', - result: '793576dfa5c0f88729a7ed3c2f1bffb3080d28f6ebb5d3648ce97bd5ba67fd', - }, - { - plaintext: 'b202b370ef9768ec6561c4fe6b7e7296fa85', - AAD: '9c2159058b1f0fe91433a5bdc20e214eab7fecef4454a10ef0657df21ac7', - key: 'b18853f68d833640e42a3c02c25b64869e146d7b233987bddfc240871d7576f7', - nonce: '028ec6eb5ea7e298342a94d4', - authKey: '670b98154076ddb59b7a9137d0dcc0f0', - encKey: '78116d78507fbe69d4a820c350f55c7cb36c3c9287df0e9614b142b76a587c3f', - polyvalInput: - '9c2159058b1f0fe91433a5bdc20e214eab7fecef4454a10ef0657df21ac70000b202b370ef9768ec6561c4fe6b7e7296fa850000000000000000000000000000f0000000000000009000000000000000', - polyvalResult: '4e4108f09f41d797dc9256f8da8d58c7', - polyvalResultXOR: '4ccfce1bc1e6350fe8b8c22cda8d58c7', - polyvalResultMasked: '4ccfce1bc1e6350fe8b8c22cda8d5847', - tag: '454fc2a154fea91f8363a39fec7d0a49', - counter: '454fc2a154fea91f8363a39fec7d0ac9', - result: '857e16a64915a787637687db4a9519635cdd454fc2a154fea91f8363a39fec7d0a49', - }, - { - plaintext: 'ced532ce4159b035277d4dfbb7db62968b13cd4eec', - AAD: '734320ccc9d9bbbb19cb81b2af4ecbc3e72834321f7aa0f70b7282b4f33df23f167541', - key: '3c535de192eaed3822a2fbbe2ca9dfc88255e14a661b8aa82cc54236093bbc23', - nonce: '688089e55540db1872504e1c', - authKey: 'cb8c3aa3f8dbaeb4b28a3e86ff6625f8', - encKey: '02426ce1aa3ab31313b0848469a1b5fc6c9af9602600b195b04ad407026bc06d', - polyvalInput: - '734320ccc9d9bbbb19cb81b2af4ecbc3e72834321f7aa0f70b7282b4f33df23f16754100000000000000000000000000ced532ce4159b035277d4dfbb7db62968b13cd4eec00000000000000000000001801000000000000a800000000000000', - polyvalResult: 'ffd503c7dd712eb3791b7114b17bb0cf', - polyvalResultXOR: '97558a228831f5ab0b4b3f08b17bb0cf', - polyvalResultMasked: '97558a228831f5ab0b4b3f08b17bb04f', - tag: '9d6c7029675b89eaf4ba1ded1a286594', - counter: '9d6c7029675b89eaf4ba1ded1a286594', - result: '626660c26ea6612fb17ad91e8e767639edd6c9faee9d6c7029675b89eaf4ba1ded1a286594', - }, -]; + // invalid iv sizes for webcrypto + if ([8, 16, 32, 48, 64, 80, 2056].includes(g.ivSize)) continue; -VECTORS.counterWrap = [ - { - plaintext: '000000000000000000000000000000004db923dc793ee6497c76dcc03a98e108', - AAD: '', - key: '0000000000000000000000000000000000000000000000000000000000000000', - nonce: '000000000000000000000000', - authKey: 'dc95c078a24089895275f3d86b4fb868', - encKey: '779b38d15bffb63d39d6e9ae76a9b2f375d11b0e3a68c422845c7d4690fa594f', - polyvalInput: - '000000000000000000000000000000004db923dc793ee6497c76dcc03a98e10800000000000000000001000000000000', - polyvalResult: '7367cdb411b730128dd56e8edc0eff56', - polyvalResultXOR: '7367cdb411b730128dd56e8edc0eff56', - polyvalResultMasked: '7367cdb411b730128dd56e8edc0eff56', - tag: 'ffffffff000000000000000000000000', - counter: 'ffffffff000000000000000000000080', - result: - 'f3f80f2cf0cb2dd9c5984fcda908456cc537703b5ba70324a6793a7bf218d3eaffffffff000000000000000000000000', - }, - { - plaintext: 'eb3640277c7ffd1303c7a542d02d3e4c0000000000000000', - AAD: '', - key: '0000000000000000000000000000000000000000000000000000000000000000', - nonce: '000000000000000000000000', - authKey: 'dc95c078a24089895275f3d86b4fb868', - encKey: '779b38d15bffb63d39d6e9ae76a9b2f375d11b0e3a68c422845c7d4690fa594f', - polyvalInput: - 'eb3640277c7ffd1303c7a542d02d3e4c000000000000000000000000000000000000000000000000c000000000000000', - polyvalResult: '7367cdb411b730128dd56e8edc0eff56', - polyvalResultXOR: '7367cdb411b730128dd56e8edc0eff56', - polyvalResultMasked: '7367cdb411b730128dd56e8edc0eff56', - tag: 'ffffffff000000000000000000000000', - counter: 'ffffffff000000000000000000000080', - result: '18ce4f0b8cb4d0cac65fea8f79257b20888e53e72299e56dffffffff000000000000000000000000', - }, -]; + const name = `Wycheproof/${g.ivSize}/${g.keySize}/${g.tagSize}/${g.type}`; + for (let i = 0; i < g.tests.length; i++) { + const t = g.tests[i]; + should(`${name}: ${t.tcId}`, async () => { + const key = utils.hexToBytes(t.key); + const iv = utils.hexToBytes(t.iv); + const msg = utils.hexToBytes(t.msg); + const aad = utils.hexToBytes(t.aad); + const gcm = cipher(key, iv, aad); + const ct = utils.concatBytes(utils.hexToBytes(t.ct), utils.hexToBytes(t.tag)); -describe('AES-GCM-SIV', () => { - should('Polyval', () => { - const h = polyval( - hex.decode('25629347589242761d31f826ba4b757b'), - hex.decode('4f4f95668c83dfb6401762bb2d01a262d1a24ddd2721d006bbe45f20d3c9f362') - ); - deepStrictEqual(hex.encode(h), 'f7a3b47b846119fae5b7866cf5e5b77e'); - }); - for (const flavor of ['aes128', 'aes256', 'counterWrap']) { - for (let i = 0; i < VECTORS[flavor].length; i++) { - const v = VECTORS[flavor][i]; - should(`${flavor}(${i}): init`, async () => { - const { encKey, authKey } = await siv.deriveKeys(hex.decode(v.key), hex.decode(v.nonce)); - deepStrictEqual(encKey, hex.decode(v.encKey)); - deepStrictEqual(authKey, hex.decode(v.authKey)); - }); - should(`${flavor}(${i}): polyval`, async () => { - deepStrictEqual( - polyval(hex.decode(v.authKey), hex.decode(v.polyvalInput)), - hex.decode(v.polyvalResult) - ); - }); - should(`${flavor}(${i}).encrypt`, async () => { - let a = await siv.aes_256_gcm_siv( - hex.decode(v.key), - hex.decode(v.nonce), - hex.decode(v.AAD) - ); - deepStrictEqual(await a.encrypt(hex.decode(v.plaintext)), hex.decode(v.result)); - }); - should(`${flavor}(${i}).decrypt`, async () => { - let a = await siv.aes_256_gcm_siv( - hex.decode(v.key), - hex.decode(v.nonce), - hex.decode(v.AAD) - ); - deepStrictEqual(await a.decrypt(hex.decode(v.result)), hex.decode(v.plaintext)); + if (t.result === 'valid') { + deepStrictEqual(await gcm.encrypt(msg), ct); + deepStrictEqual(await gcm.decrypt(ct), msg); + } else { + await rejects(async () => await a.decrypt(ct)); + } }); } } - - describe('Wycheproof', () => { - for (const g of aes_gcm_siv_test.testGroups) { - const name = `Wycheproof/${g.ivSize}/${g.keySize}/${g.tagSize}/${g.type}`; - for (let i = 0; i < g.tests.length; i++) { - const t = g.tests[i]; - should(`${name}: ${i}`, async () => { - const a = await siv.aes_256_gcm_siv( - hex.decode(t.key), - hex.decode(t.iv), - hex.decode(t.aad) - ); - const ct = utils.concatBytes(hex.decode(t.ct), hex.decode(t.tag)); - const msg = hex.decode(t.msg); - if (t.result === 'valid') { - deepStrictEqual(await a.decrypt(ct), msg); - deepStrictEqual(await a.encrypt(msg), ct); - } else { - await rejects(async () => await a.decrypt(ct)); - } - }); - } - } - }); }); if (require.main === module) should.run(); diff --git a/test/index.js b/test/index.js index 3ea6a56..469cae4 100644 --- a/test/index.js +++ b/test/index.js @@ -1,7 +1,7 @@ -// import { should } from 'micro-should'; const { should } = require('micro-should'); require('./basic.test.js'); require('./gcm.test.js'); +require('./gcm-siv.test.js'); require('./ff1.test.js'); if (require.main === module) should.run(); diff --git a/test/vectors/siv.json b/test/vectors/siv.json new file mode 100644 index 0000000..054b49e --- /dev/null +++ b/test/vectors/siv.json @@ -0,0 +1,758 @@ +{ + "aes128": [ + { + "plaintext": "", + "AAD": "", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "00000000000000000000000000000000", + "polyvalResult": "00000000000000000000000000000000", + "polyvalResultXOR": "03000000000000000000000000000000", + "polyvalResultMasked": "03000000000000000000000000000000", + "tag": "dc20e2d83f25705bb49e439eca56de25", + "counter": "dc20e2d83f25705bb49e439eca56dea5", + "result": "dc20e2d83f25705bb49e439eca56de25" + }, + { + "plaintext": "0100000000000000", + "AAD": "", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "0100000000000000000000000000000000000000000000004000000000000000", + "polyvalResult": "eb93b7740962c5e49d2a90a7dc5cec74", + "polyvalResultXOR": "e893b7740962c5e49d2a90a7dc5cec74", + "polyvalResultMasked": "e893b7740962c5e49d2a90a7dc5cec74", + "tag": "578782fff6013b815b287c22493a364c", + "counter": "578782fff6013b815b287c22493a36cc", + "result": "b5d839330ac7b786578782fff6013b815b287c22493a364c" + }, + { + "plaintext": "010000000000000000000000", + "AAD": "", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "0100000000000000000000000000000000000000000000006000000000000000", + "polyvalResult": "48eb6c6c5a2dbe4a1dde508fee06361b", + "polyvalResultXOR": "4beb6c6c5a2dbe4a1dde508fee06361b", + "polyvalResultMasked": "4beb6c6c5a2dbe4a1dde508fee06361b", + "tag": "a4978db357391a0bc4fdec8b0d106639", + "counter": "a4978db357391a0bc4fdec8b0d1066b9", + "result": "7323ea61d05932260047d942a4978db357391a0bc4fdec8b0d106639" + }, + { + "plaintext": "01000000000000000000000000000000", + "AAD": "", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "0100000000000000000000000000000000000000000000008000000000000000", + "polyvalResult": "20806c26e3c1de019e111255708031d6", + "polyvalResultXOR": "23806c26e3c1de019e111255708031d6", + "polyvalResultMasked": "23806c26e3c1de019e11125570803156", + "tag": "303aaf90f6fe21199c6068577437a0c4", + "counter": "303aaf90f6fe21199c6068577437a0c4", + "result": "743f7c8077ab25f8624e2e948579cf77303aaf90f6fe21199c6068577437a0c4" + }, + { + "plaintext": "0100000000000000000000000000000002000000000000000000000000000000", + "AAD": "", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000000000000000000000001000000000000", + "polyvalResult": "ce6edc9a50b36d9a98986bbf6a261c3b", + "polyvalResultXOR": "cd6edc9a50b36d9a98986bbf6a261c3b", + "polyvalResultMasked": "cd6edc9a50b36d9a98986bbf6a261c3b", + "tag": "1a8e45dcd4578c667cd86847bf6155ff", + "counter": "1a8e45dcd4578c667cd86847bf6155ff", + "result": "84e07e62ba83a6585417245d7ec413a9fe427d6315c09b57ce45f2e3936a94451a8e45dcd4578c667cd86847bf6155ff" + }, + { + "plaintext": "010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000", + "AAD": "", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000000000000000000008001000000000000", + "polyvalResult": "81388746bc22d26b2abc3dcb15754222", + "polyvalResultXOR": "82388746bc22d26b2abc3dcb15754222", + "polyvalResultMasked": "82388746bc22d26b2abc3dcb15754222", + "tag": "5e6e311dbf395d35b0fe39c2714388f8", + "counter": "5e6e311dbf395d35b0fe39c2714388f8", + "result": "3fd24ce1f5a67b75bf2351f181a475c7b800a5b4d3dcf70106b1eea82fa1d64df42bf7226122fa92e17a40eeaac1201b5e6e311dbf395d35b0fe39c2714388f8" + }, + { + "plaintext": "01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000", + "AAD": "", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "0100000000000000000000000000000002000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000000000000000000000002000000000000", + "polyvalResult": "1e39b6d3344d348f6044f89935d1cf78", + "polyvalResultXOR": "1d39b6d3344d348f6044f89935d1cf78", + "polyvalResultMasked": "1d39b6d3344d348f6044f89935d1cf78", + "tag": "8a263dd317aa88d56bdf3936dba75bb8", + "counter": "8a263dd317aa88d56bdf3936dba75bb8", + "result": "2433668f1058190f6d43e360f4f35cd8e475127cfca7028ea8ab5c20f7ab2af02516a2bdcbc08d521be37ff28c152bba36697f25b4cd169c6590d1dd39566d3f8a263dd317aa88d56bdf3936dba75bb8" + }, + { + "plaintext": "0200000000000000", + "AAD": "01", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000008000000000000004000000000000000", + "polyvalResult": "b26781e7e2c1376f96bec195f3709b2a", + "polyvalResultXOR": "b16781e7e2c1376f96bec195f3709b2a", + "polyvalResultMasked": "b16781e7e2c1376f96bec195f3709b2a", + "tag": "3b0a1a2560969cdf790d99759abd1508", + "counter": "3b0a1a2560969cdf790d99759abd1588", + "result": "1e6daba35669f4273b0a1a2560969cdf790d99759abd1508" + }, + { + "plaintext": "020000000000000000000000", + "AAD": "01", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000008000000000000006000000000000000", + "polyvalResult": "111f5affb18e4cc1164a01bdc12a4145", + "polyvalResultXOR": "121f5affb18e4cc1164a01bdc12a4145", + "polyvalResultMasked": "121f5affb18e4cc1164a01bdc12a4145", + "tag": "08299c5102745aaa3a0c469fad9e075a", + "counter": "08299c5102745aaa3a0c469fad9e07da", + "result": "296c7889fd99f41917f4462008299c5102745aaa3a0c469fad9e075a" + }, + { + "plaintext": "02000000000000000000000000000000", + "AAD": "01", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000008000000000000008000000000000000", + "polyvalResult": "79745ab508622c8a958543675fac4688", + "polyvalResultXOR": "7a745ab508622c8a958543675fac4688", + "polyvalResultMasked": "7a745ab508622c8a958543675fac4608", + "tag": "8f8936ec039e4e4bb97ebd8c4457441f", + "counter": "8f8936ec039e4e4bb97ebd8c4457449f", + "result": "e2b0c5da79a901c1745f700525cb335b8f8936ec039e4e4bb97ebd8c4457441f" + }, + { + "plaintext": "0200000000000000000000000000000003000000000000000000000000000000", + "AAD": "01", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000008000000000000000001000000000000", + "polyvalResult": "2ce7daaf7c89490822051255b12eca6b", + "polyvalResultXOR": "2fe7daaf7c89490822051255b12eca6b", + "polyvalResultMasked": "2fe7daaf7c89490822051255b12eca6b", + "tag": "e6af6a7f87287da059a71684ed3498e1", + "counter": "e6af6a7f87287da059a71684ed3498e1", + "result": "620048ef3c1e73e57e02bb8562c416a319e73e4caac8e96a1ecb2933145a1d71e6af6a7f87287da059a71684ed3498e1" + }, + { + "plaintext": "020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000", + "AAD": "01", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "0100000000000000000000000000000002000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000008000000000000008001000000000000", + "polyvalResult": "9ca987715d69c1786711dfcd22f830fc", + "polyvalResultXOR": "9fa987715d69c1786711dfcd22f830fc", + "polyvalResultMasked": "9fa987715d69c1786711dfcd22f8307c", + "tag": "6a8cc3865f76897c2e4b245cf31c51f2", + "counter": "6a8cc3865f76897c2e4b245cf31c51f2", + "result": "50c8303ea93925d64090d07bd109dfd9515a5a33431019c17d93465999a8b0053201d723120a8562b838cdff25bf9d1e6a8cc3865f76897c2e4b245cf31c51f2" + }, + { + "plaintext": "02000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000005000000000000000000000000000000", + "AAD": "01", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000040000000000000000000000000000000500000000000000000000000000000008000000000000000002000000000000", + "polyvalResult": "ffcd05d5770f34ad9267f0a59994b15a", + "polyvalResultXOR": "fccd05d5770f34ad9267f0a59994b15a", + "polyvalResultMasked": "fccd05d5770f34ad9267f0a59994b15a", + "tag": "cdc46ae475563de037001ef84ae21744", + "counter": "cdc46ae475563de037001ef84ae217c4", + "result": "2f5c64059db55ee0fb847ed513003746aca4e61c711b5de2e7a77ffd02da42feec601910d3467bb8b36ebbaebce5fba30d36c95f48a3e7980f0e7ac299332a80cdc46ae475563de037001ef84ae21744" + }, + { + "plaintext": "02000000", + "AAD": "010000000000000000000000", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000060000000000000002000000000000000", + "polyvalResult": "f6ce9d3dcd68a2fd603c7ecc18fb9918", + "polyvalResultXOR": "f5ce9d3dcd68a2fd603c7ecc18fb9918", + "polyvalResultMasked": "f5ce9d3dcd68a2fd603c7ecc18fb9918", + "tag": "07eb1f84fb28f8cb73de8e99e2f48a14", + "counter": "07eb1f84fb28f8cb73de8e99e2f48a94", + "result": "a8fe3e8707eb1f84fb28f8cb73de8e99e2f48a14" + }, + { + "plaintext": "0300000000000000000000000000000004000000", + "AAD": "010000000000000000000000000000000200", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000040000000000000000000000000000009000000000000000a000000000000000", + "polyvalResult": "4781d492cb8f926c504caa36f61008fe", + "polyvalResultXOR": "4481d492cb8f926c504caa36f61008fe", + "polyvalResultMasked": "4481d492cb8f926c504caa36f610087e", + "tag": "24afc9805e976f451e6d87f6fe106514", + "counter": "24afc9805e976f451e6d87f6fe106594", + "result": "6bb0fecf5ded9b77f902c7d5da236a4391dd029724afc9805e976f451e6d87f6fe106514" + }, + { + "plaintext": "030000000000000000000000000000000400", + "AAD": "0100000000000000000000000000000002000000", + "key": "01000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "d9b360279694941ac5dbc6987ada7377", + "encKey": "4004a0dcd862f2a57360219d2d44ef6c", + "polyvalInput": "01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000a0000000000000009000000000000000", + "polyvalResult": "75cbc23a1a10e348aeb8e384b5cc79fd", + "polyvalResultXOR": "76cbc23a1a10e348aeb8e384b5cc79fd", + "polyvalResultMasked": "76cbc23a1a10e348aeb8e384b5cc797d", + "tag": "bff9b2ef00fb47920cc72a0c0f13b9fd", + "counter": "bff9b2ef00fb47920cc72a0c0f13b9fd", + "result": "44d0aaf6fb2f1f34add5e8064e83e12a2adabff9b2ef00fb47920cc72a0c0f13b9fd" + }, + { + "plaintext": "", + "AAD": "", + "key": "e66021d5eb8e4f4066d4adb9c33560e4", + "nonce": "f46e44bb3da0015c94f70887", + "authKey": "036ee1fe2d7926af68898095e54e7b3c", + "encKey": "5e46482396008223b5c1d25173d87539", + "polyvalInput": "00000000000000000000000000000000", + "polyvalResult": "00000000000000000000000000000000", + "polyvalResultXOR": "f46e44bb3da0015c94f7088700000000", + "polyvalResultMasked": "f46e44bb3da0015c94f7088700000000", + "tag": "a4194b79071b01a87d65f706e3949578", + "counter": "a4194b79071b01a87d65f706e39495f8", + "result": "a4194b79071b01a87d65f706e3949578" + }, + { + "plaintext": "7a806c", + "AAD": "46bb91c3c5", + "key": "36864200e0eaf5284d884a0e77d31646", + "nonce": "bae8e37fc83441b16034566b", + "authKey": "3e28de1120b2981a0155795ca2812af6", + "encKey": "6d4b78b31a4c9c03d8db0f42f7507fae", + "polyvalInput": "46bb91c3c500000000000000000000007a806c0000000000000000000000000028000000000000001800000000000000", + "polyvalResult": "43d9a745511dcfa21b96dd606f1d5720", + "polyvalResultXOR": "f931443a99298e137ba28b0b6f1d5720", + "polyvalResultMasked": "f931443a99298e137ba28b0b6f1d5720", + "tag": "711bd85bc1e4d3e0a462e074eea428a8", + "counter": "711bd85bc1e4d3e0a462e074eea428a8", + "result": "af60eb711bd85bc1e4d3e0a462e074eea428a8" + }, + { + "plaintext": "bdc66f146545", + "AAD": "fc880c94a95198874296", + "key": "aedb64a6c590bc84d1a5e269e4b47801", + "nonce": "afc0577e34699b9e671fdd4f", + "authKey": "43b8de9cea62330d15cccfc84a33e8c8", + "encKey": "8e54631607e431e095b54852868e3a27", + "polyvalInput": "fc880c94a95198874296000000000000bdc66f1465450000000000000000000050000000000000003000000000000000", + "polyvalResult": "26498e0d2b1ef004e808c458e8f2f515", + "polyvalResultXOR": "8989d9731f776b9a8f171917e8f2f515", + "polyvalResultMasked": "8989d9731f776b9a8f171917e8f2f515", + "tag": "d6a9c45545cfc11f03ad743dba20f966", + "counter": "d6a9c45545cfc11f03ad743dba20f9e6", + "result": "bb93a3e34d3cd6a9c45545cfc11f03ad743dba20f966" + }, + { + "plaintext": "1177441f195495860f", + "AAD": "046787f3ea22c127aaf195d1894728", + "key": "d5cc1fd161320b6920ce07787f86743b", + "nonce": "275d1ab32f6d1f0434d8848c", + "authKey": "8a51df64d93eaf667c2c09bd454ce5c5", + "encKey": "43ab276c2b4a473918ca73f2dd85109c", + "polyvalInput": "046787f3ea22c127aaf195d1894728001177441f195495860f0000000000000078000000000000004800000000000000", + "polyvalResult": "63a3451c0b23345ad02bba59956517cf", + "polyvalResultXOR": "44fe5faf244e2b5ee4f33ed5956517cf", + "polyvalResultMasked": "44fe5faf244e2b5ee4f33ed59565174f", + "tag": "1d02fd0cd174c84fc5dae2f60f52fd2b", + "counter": "1d02fd0cd174c84fc5dae2f60f52fdab", + "result": "4f37281f7ad12949d01d02fd0cd174c84fc5dae2f60f52fd2b" + }, + { + "plaintext": "9f572c614b4745914474e7c7", + "AAD": "c9882e5386fd9f92ec489c8fde2be2cf97e74e93", + "key": "b3fed1473c528b8426a582995929a149", + "nonce": "9e9ad8780c8d63d0ab4149c0", + "authKey": "22f50707a95dd416df069d670cb775e8", + "encKey": "f674a5584ee21fe97b4cebc468ab61e4", + "polyvalInput": "c9882e5386fd9f92ec489c8fde2be2cf97e74e930000000000000000000000009f572c614b4745914474e7c700000000a0000000000000006000000000000000", + "polyvalResult": "0cca0423fba9d77fe7e2e6963b08cdd0", + "polyvalResultXOR": "9250dc5bf724b4af4ca3af563b08cdd0", + "polyvalResultMasked": "9250dc5bf724b4af4ca3af563b08cd50", + "tag": "c1dc2f871fb7561da1286e655e24b7b0", + "counter": "c1dc2f871fb7561da1286e655e24b7b0", + "result": "f54673c5ddf710c745641c8bc1dc2f871fb7561da1286e655e24b7b0" + }, + { + "plaintext": "0d8c8451178082355c9e940fea2f58", + "AAD": "2950a70d5a1db2316fd568378da107b52b0da55210cc1c1b0a", + "key": "2d4ed87da44102952ef94b02b805249b", + "nonce": "ac80e6f61455bfac8308a2d4", + "authKey": "0b00a29a83e7e95b92e3a0783b29f140", + "encKey": "a430c27f285aed913005975c42eed5f3", + "polyvalInput": "2950a70d5a1db2316fd568378da107b52b0da55210cc1c1b0a000000000000000d8c8451178082355c9e940fea2f5800c8000000000000007800000000000000", + "polyvalResult": "1086ef25247aa41009bbc40871d9b350", + "polyvalResultXOR": "bc0609d3302f1bbc8ab366dc71d9b350", + "polyvalResultMasked": "bc0609d3302f1bbc8ab366dc71d9b350", + "tag": "83b3449b9f39552de99dc214a1190b0b", + "counter": "83b3449b9f39552de99dc214a1190b8b", + "result": "c9ff545e07b88a015f05b274540aa183b3449b9f39552de99dc214a1190b0b" + }, + { + "plaintext": "6b3db4da3d57aa94842b9803a96e07fb6de7", + "AAD": "1860f762ebfbd08284e421702de0de18baa9c9596291b08466f37de21c7f", + "key": "bde3b2f204d1e9f8b06bc47f9745b3d1", + "nonce": "ae06556fb6aa7890bebc18fe", + "authKey": "21c874a8bad3603d1c3e8784df5b3f9f", + "encKey": "d1c16d72651c3df504eae27129d818e8", + "polyvalInput": "1860f762ebfbd08284e421702de0de18baa9c9596291b08466f37de21c7f00006b3db4da3d57aa94842b9803a96e07fb6de70000000000000000000000000000f0000000000000009000000000000000", + "polyvalResult": "55462a5afa0da8d646481e049ef9c764", + "polyvalResultXOR": "fb407f354ca7d046f8f406fa9ef9c764", + "polyvalResultMasked": "fb407f354ca7d046f8f406fa9ef9c764", + "tag": "3e377094f04709f64d7b985310a4db84", + "counter": "3e377094f04709f64d7b985310a4db84", + "result": "6298b296e24e8cc35dce0bed484b7f30d5803e377094f04709f64d7b985310a4db84" + }, + { + "plaintext": "e42a3c02c25b64869e146d7b233987bddfc240871d", + "AAD": "7576f7028ec6eb5ea7e298342a94d4b202b370ef9768ec6561c4fe6b7e7296fa859c21", + "key": "f901cfe8a69615a93fdf7a98cad48179", + "nonce": "6245709fb18853f68d833640", + "authKey": "3724f55f1d22ac0ab830da0b6a995d74", + "encKey": "75ac87b70c05db287de779006105a344", + "polyvalInput": "7576f7028ec6eb5ea7e298342a94d4b202b370ef9768ec6561c4fe6b7e7296fa859c2100000000000000000000000000e42a3c02c25b64869e146d7b233987bddfc240871d00000000000000000000001801000000000000a800000000000000", + "polyvalResult": "4cbba090f03f7d1188ea55749fa6c7bd", + "polyvalResultXOR": "2efed00f41b72ee7056963349fa6c7bd", + "polyvalResultMasked": "2efed00f41b72ee7056963349fa6c73d", + "tag": "2d15506c84a9edd65e13e9d24a2a6e70", + "counter": "2d15506c84a9edd65e13e9d24a2a6ef0", + "result": "391cc328d484a4f46406181bcd62efd9b3ee197d052d15506c84a9edd65e13e9d24a2a6e70" + } + ], + "aes256": [ + { + "plaintext": "", + "AAD": "", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "00000000000000000000000000000000", + "polyvalResult": "00000000000000000000000000000000", + "polyvalResultXOR": "03000000000000000000000000000000", + "polyvalResultMasked": "03000000000000000000000000000000", + "tag": "07f5f4169bbf55a8400cd47ea6fd400f", + "counter": "07f5f4169bbf55a8400cd47ea6fd408f", + "result": "07f5f4169bbf55a8400cd47ea6fd400f" + }, + { + "plaintext": "0100000000000000", + "AAD": "", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "0100000000000000000000000000000000000000000000004000000000000000", + "polyvalResult": "05230f62f0eac8aa14fe4d646b59cd41", + "polyvalResultXOR": "06230f62f0eac8aa14fe4d646b59cd41", + "polyvalResultMasked": "06230f62f0eac8aa14fe4d646b59cd41", + "tag": "843122130f7364b761e0b97427e3df28", + "counter": "843122130f7364b761e0b97427e3dfa8", + "result": "c2ef328e5c71c83b843122130f7364b761e0b97427e3df28" + }, + { + "plaintext": "010000000000000000000000", + "AAD": "", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "0100000000000000000000000000000000000000000000006000000000000000", + "polyvalResult": "6d81a24732fd6d03ae5af544720a1c13", + "polyvalResultXOR": "6e81a24732fd6d03ae5af544720a1c13", + "polyvalResultMasked": "6e81a24732fd6d03ae5af544720a1c13", + "tag": "8ca50da9ae6559e48fd10f6e5c9ca17e", + "counter": "8ca50da9ae6559e48fd10f6e5c9ca1fe", + "result": "9aab2aeb3faa0a34aea8e2b18ca50da9ae6559e48fd10f6e5c9ca17e" + }, + { + "plaintext": "01000000000000000000000000000000", + "AAD": "", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "0100000000000000000000000000000000000000000000008000000000000000", + "polyvalResult": "74eee2bf7c9a165f8b25dea73db32a6d", + "polyvalResultXOR": "77eee2bf7c9a165f8b25dea73db32a6d", + "polyvalResultMasked": "77eee2bf7c9a165f8b25dea73db32a6d", + "tag": "c9eac6fa700942702e90862383c6c366", + "counter": "c9eac6fa700942702e90862383c6c3e6", + "result": "85a01b63025ba19b7fd3ddfc033b3e76c9eac6fa700942702e90862383c6c366" + }, + { + "plaintext": "0100000000000000000000000000000002000000000000000000000000000000", + "AAD": "", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000000000000000000000001000000000000", + "polyvalResult": "899b6381b3d46f0def7aa0517ba188f5", + "polyvalResultXOR": "8a9b6381b3d46f0def7aa0517ba188f5", + "polyvalResultMasked": "8a9b6381b3d46f0def7aa0517ba18875", + "tag": "e819e63abcd020b006a976397632eb5d", + "counter": "e819e63abcd020b006a976397632ebdd", + "result": "4a6a9db4c8c6549201b9edb53006cba821ec9cf850948a7c86c68ac7539d027fe819e63abcd020b006a976397632eb5d" + }, + { + "plaintext": "010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000", + "AAD": "", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000000000000000000008001000000000000", + "polyvalResult": "c1f8593d8fc29b0c290cae1992f71f51", + "polyvalResultXOR": "c2f8593d8fc29b0c290cae1992f71f51", + "polyvalResultMasked": "c2f8593d8fc29b0c290cae1992f71f51", + "tag": "790bc96880a99ba804bd12c0e6a22cc4", + "counter": "790bc96880a99ba804bd12c0e6a22cc4", + "result": "c00d121893a9fa603f48ccc1ca3c57ce7499245ea0046db16c53c7c66fe717e39cf6c748837b61f6ee3adcee17534ed5790bc96880a99ba804bd12c0e6a22cc4" + }, + { + "plaintext": "01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000", + "AAD": "", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "0100000000000000000000000000000002000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000000000000000000000002000000000000", + "polyvalResult": "6ef38b06046c7c0e225efaef8e2ec4c4", + "polyvalResultXOR": "6df38b06046c7c0e225efaef8e2ec4c4", + "polyvalResultMasked": "6df38b06046c7c0e225efaef8e2ec444", + "tag": "112864c269fc0d9d88c61fa47e39aa08", + "counter": "112864c269fc0d9d88c61fa47e39aa88", + "result": "c2d5160a1f8683834910acdafc41fbb1632d4a353e8b905ec9a5499ac34f96c7e1049eb080883891a4db8caaa1f99dd004d80487540735234e3744512c6f90ce112864c269fc0d9d88c61fa47e39aa08" + }, + { + "plaintext": "0200000000000000", + "AAD": "01", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000008000000000000004000000000000000", + "polyvalResult": "34e57bafe011b9b36fc6821b7ffb3354", + "polyvalResultXOR": "37e57bafe011b9b36fc6821b7ffb3354", + "polyvalResultMasked": "37e57bafe011b9b36fc6821b7ffb3354", + "tag": "91213f267e3b452f02d01ae33e4ec854", + "counter": "91213f267e3b452f02d01ae33e4ec8d4", + "result": "1de22967237a813291213f267e3b452f02d01ae33e4ec854" + }, + { + "plaintext": "020000000000000000000000", + "AAD": "01", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000008000000000000006000000000000000", + "polyvalResult": "5c47d68a22061c1ad5623a3b66a8e206", + "polyvalResultXOR": "5f47d68a22061c1ad5623a3b66a8e206", + "polyvalResultMasked": "5f47d68a22061c1ad5623a3b66a8e206", + "tag": "c1a4a19ae800941ccdc57cc8413c277f", + "counter": "c1a4a19ae800941ccdc57cc8413c27ff", + "result": "163d6f9cc1b346cd453a2e4cc1a4a19ae800941ccdc57cc8413c277f" + }, + { + "plaintext": "02000000000000000000000000000000", + "AAD": "01", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000008000000000000008000000000000000", + "polyvalResult": "452896726c616746f01d11d82911d478", + "polyvalResultXOR": "462896726c616746f01d11d82911d478", + "polyvalResultMasked": "462896726c616746f01d11d82911d478", + "tag": "b292d28ff61189e8e49f3875ef91aff7", + "counter": "b292d28ff61189e8e49f3875ef91aff7", + "result": "c91545823cc24f17dbb0e9e807d5ec17b292d28ff61189e8e49f3875ef91aff7" + }, + { + "plaintext": "0200000000000000000000000000000003000000000000000000000000000000", + "AAD": "01", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000008000000000000000001000000000000", + "polyvalResult": "4e58c1e341c9bb0ae34eda9509dfc90c", + "polyvalResultXOR": "4d58c1e341c9bb0ae34eda9509dfc90c", + "polyvalResultMasked": "4d58c1e341c9bb0ae34eda9509dfc90c", + "tag": "aea1bad12702e1965604374aab96dbbc", + "counter": "aea1bad12702e1965604374aab96dbbc", + "result": "07dad364bfc2b9da89116d7bef6daaaf6f255510aa654f920ac81b94e8bad365aea1bad12702e1965604374aab96dbbc" + }, + { + "plaintext": "020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000", + "AAD": "01", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "0100000000000000000000000000000002000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000008000000000000008001000000000000", + "polyvalResult": "2566a4aff9a525df9772c16d4eaf8d2a", + "polyvalResultXOR": "2666a4aff9a525df9772c16d4eaf8d2a", + "polyvalResultMasked": "2666a4aff9a525df9772c16d4eaf8d2a", + "tag": "03332742b228c647173616cfd44c54eb", + "counter": "03332742b228c647173616cfd44c54eb", + "result": "c67a1f0f567a5198aa1fcc8e3f21314336f7f51ca8b1af61feac35a86416fa47fbca3b5f749cdf564527f2314f42fe2503332742b228c647173616cfd44c54eb" + }, + { + "plaintext": "02000000000000000000000000000000030000000000000000000000000000000400000000000000000000000000000005000000000000000000000000000000", + "AAD": "01", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000040000000000000000000000000000000500000000000000000000000000000008000000000000000002000000000000", + "polyvalResult": "da58d2f61b0a9d343b2f37fb0c519733", + "polyvalResultXOR": "d958d2f61b0a9d343b2f37fb0c519733", + "polyvalResultMasked": "d958d2f61b0a9d343b2f37fb0c519733", + "tag": "5bde0285037c5de81e5b570a049b62a0", + "counter": "5bde0285037c5de81e5b570a049b62a0", + "result": "67fd45e126bfb9a79930c43aad2d36967d3f0e4d217c1e551f59727870beefc98cb933a8fce9de887b1e40799988db1fc3f91880ed405b2dd298318858467c895bde0285037c5de81e5b570a049b62a0" + }, + { + "plaintext": "02000000", + "AAD": "010000000000000000000000", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000060000000000000002000000000000000", + "polyvalResult": "6dc76ae84b88916e073a303aafde05cf", + "polyvalResultXOR": "6ec76ae84b88916e073a303aafde05cf", + "polyvalResultMasked": "6ec76ae84b88916e073a303aafde054f", + "tag": "1835e517741dfddccfa07fa4661b74cf", + "counter": "1835e517741dfddccfa07fa4661b74cf", + "result": "22b3f4cd1835e517741dfddccfa07fa4661b74cf" + }, + { + "plaintext": "0300000000000000000000000000000004000000", + "AAD": "010000000000000000000000000000000200", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "010000000000000000000000000000000200000000000000000000000000000003000000000000000000000000000000040000000000000000000000000000009000000000000000a000000000000000", + "polyvalResult": "973ef4fd04bd31d193816ab26f8655ca", + "polyvalResultXOR": "943ef4fd04bd31d193816ab26f8655ca", + "polyvalResultMasked": "943ef4fd04bd31d193816ab26f86554a", + "tag": "b879ad976d8242acc188ab59cabfe307", + "counter": "b879ad976d8242acc188ab59cabfe387", + "result": "43dd0163cdb48f9fe3212bf61b201976067f342bb879ad976d8242acc188ab59cabfe307" + }, + { + "plaintext": "030000000000000000000000000000000400", + "AAD": "0100000000000000000000000000000002000000", + "key": "0100000000000000000000000000000000000000000000000000000000000000", + "nonce": "030000000000000000000000", + "authKey": "b5d3c529dfafac43136d2d11be284d7f", + "encKey": "b914f4742be9e1d7a2f84addbf96dec3456e3c6c05ecc157cdbf0700fedad222", + "polyvalInput": "01000000000000000000000000000000020000000000000000000000000000000300000000000000000000000000000004000000000000000000000000000000a0000000000000009000000000000000", + "polyvalResult": "2cbb6b7ab2dbffefb797f825f826870c", + "polyvalResultXOR": "2fbb6b7ab2dbffefb797f825f826870c", + "polyvalResultMasked": "2fbb6b7ab2dbffefb797f825f826870c", + "tag": "cfcdf5042112aa29685c912fc2056543", + "counter": "cfcdf5042112aa29685c912fc20565c3", + "result": "462401724b5ce6588d5a54aae5375513a075cfcdf5042112aa29685c912fc2056543" + }, + { + "plaintext": "", + "AAD": "", + "key": "e66021d5eb8e4f4066d4adb9c33560e4f46e44bb3da0015c94f7088736864200", + "nonce": "e0eaf5284d884a0e77d31646", + "authKey": "e40d26f82774aa27f47b047b608b9585", + "encKey": "7c7c3d9a542cef53dde0e6de9b5800400f82e73ec5f7ee41b7ba8dcb9ba078c3", + "polyvalInput": "00000000000000000000000000000000", + "polyvalResult": "00000000000000000000000000000000", + "polyvalResultXOR": "e0eaf5284d884a0e77d3164600000000", + "polyvalResultMasked": "e0eaf5284d884a0e77d3164600000000", + "tag": "169fbb2fbf389a995f6390af22228a62", + "counter": "169fbb2fbf389a995f6390af22228ae2", + "result": "169fbb2fbf389a995f6390af22228a62" + }, + { + "plaintext": "671fdd", + "AAD": "4fbdc66f14", + "key": "bae8e37fc83441b16034566b7a806c46bb91c3c5aedb64a6c590bc84d1a5e269", + "nonce": "e4b47801afc0577e34699b9e", + "authKey": "b546f5a850d0a90adfe39e95c2510fc6", + "encKey": "b9d1e239d62cbb5c49273ddac8838bdcc53bca478a770f07087caa4e0a924a55", + "polyvalInput": "4fbdc66f140000000000000000000000671fdd0000000000000000000000000028000000000000001800000000000000", + "polyvalResult": "b91f91f96b159a7c611c05035b839e92", + "polyvalResultXOR": "5dabe9f8c4d5cd0255759e9d5b839e92", + "polyvalResultMasked": "5dabe9f8c4d5cd0255759e9d5b839e12", + "tag": "93da9bb81333aee0c785b240d319719d", + "counter": "93da9bb81333aee0c785b240d319719d", + "result": "0eaccb93da9bb81333aee0c785b240d319719d" + }, + { + "plaintext": "195495860f04", + "AAD": "6787f3ea22c127aaf195", + "key": "6545fc880c94a95198874296d5cc1fd161320b6920ce07787f86743b275d1ab3", + "nonce": "2f6d1f0434d8848c1177441f", + "authKey": "e156e1f9b0b07b780cbe30f259e3c8da", + "encKey": "6fc1c494519f944aae52fcd8b14e5b171b5a9429d3b76e430d49940c0021d612", + "polyvalInput": "6787f3ea22c127aaf195000000000000195495860f040000000000000000000050000000000000003000000000000000", + "polyvalResult": "2c480ed9d236b1df24c6eec109bd40c1", + "polyvalResultXOR": "032511dde6ee355335b1aade09bd40c1", + "polyvalResultMasked": "032511dde6ee355335b1aade09bd4041", + "tag": "6b62b84dc40c84636a5ec12020ec8c2c", + "counter": "6b62b84dc40c84636a5ec12020ec8cac", + "result": "a254dad4f3f96b62b84dc40c84636a5ec12020ec8c2c" + }, + { + "plaintext": "c9882e5386fd9f92ec", + "AAD": "489c8fde2be2cf97e74e932d4ed87d", + "key": "d1894728b3fed1473c528b8426a582995929a1499e9ad8780c8d63d0ab4149c0", + "nonce": "9f572c614b4745914474e7c7", + "authKey": "0533fd71f4119257361a3ff1469dd4e5", + "encKey": "4feba89799be8ac3684fa2bb30ade0ea51390e6d87dcf3627d2ee44493853abe", + "polyvalInput": "489c8fde2be2cf97e74e932d4ed87d00c9882e5386fd9f92ec0000000000000078000000000000004800000000000000", + "polyvalResult": "bf160bc9ded8c63057d2c38aae552fb4", + "polyvalResultXOR": "204127a8959f83a113a6244dae552fb4", + "polyvalResultMasked": "204127a8959f83a113a6244dae552f34", + "tag": "c0fd3dc6628dfe55ebb0b9fb2295c8c2", + "counter": "c0fd3dc6628dfe55ebb0b9fb2295c8c2", + "result": "0df9e308678244c44bc0fd3dc6628dfe55ebb0b9fb2295c8c2" + }, + { + "plaintext": "1db2316fd568378da107b52b", + "AAD": "0da55210cc1c1b0abde3b2f204d1e9f8b06bc47f", + "key": "a44102952ef94b02b805249bac80e6f61455bfac8308a2d40d8c845117808235", + "nonce": "5c9e940fea2f582950a70d5a", + "authKey": "64779ab10ee8a280272f14cc8851b727", + "encKey": "25f40fc63f49d3b9016a8eeeb75846e0d72ca36ddbd312b6f5ef38ad14bd2651", + "polyvalInput": "0da55210cc1c1b0abde3b2f204d1e9f8b06bc47f0000000000000000000000001db2316fd568378da107b52b00000000a0000000000000006000000000000000", + "polyvalResult": "cc86ee22c861e1fd474c84676b42739c", + "polyvalResultXOR": "90187a2d224eb9d417eb893d6b42739c", + "polyvalResultMasked": "90187a2d224eb9d417eb893d6b42731c", + "tag": "404099c2587f64979f21826706d497d5", + "counter": "404099c2587f64979f21826706d497d5", + "result": "8dbeb9f7255bf5769dd56692404099c2587f64979f21826706d497d5" + }, + { + "plaintext": "21702de0de18baa9c9596291b08466", + "AAD": "f37de21c7ff901cfe8a69615a93fdf7a98cad481796245709f", + "key": "9745b3d1ae06556fb6aa7890bebc18fe6b3db4da3d57aa94842b9803a96e07fb", + "nonce": "6de71860f762ebfbd08284e4", + "authKey": "27c2959ed4daea3b1f52e849478de376", + "encKey": "307a38a5a6cf231c0a9af3b527f23a62e9a6ff09aff8ae669f760153e864fc93", + "polyvalInput": "f37de21c7ff901cfe8a69615a93fdf7a98cad481796245709f0000000000000021702de0de18baa9c9596291b0846600c8000000000000007800000000000000", + "polyvalResult": "c4fa5e5b713853703bcf8e6424505fa5", + "polyvalResultXOR": "a91d463b865ab88beb4d0a8024505fa5", + "polyvalResultMasked": "a91d463b865ab88beb4d0a8024505f25", + "tag": "b3080d28f6ebb5d3648ce97bd5ba67fd", + "counter": "b3080d28f6ebb5d3648ce97bd5ba67fd", + "result": "793576dfa5c0f88729a7ed3c2f1bffb3080d28f6ebb5d3648ce97bd5ba67fd" + }, + { + "plaintext": "b202b370ef9768ec6561c4fe6b7e7296fa85", + "AAD": "9c2159058b1f0fe91433a5bdc20e214eab7fecef4454a10ef0657df21ac7", + "key": "b18853f68d833640e42a3c02c25b64869e146d7b233987bddfc240871d7576f7", + "nonce": "028ec6eb5ea7e298342a94d4", + "authKey": "670b98154076ddb59b7a9137d0dcc0f0", + "encKey": "78116d78507fbe69d4a820c350f55c7cb36c3c9287df0e9614b142b76a587c3f", + "polyvalInput": "9c2159058b1f0fe91433a5bdc20e214eab7fecef4454a10ef0657df21ac70000b202b370ef9768ec6561c4fe6b7e7296fa850000000000000000000000000000f0000000000000009000000000000000", + "polyvalResult": "4e4108f09f41d797dc9256f8da8d58c7", + "polyvalResultXOR": "4ccfce1bc1e6350fe8b8c22cda8d58c7", + "polyvalResultMasked": "4ccfce1bc1e6350fe8b8c22cda8d5847", + "tag": "454fc2a154fea91f8363a39fec7d0a49", + "counter": "454fc2a154fea91f8363a39fec7d0ac9", + "result": "857e16a64915a787637687db4a9519635cdd454fc2a154fea91f8363a39fec7d0a49" + }, + { + "plaintext": "ced532ce4159b035277d4dfbb7db62968b13cd4eec", + "AAD": "734320ccc9d9bbbb19cb81b2af4ecbc3e72834321f7aa0f70b7282b4f33df23f167541", + "key": "3c535de192eaed3822a2fbbe2ca9dfc88255e14a661b8aa82cc54236093bbc23", + "nonce": "688089e55540db1872504e1c", + "authKey": "cb8c3aa3f8dbaeb4b28a3e86ff6625f8", + "encKey": "02426ce1aa3ab31313b0848469a1b5fc6c9af9602600b195b04ad407026bc06d", + "polyvalInput": "734320ccc9d9bbbb19cb81b2af4ecbc3e72834321f7aa0f70b7282b4f33df23f16754100000000000000000000000000ced532ce4159b035277d4dfbb7db62968b13cd4eec00000000000000000000001801000000000000a800000000000000", + "polyvalResult": "ffd503c7dd712eb3791b7114b17bb0cf", + "polyvalResultXOR": "97558a228831f5ab0b4b3f08b17bb0cf", + "polyvalResultMasked": "97558a228831f5ab0b4b3f08b17bb04f", + "tag": "9d6c7029675b89eaf4ba1ded1a286594", + "counter": "9d6c7029675b89eaf4ba1ded1a286594", + "result": "626660c26ea6612fb17ad91e8e767639edd6c9faee9d6c7029675b89eaf4ba1ded1a286594" + } + ], + "counterWrap": [ + { + "plaintext": "000000000000000000000000000000004db923dc793ee6497c76dcc03a98e108", + "AAD": "", + "key": "0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "000000000000000000000000", + "authKey": "dc95c078a24089895275f3d86b4fb868", + "encKey": "779b38d15bffb63d39d6e9ae76a9b2f375d11b0e3a68c422845c7d4690fa594f", + "polyvalInput": "000000000000000000000000000000004db923dc793ee6497c76dcc03a98e10800000000000000000001000000000000", + "polyvalResult": "7367cdb411b730128dd56e8edc0eff56", + "polyvalResultXOR": "7367cdb411b730128dd56e8edc0eff56", + "polyvalResultMasked": "7367cdb411b730128dd56e8edc0eff56", + "tag": "ffffffff000000000000000000000000", + "counter": "ffffffff000000000000000000000080", + "result": "f3f80f2cf0cb2dd9c5984fcda908456cc537703b5ba70324a6793a7bf218d3eaffffffff000000000000000000000000" + }, + { + "plaintext": "eb3640277c7ffd1303c7a542d02d3e4c0000000000000000", + "AAD": "", + "key": "0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "000000000000000000000000", + "authKey": "dc95c078a24089895275f3d86b4fb868", + "encKey": "779b38d15bffb63d39d6e9ae76a9b2f375d11b0e3a68c422845c7d4690fa594f", + "polyvalInput": "eb3640277c7ffd1303c7a542d02d3e4c000000000000000000000000000000000000000000000000c000000000000000", + "polyvalResult": "7367cdb411b730128dd56e8edc0eff56", + "polyvalResultXOR": "7367cdb411b730128dd56e8edc0eff56", + "polyvalResultMasked": "7367cdb411b730128dd56e8edc0eff56", + "tag": "ffffffff000000000000000000000000", + "counter": "ffffffff000000000000000000000080", + "result": "18ce4f0b8cb4d0cac65fea8f79257b20888e53e72299e56dffffffff000000000000000000000000" + } + ] +}