|
1 | 1 | var test = require('tape') |
2 | 2 | var crypto = require('browserify-cipher/browser') |
3 | | -var randomBytes = require('randombytes') |
| 3 | +var randomBytes = require('pseudorandombytes') |
4 | 4 |
|
5 | | -crypto.listCiphers().forEach(function (cipher) { |
6 | | - test('ciphers: ' + cipher, function (t) { |
7 | | - t.plan(1) |
8 | | - var data = randomBytes(562) |
9 | | - var password = randomBytes(20) |
10 | | - var crypter = crypto.createCipher(cipher, password) |
11 | | - var decrypter = crypto.createDecipher(cipher, password) |
12 | | - var out = [] |
13 | | - out.push(decrypter.update(crypter.update(data))) |
14 | | - out.push(decrypter.update(crypter.final())) |
15 | | - if (cipher.indexOf('gcm') > -1) { |
16 | | - decrypter.setAuthTag(crypter.getAuthTag()) |
17 | | - } |
18 | | - out.push(decrypter.final()) |
19 | | - t.equals(data.toString('hex'), Buffer.concat(out).toString('hex')) |
| 5 | +function runIt (i) { |
| 6 | + crypto.listCiphers().forEach(function (cipher) { |
| 7 | + test('run: ' + i, function (t) { |
| 8 | + t.test('ciphers: ' + cipher, function (t) { |
| 9 | + t.plan(1) |
| 10 | + var data = randomBytes(562) |
| 11 | + var password = randomBytes(20) |
| 12 | + var crypter = crypto.createCipher(cipher, password) |
| 13 | + var decrypter = crypto.createDecipher(cipher, password) |
| 14 | + var out = [] |
| 15 | + out.push(decrypter.update(crypter.update(data))) |
| 16 | + out.push(decrypter.update(crypter.final())) |
| 17 | + if (cipher.indexOf('gcm') > -1) { |
| 18 | + decrypter.setAuthTag(crypter.getAuthTag()) |
| 19 | + } |
| 20 | + out.push(decrypter.final()) |
| 21 | + t.equals(data.toString('hex'), Buffer.concat(out).toString('hex')) |
| 22 | + }) |
| 23 | + }) |
20 | 24 | }) |
21 | | -}) |
22 | | - |
| 25 | + if (i < 4) { |
| 26 | + setTimeout(runIt, 0, i + 1) |
| 27 | + } |
| 28 | +} |
| 29 | +runIt(1) |
23 | 30 | test('getCiphers', function (t) { |
24 | 31 | t.plan(1) |
25 | 32 | t.ok(crypto.getCiphers().length, 'get ciphers returns an array') |
|
0 commit comments