What changed, and why it matters
This commit only updates a JavaScript test file for AES encryption in the WebAssembly package. It changes how empty plaintext or ciphertext test vectors are handled (treating zero-length buffers as null) and adds a debug console.log statement. There is no change to the actual cryptographic library code, only to test expectations.
No security action required. This is a test-only change. Optionally remove the leftover console.log(i) debug statement before merging.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies src/wasm_package/test/aes.js. It changes const to var for plain/cypher, adds length checks that convert empty Buffers to null, adds a console.log(i) debug line, and adjusts assertion messages and expected values to accommodate null/empty inputs. No library implementation code is changed.
Changed components
src/wasm_package/test/aes.jsInspect captured patch +13 / −6
diff --git a/src/wasm_package/test/aes.js b/src/wasm_package/test/aes.js
index 40c6f12..f8dd0ff 100644
--- a/src/wasm_package/test/aes.js
+++ b/src/wasm_package/test/aes.js
@@ -79,17 +79,24 @@ test('AES ECB', t => {
test('AES CBC', function (t) {
for (let i = 0; i < cbc_lines.length / 4; ++i) {
- const plain = Buffer.from(cbc_lines[i * 4].split("=")[1], 'hex')
+ var plain = Buffer.from(cbc_lines[i * 4].split("=")[1], 'hex')
+ if (plain.length == 0) {
+ plain = null
+ }
const key = Buffer.from(cbc_lines[i * 4 + 1].split("=")[1], 'hex')
const iv = Buffer.from(cbc_lines[i * 4 + 2].split("=")[1], 'hex')
- const cypher = Buffer.from(cbc_lines[i * 4 + 3].split("=")[1], 'hex')
+ var cypher = Buffer.from(cbc_lines[i * 4 + 3].split("=")[1], 'hex')
+ if (cypher.length == 0) {
+ cypher = null
+ }
+ console.log(i);
const encryptResult = wally.aes_cbc(key, iv, plain, wally.AES_FLAG_ENCRYPT)
assert.deepEqual(encryptResult, cypher,
- 'aes CBC encrypt(' + plain.toString('hex') + ')')
+ 'aes CBC encrypt(' + (plain ?? "null").toString('hex') + ')')
const decryptResult = wally.aes_cbc(key, iv, cypher, wally.AES_FLAG_DECRYPT)
- assert.deepEqual(decryptResult, plain,
- 'aes CBC decrypt(' + cypher.toString('hex') + ')')
+ assert.deepEqual(decryptResult, plain ?? Buffer.from([]),
+ 'aes CBC decrypt(' + (cypher ?? "null").toString('hex') + ')')
}
-})
\ No newline at end of file
+})
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.