[Pkg-javascript-commits] [node-browserify-aes] 62/92: remove inadvertent nesting of tests
Bastien Roucariès
rouca at moszumanska.debian.org
Sun Jun 4 09:35:20 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-browserify-aes.
commit d39c24c13975f7eeaf92f15586bbcd9b58cb89c0
Author: Calvin Metcalf <cmetcalf at appgeo.com>
Date: Mon May 4 12:47:23 2015 -0400
remove inadvertent nesting of tests
---
test/index.js | 258 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 128 insertions(+), 130 deletions(-)
diff --git a/test/index.js b/test/index.js
index 893b33d..66199ab 100644
--- a/test/index.js
+++ b/test/index.js
@@ -92,146 +92,144 @@ fixtures.forEach(function (fixture, i) {
t.equals(buf.toString('utf8'), fixture.text)
t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'final')
})
- // var cipherivs = fixture.results.cipherivs = {}
-
- types.forEach(function (cipher) {
- if (modes[cipher].mode === 'ECB') {
- return
- }
- if (isGCM(cipher) && isNode10()) {
- return
+ })
+ types.forEach(function (cipher) {
+ if (modes[cipher].mode === 'ECB') {
+ return
+ }
+ if (isGCM(cipher) && isNode10()) {
+ return
+ }
+ test('fixture ' + i + ' ' + cipher + '-iv', function (t) {
+ if (isGCM(cipher)) {
+ t.plan(4)
+ } else {
+ t.plan(2)
}
- test('fixture ' + i + ' ' + cipher + '-iv', function (t) {
- if (isGCM(cipher)) {
- t.plan(4)
- } else {
- t.plan(2)
- }
- var suite = crypto.createCipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
- var suite2 = _crypto.createCipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
- var buf = new Buffer('')
- var buf2 = new Buffer('')
- suite.on('data', function (d) {
- buf = Buffer.concat([buf, d])
- })
- suite.on('error', function (e) {
- console.log(e)
- })
- suite2.on('data', function (d) {
- buf2 = Buffer.concat([buf2, d])
- })
- suite2.on('error', function (e) {
- console.log(e)
- })
- suite.on('end', function () {
- t.equals(buf.toString('hex'), fixture.results.cipherivs[cipher], 'vs fixture')
- t.equals(buf.toString('hex'), buf2.toString('hex'), 'vs node')
- if (isGCM(cipher)) {
- t.equals(suite.getAuthTag().toString('hex'), fixture.authtag[cipher], 'authtag vs fixture')
- t.equals(suite.getAuthTag().toString('hex'), suite2.getAuthTag().toString('hex'), 'authtag vs node')
- }
- })
- if (isGCM(cipher)) {
- suite.setAAD(new Buffer(fixture.aad, 'hex'))
- suite2.setAAD(new Buffer(fixture.aad, 'hex'))
- }
- suite2.write(new Buffer(fixture.text))
- suite2.end()
- suite.write(new Buffer(fixture.text))
- suite.end()
+ var suite = crypto.createCipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
+ var suite2 = _crypto.createCipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
+ var buf = new Buffer('')
+ var buf2 = new Buffer('')
+ suite.on('data', function (d) {
+ buf = Buffer.concat([buf, d])
})
-
- test('fixture ' + i + ' ' + cipher + '-legacy-iv', function (t) {
- if (isGCM(cipher)) {
- t.plan(6)
- } else {
- t.plan(4)
- }
- var suite = crypto.createCipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
- var suite2 = _crypto.createCipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
- var buf = new Buffer('')
- var buf2 = new Buffer('')
- var inbuf = new Buffer(fixture.text)
- var mid = ~~(inbuf.length / 2)
- if (isGCM(cipher)) {
- suite.setAAD(new Buffer(fixture.aad, 'hex'))
- suite2.setAAD(new Buffer(fixture.aad, 'hex'))
- }
- buf = Buffer.concat([buf, suite.update(inbuf.slice(0, mid))])
- buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(0, mid))])
- t.equals(buf.toString('hex'), buf2.toString('hex'), 'intermediate')
- buf = Buffer.concat([buf, suite.update(inbuf.slice(mid))])
- buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(mid))])
- t.equals(buf.toString('hex'), buf2.toString('hex'), 'intermediate 2')
- buf = Buffer.concat([buf, suite.final()])
- buf2 = Buffer.concat([buf2, suite2.final()])
- t.equals(buf.toString('hex'), fixture.results.cipherivs[cipher])
- t.equals(buf.toString('hex'), buf2.toString('hex'), 'final')
+ suite.on('error', function (e) {
+ console.log(e)
+ })
+ suite2.on('data', function (d) {
+ buf2 = Buffer.concat([buf2, d])
+ })
+ suite2.on('error', function (e) {
+ console.log(e)
+ })
+ suite.on('end', function () {
+ t.equals(buf.toString('hex'), fixture.results.cipherivs[cipher], 'vs fixture')
+ t.equals(buf.toString('hex'), buf2.toString('hex'), 'vs node')
if (isGCM(cipher)) {
t.equals(suite.getAuthTag().toString('hex'), fixture.authtag[cipher], 'authtag vs fixture')
t.equals(suite.getAuthTag().toString('hex'), suite2.getAuthTag().toString('hex'), 'authtag vs node')
}
})
- test('fixture ' + i + ' ' + cipher + '-iv-decrypt', function (t) {
- t.plan(2)
- var suite = crypto.createDecipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
- var buf = new Buffer('')
- var suite2 = _crypto.createDecipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
- var buf2 = new Buffer('')
- suite.on('data', function (d) {
- buf = Buffer.concat([buf, d])
- })
- suite.on('error', function (e) {
- t.notOk(e)
- })
- suite2.on('data', function (d) {
- buf2 = Buffer.concat([buf2, d])
- })
- suite2.on('error', function (e) {
- t.notOk(e)
- })
- suite.on('end', function () {
- t.equals(buf.toString('utf8'), fixture.text, 'correct text vs fixture')
- t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'correct text vs node')
- })
- if (isGCM(cipher)) {
- suite.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
- suite2.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
- suite.setAAD(new Buffer(fixture.aad, 'hex'))
- suite2.setAAD(new Buffer(fixture.aad, 'hex'))
- }
+ if (isGCM(cipher)) {
+ suite.setAAD(new Buffer(fixture.aad, 'hex'))
+ suite2.setAAD(new Buffer(fixture.aad, 'hex'))
+ }
+ suite2.write(new Buffer(fixture.text))
+ suite2.end()
+ suite.write(new Buffer(fixture.text))
+ suite.end()
+ })
- suite2.write(new Buffer(fixture.results.cipherivs[cipher], 'hex'))
- suite.write(new Buffer(fixture.results.cipherivs[cipher], 'hex'))
- suite2.end()
- suite.end()
- })
- test('fixture ' + i + ' ' + cipher + '-decrypt-legacy', function (t) {
+ test('fixture ' + i + ' ' + cipher + '-legacy-iv', function (t) {
+ if (isGCM(cipher)) {
+ t.plan(6)
+ } else {
t.plan(4)
- var suite = crypto.createDecipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
- var buf = new Buffer('')
- var suite2 = _crypto.createDecipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
- var buf2 = new Buffer('')
- var inbuf = new Buffer(fixture.results.cipherivs[cipher], 'hex')
- var mid = ~~(inbuf.length / 2)
- if (isGCM(cipher)) {
- suite.setAAD(new Buffer(fixture.aad, 'hex'))
- suite2.setAAD(new Buffer(fixture.aad, 'hex'))
- suite.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
- suite2.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
- }
- buf = Buffer.concat([buf, suite.update(inbuf.slice(0, mid))])
- buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(0, mid))])
-
- t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'intermediate')
- buf = Buffer.concat([buf, suite.update(inbuf.slice(mid))])
- buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(mid))])
- t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'intermediate 2')
- buf = Buffer.concat([buf, suite.final()])
- buf2 = Buffer.concat([buf2, suite2.final()])
- t.equals(buf.toString('utf8'), fixture.text)
- t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'final')
+ }
+ var suite = crypto.createCipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
+ var suite2 = _crypto.createCipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
+ var buf = new Buffer('')
+ var buf2 = new Buffer('')
+ var inbuf = new Buffer(fixture.text)
+ var mid = ~~(inbuf.length / 2)
+ if (isGCM(cipher)) {
+ suite.setAAD(new Buffer(fixture.aad, 'hex'))
+ suite2.setAAD(new Buffer(fixture.aad, 'hex'))
+ }
+ buf = Buffer.concat([buf, suite.update(inbuf.slice(0, mid))])
+ buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(0, mid))])
+ t.equals(buf.toString('hex'), buf2.toString('hex'), 'intermediate')
+ buf = Buffer.concat([buf, suite.update(inbuf.slice(mid))])
+ buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(mid))])
+ t.equals(buf.toString('hex'), buf2.toString('hex'), 'intermediate 2')
+ buf = Buffer.concat([buf, suite.final()])
+ buf2 = Buffer.concat([buf2, suite2.final()])
+ t.equals(buf.toString('hex'), fixture.results.cipherivs[cipher])
+ t.equals(buf.toString('hex'), buf2.toString('hex'), 'final')
+ if (isGCM(cipher)) {
+ t.equals(suite.getAuthTag().toString('hex'), fixture.authtag[cipher], 'authtag vs fixture')
+ t.equals(suite.getAuthTag().toString('hex'), suite2.getAuthTag().toString('hex'), 'authtag vs node')
+ }
+ })
+ test('fixture ' + i + ' ' + cipher + '-iv-decrypt', function (t) {
+ t.plan(2)
+ var suite = crypto.createDecipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
+ var buf = new Buffer('')
+ var suite2 = _crypto.createDecipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
+ var buf2 = new Buffer('')
+ suite.on('data', function (d) {
+ buf = Buffer.concat([buf, d])
})
+ suite.on('error', function (e) {
+ t.notOk(e)
+ })
+ suite2.on('data', function (d) {
+ buf2 = Buffer.concat([buf2, d])
+ })
+ suite2.on('error', function (e) {
+ t.notOk(e)
+ })
+ suite.on('end', function () {
+ t.equals(buf.toString('utf8'), fixture.text, 'correct text vs fixture')
+ t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'correct text vs node')
+ })
+ if (isGCM(cipher)) {
+ suite.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
+ suite2.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
+ suite.setAAD(new Buffer(fixture.aad, 'hex'))
+ suite2.setAAD(new Buffer(fixture.aad, 'hex'))
+ }
+
+ suite2.write(new Buffer(fixture.results.cipherivs[cipher], 'hex'))
+ suite.write(new Buffer(fixture.results.cipherivs[cipher], 'hex'))
+ suite2.end()
+ suite.end()
+ })
+ test('fixture ' + i + ' ' + cipher + '-decrypt-legacy', function (t) {
+ t.plan(4)
+ var suite = crypto.createDecipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
+ var buf = new Buffer('')
+ var suite2 = _crypto.createDecipheriv(cipher, ebtk(fixture.password, modes[cipher].key).key, isGCM(cipher) ? (new Buffer(fixture.iv, 'hex').slice(0, 12)) : (new Buffer(fixture.iv, 'hex')))
+ var buf2 = new Buffer('')
+ var inbuf = new Buffer(fixture.results.cipherivs[cipher], 'hex')
+ var mid = ~~(inbuf.length / 2)
+ if (isGCM(cipher)) {
+ suite.setAAD(new Buffer(fixture.aad, 'hex'))
+ suite2.setAAD(new Buffer(fixture.aad, 'hex'))
+ suite.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
+ suite2.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
+ }
+ buf = Buffer.concat([buf, suite.update(inbuf.slice(0, mid))])
+ buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(0, mid))])
+
+ t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'intermediate')
+ buf = Buffer.concat([buf, suite.update(inbuf.slice(mid))])
+ buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(mid))])
+ t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'intermediate 2')
+ buf = Buffer.concat([buf, suite.final()])
+ buf2 = Buffer.concat([buf2, suite2.final()])
+ t.equals(buf.toString('utf8'), fixture.text)
+ t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'final')
})
})
})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browserify-aes.git
More information about the Pkg-javascript-commits
mailing list