diff options
author | Brian White <mscdex@mscdex.net> | 2014-03-04 00:05:23 -0500 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2014-03-04 12:42:03 +0400 |
commit | 31ce34887fc2f5e10d0c1f099e71664370794fec (patch) | |
tree | 23e6f34a242e7afd86cdc274b84ee41a984e675b /test | |
parent | caca4f33aad84f71b4f542d1455e954f4dd08313 (diff) | |
download | android-node-v8-31ce34887fc2f5e10d0c1f099e71664370794fec.tar.gz android-node-v8-31ce34887fc2f5e10d0c1f099e71664370794fec.tar.bz2 android-node-v8-31ce34887fc2f5e10d0c1f099e71664370794fec.zip |
crypto: allow setting add'l authenticated data
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-crypto-authenticated.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/simple/test-crypto-authenticated.js b/test/simple/test-crypto-authenticated.js index ff9eedab03..754732c7e5 100644 --- a/test/simple/test-crypto-authenticated.js +++ b/test/simple/test-crypto-authenticated.js @@ -41,11 +41,17 @@ crypto.DEFAULT_ENCODING = 'buffer'; // var TEST_CASES = [ - { algo: 'aes-128-gcm', key: 'ipxp9a6i1Mb4USb4', iv: 'X6sIq117H0vR', - plain: 'Hello World!', ct: '4BE13896F64DFA2C2D0F2C76', + { algo: 'aes-128-gcm', key: 'ipxp9a6i1Mb4USb4', + iv: 'X6sIq117H0vR', plain: 'Hello World!', + ct: '4BE13896F64DFA2C2D0F2C76', tag: '272B422F62EB545EAA15B5FF84092447', tampered: false }, - { algo: 'aes-128-gcm', key: 'ipxp9a6i1Mb4USb4', iv: 'X6sIq117H0vR', - plain: 'Hello World!', ct: '4BE13596F64DFA2C2D0FAC76', + { algo: 'aes-128-gcm', key: 'ipxp9a6i1Mb4USb4', + iv: 'X6sIq117H0vR', plain: 'Hello World!', + ct: '4BE13896F64DFA2C2D0F2C76', aad: '000000FF', + tag: 'BA2479F66275665A88CB7B15F43EB005', tampered: false }, + { algo: 'aes-128-gcm', key: 'ipxp9a6i1Mb4USb4', + iv: 'X6sIq117H0vR', plain: 'Hello World!', + ct: '4BE13596F64DFA2C2D0FAC76', tag: '272B422F62EB545EAA15B5FF84092447', tampered: true }, { algo: 'aes-256-gcm', key: '3zTvzr3p67VC61jmV54rIYu1545x4TlY', iv: '60iP0h6vJoEa', plain: 'Hello node.js world!', @@ -69,6 +75,8 @@ for (var i in TEST_CASES) { (function() { var encrypt = crypto.createCipheriv(test.algo, test.key, test.iv); + if (test.aad) + encrypt.setAAD(new Buffer(test.aad, 'hex')); var hex = encrypt.update(test.plain, 'ascii', 'hex'); hex += encrypt.final('hex'); var auth_tag = encrypt.getAuthTag(); @@ -82,6 +90,8 @@ for (var i in TEST_CASES) { (function() { var decrypt = crypto.createDecipheriv(test.algo, test.key, test.iv); decrypt.setAuthTag(new Buffer(test.tag, 'hex')); + if (test.aad) + decrypt.setAAD(new Buffer(test.aad, 'hex')); var msg = decrypt.update(test.ct, 'hex', 'ascii'); if (!test.tampered) { msg += decrypt.final('ascii'); |