MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / testCipherMode

Function testCipherMode

examples/crypt/cryptblockcipher/main.js:69–88  ·  view source on GitHub ↗
(name, direction, cipher, iv, padding, data, expected)

Source from the content-addressed store, hash-verified

67
68
69function testCipherMode(name, direction, cipher, iv, padding, data, expected)
70{
71 let mode, result;
72 if (name == "GCM") {
73 mode = new GCM(cipher);
74 result = mode.process(data, undefined, iv, padding /* AAD */, direction == "encrypt");
75 }
76 else {
77 mode = new Mode(name, cipher, iv, padding);
78 result = mode[direction](data);
79 }
80
81 if (Bin.comp(result, expected) != 0) {
82 trace(`${name}.${direction} FAIL\n`);
83 trace("result = " + Hex.toString(result) + "\n");
84 trace("expected = " + Hex.toString(expected) + "\n");
85 }
86 else
87 trace(`${name}.${direction} pass\n`);
88}
89
90function testBlockCipher(name, keyStr, plain, expected)
91{

Callers 1

main.jsFile · 0.85

Calls 2

processMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected