Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80552 views
1
var test = require('tape')
2
var fixtures = require('./fixtures.json')
3
var _crypto = require('crypto')
4
var crypto = require('../browser.js')
5
var modes = require('../modes')
6
var types = Object.keys(modes)
7
var ebtk = require('../EVP_BytesToKey')
8
function isGCM (cipher) {
9
return modes[cipher].mode === 'GCM'
10
}
11
function isNode10 () {
12
return process.version && process.version.split('.').length === 3 && parseInt(process.version.split('.')[1], 10) <= 10
13
}
14
fixtures.forEach(function (fixture, i) {
15
// var ciphers = fixture.results.ciphers = {}
16
types.forEach(function (cipher) {
17
if (isGCM(cipher)) {
18
return
19
}
20
test('fixture ' + i + ' ' + cipher, function (t) {
21
t.plan(1)
22
var suite = crypto.createCipher(cipher, new Buffer(fixture.password))
23
var buf = new Buffer('')
24
suite.on('data', function (d) {
25
buf = Buffer.concat([buf, d])
26
})
27
suite.on('error', function (e) {
28
console.log(e)
29
})
30
suite.on('end', function () {
31
// console.log(fixture.text)
32
// decriptNoPadding(cipher, new Buffer(fixture.password), buf.toString('hex'), 'a')
33
// decriptNoPadding(cipher, new Buffer(fixture.password), fixture.results.ciphers[cipher], 'b')
34
t.equals(buf.toString('hex'), fixture.results.ciphers[cipher])
35
})
36
suite.write(new Buffer(fixture.text))
37
suite.end()
38
})
39
test('fixture ' + i + ' ' + cipher + '-legacy', function (t) {
40
t.plan(3)
41
var suite = crypto.createCipher(cipher, new Buffer(fixture.password))
42
var buf = new Buffer('')
43
var suite2 = _crypto.createCipher(cipher, new Buffer(fixture.password))
44
var buf2 = new Buffer('')
45
var inbuf = new Buffer(fixture.text)
46
var mid = ~~(inbuf.length / 2)
47
buf = Buffer.concat([buf, suite.update(inbuf.slice(0, mid))])
48
buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(0, mid))])
49
t.equals(buf.toString('hex'), buf2.toString('hex'), 'intermediate')
50
buf = Buffer.concat([buf, suite.update(inbuf.slice(mid))])
51
buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(mid))])
52
t.equals(buf.toString('hex'), buf2.toString('hex'), 'intermediate 2')
53
buf = Buffer.concat([buf, suite.final()])
54
buf2 = Buffer.concat([buf2, suite2.final()])
55
t.equals(buf.toString('hex'), buf2.toString('hex'), 'final')
56
})
57
test('fixture ' + i + ' ' + cipher + '-decrypt', function (t) {
58
t.plan(1)
59
var suite = crypto.createDecipher(cipher, new Buffer(fixture.password))
60
var buf = new Buffer('')
61
suite.on('data', function (d) {
62
buf = Buffer.concat([buf, d])
63
})
64
suite.on('error', function (e) {
65
console.log(e)
66
})
67
suite.on('end', function () {
68
// console.log(fixture.text)
69
// decriptNoPadding(cipher, new Buffer(fixture.password), buf.toString('hex'), 'a')
70
// decriptNoPadding(cipher, new Buffer(fixture.password), fixture.results.ciphers[cipher], 'b')
71
t.equals(buf.toString('utf8'), fixture.text)
72
})
73
suite.write(new Buffer(fixture.results.ciphers[cipher], 'hex'))
74
suite.end()
75
})
76
test('fixture ' + i + ' ' + cipher + '-decrypt-legacy', function (t) {
77
t.plan(4)
78
var suite = crypto.createDecipher(cipher, new Buffer(fixture.password))
79
var buf = new Buffer('')
80
var suite2 = _crypto.createDecipher(cipher, new Buffer(fixture.password))
81
var buf2 = new Buffer('')
82
var inbuf = new Buffer(fixture.results.ciphers[cipher], 'hex')
83
var mid = ~~(inbuf.length / 2)
84
buf = Buffer.concat([buf, suite.update(inbuf.slice(0, mid))])
85
buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(0, mid))])
86
t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'intermediate')
87
buf = Buffer.concat([buf, suite.update(inbuf.slice(mid))])
88
buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(mid))])
89
t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'intermediate 2')
90
buf = Buffer.concat([buf, suite.final()])
91
buf2 = Buffer.concat([buf2, suite2.final()])
92
t.equals(buf.toString('utf8'), fixture.text)
93
t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'final')
94
})
95
})
96
types.forEach(function (cipher) {
97
if (modes[cipher].mode === 'ECB') {
98
return
99
}
100
if (isGCM(cipher) && isNode10()) {
101
return
102
}
103
test('fixture ' + i + ' ' + cipher + '-iv', function (t) {
104
if (isGCM(cipher)) {
105
t.plan(4)
106
} else {
107
t.plan(2)
108
}
109
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')))
110
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')))
111
var buf = new Buffer('')
112
var buf2 = new Buffer('')
113
suite.on('data', function (d) {
114
buf = Buffer.concat([buf, d])
115
})
116
suite.on('error', function (e) {
117
console.log(e)
118
})
119
suite2.on('data', function (d) {
120
buf2 = Buffer.concat([buf2, d])
121
})
122
suite2.on('error', function (e) {
123
console.log(e)
124
})
125
suite.on('end', function () {
126
t.equals(buf.toString('hex'), fixture.results.cipherivs[cipher], 'vs fixture')
127
t.equals(buf.toString('hex'), buf2.toString('hex'), 'vs node')
128
if (isGCM(cipher)) {
129
t.equals(suite.getAuthTag().toString('hex'), fixture.authtag[cipher], 'authtag vs fixture')
130
t.equals(suite.getAuthTag().toString('hex'), suite2.getAuthTag().toString('hex'), 'authtag vs node')
131
}
132
})
133
if (isGCM(cipher)) {
134
suite.setAAD(new Buffer(fixture.aad, 'hex'))
135
suite2.setAAD(new Buffer(fixture.aad, 'hex'))
136
}
137
suite2.write(new Buffer(fixture.text))
138
suite2.end()
139
suite.write(new Buffer(fixture.text))
140
suite.end()
141
})
142
143
test('fixture ' + i + ' ' + cipher + '-legacy-iv', function (t) {
144
if (isGCM(cipher)) {
145
t.plan(6)
146
} else {
147
t.plan(4)
148
}
149
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')))
150
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')))
151
var buf = new Buffer('')
152
var buf2 = new Buffer('')
153
var inbuf = new Buffer(fixture.text)
154
var mid = ~~(inbuf.length / 2)
155
if (isGCM(cipher)) {
156
suite.setAAD(new Buffer(fixture.aad, 'hex'))
157
suite2.setAAD(new Buffer(fixture.aad, 'hex'))
158
}
159
buf = Buffer.concat([buf, suite.update(inbuf.slice(0, mid))])
160
buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(0, mid))])
161
t.equals(buf.toString('hex'), buf2.toString('hex'), 'intermediate')
162
buf = Buffer.concat([buf, suite.update(inbuf.slice(mid))])
163
buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(mid))])
164
t.equals(buf.toString('hex'), buf2.toString('hex'), 'intermediate 2')
165
buf = Buffer.concat([buf, suite.final()])
166
buf2 = Buffer.concat([buf2, suite2.final()])
167
t.equals(buf.toString('hex'), fixture.results.cipherivs[cipher])
168
t.equals(buf.toString('hex'), buf2.toString('hex'), 'final')
169
if (isGCM(cipher)) {
170
t.equals(suite.getAuthTag().toString('hex'), fixture.authtag[cipher], 'authtag vs fixture')
171
t.equals(suite.getAuthTag().toString('hex'), suite2.getAuthTag().toString('hex'), 'authtag vs node')
172
}
173
})
174
test('fixture ' + i + ' ' + cipher + '-iv-decrypt', function (t) {
175
t.plan(2)
176
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')))
177
var buf = new Buffer('')
178
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')))
179
var buf2 = new Buffer('')
180
suite.on('data', function (d) {
181
buf = Buffer.concat([buf, d])
182
})
183
suite.on('error', function (e) {
184
t.notOk(e)
185
})
186
suite2.on('data', function (d) {
187
buf2 = Buffer.concat([buf2, d])
188
})
189
suite2.on('error', function (e) {
190
t.notOk(e)
191
})
192
suite.on('end', function () {
193
t.equals(buf.toString('utf8'), fixture.text, 'correct text vs fixture')
194
t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'correct text vs node')
195
})
196
if (isGCM(cipher)) {
197
suite.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
198
suite2.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
199
suite.setAAD(new Buffer(fixture.aad, 'hex'))
200
suite2.setAAD(new Buffer(fixture.aad, 'hex'))
201
}
202
203
suite2.write(new Buffer(fixture.results.cipherivs[cipher], 'hex'))
204
suite.write(new Buffer(fixture.results.cipherivs[cipher], 'hex'))
205
suite2.end()
206
suite.end()
207
})
208
test('fixture ' + i + ' ' + cipher + '-decrypt-legacy', function (t) {
209
t.plan(4)
210
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')))
211
var buf = new Buffer('')
212
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')))
213
var buf2 = new Buffer('')
214
var inbuf = new Buffer(fixture.results.cipherivs[cipher], 'hex')
215
var mid = ~~(inbuf.length / 2)
216
if (isGCM(cipher)) {
217
suite.setAAD(new Buffer(fixture.aad, 'hex'))
218
suite2.setAAD(new Buffer(fixture.aad, 'hex'))
219
suite.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
220
suite2.setAuthTag(new Buffer(fixture.authtag[cipher], 'hex'))
221
}
222
buf = Buffer.concat([buf, suite.update(inbuf.slice(0, mid))])
223
buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(0, mid))])
224
225
t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'intermediate')
226
buf = Buffer.concat([buf, suite.update(inbuf.slice(mid))])
227
buf2 = Buffer.concat([buf2, suite2.update(inbuf.slice(mid))])
228
t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'intermediate 2')
229
buf = Buffer.concat([buf, suite.final()])
230
buf2 = Buffer.concat([buf2, suite2.final()])
231
t.equals(buf.toString('utf8'), fixture.text)
232
t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'final')
233
})
234
})
235
})
236
237
if (!isNode10()) {
238
test('node tests', function (t) {
239
var TEST_CASES = [
240
{ algo: 'aes-128-gcm', key: '6970787039613669314d623455536234',
241
iv: '583673497131313748307652', plain: 'Hello World!',
242
ct: '4BE13896F64DFA2C2D0F2C76',
243
tag: '272B422F62EB545EAA15B5FF84092447', tampered: false },
244
{ algo: 'aes-128-gcm', key: '6970787039613669314d623455536234',
245
iv: '583673497131313748307652', plain: 'Hello World!',
246
ct: '4BE13896F64DFA2C2D0F2C76', aad: '000000FF',
247
tag: 'BA2479F66275665A88CB7B15F43EB005', tampered: false },
248
{ algo: 'aes-128-gcm', key: '6970787039613669314d623455536234',
249
iv: '583673497131313748307652', plain: 'Hello World!',
250
ct: '4BE13596F64DFA2C2D0FAC76',
251
tag: '272B422F62EB545EAA15B5FF84092447', tampered: true },
252
{ algo: 'aes-256-gcm', key: '337a54767a7233703637564336316a6d56353472495975313534357834546c59',
253
iv: '36306950306836764a6f4561', plain: 'Hello node.js world!',
254
ct: '58E62CFE7B1D274111A82267EBB93866E72B6C2A',
255
tag: '9BB44F663BADABACAE9720881FB1EC7A', tampered: false },
256
{ algo: 'aes-256-gcm', key: '337a54767a7233703637564336316a6d56353472495975313534357834546c59',
257
iv: '36306950306836764a6f4561', plain: 'Hello node.js world!',
258
ct: '58E62CFF7B1D274011A82267EBB93866E72B6C2B',
259
tag: '9BB44F663BADABACAE9720881FB1EC7A', tampered: true },
260
{ algo: 'aes-192-gcm', key: '1ed2233fa2223ef5d7df08546049406c7305220bca40d4c9',
261
iv: '0e1791e9db3bd21a9122c416', plain: 'Hello node.js world!',
262
password: 'very bad password', aad: '63616c76696e',
263
ct: 'DDA53A4059AA17B88756984995F7BBA3C636CC44',
264
tag: 'D2A35E5C611E5E3D2258360241C5B045', tampered: false }
265
]
266
267
var ciphers = Object.keys(modes)
268
function testIt (i) {
269
t.test('test case ' + i, function (t) {
270
var test = TEST_CASES[i]
271
272
if (ciphers.indexOf(test.algo) === -1) {
273
console.log('skipping unsupported ' + test.algo + ' test')
274
return
275
}
276
277
(function () {
278
var encrypt = crypto.createCipheriv(test.algo,
279
new Buffer(test.key, 'hex'), new Buffer(test.iv, 'hex'))
280
if (test.aad) encrypt.setAAD(new Buffer(test.aad, 'hex'))
281
282
var hex = encrypt.update(test.plain, 'ascii', 'hex')
283
hex += encrypt.final('hex')
284
var auth_tag = encrypt.getAuthTag()
285
// only test basic encryption run if output is marked as tampered.
286
if (!test.tampered) {
287
t.equal(hex.toUpperCase(), test.ct)
288
t.equal(auth_tag.toString('hex').toUpperCase(), test.tag)
289
}
290
})()
291
;(function () {
292
var decrypt = crypto.createDecipheriv(test.algo,
293
new Buffer(test.key, 'hex'), new Buffer(test.iv, 'hex'))
294
decrypt.setAuthTag(new Buffer(test.tag, 'hex'))
295
if (test.aad) decrypt.setAAD(new Buffer(test.aad, 'hex'))
296
var msg = decrypt.update(test.ct, 'hex', 'ascii')
297
if (!test.tampered) {
298
msg += decrypt.final('ascii')
299
t.equal(msg, test.plain)
300
} else {
301
// assert that final throws if input data could not be verified!
302
t.throws(function () { decrypt.final('ascii') }, / auth/)
303
}
304
})()
305
;(function () {
306
if (!test.password) return
307
var encrypt = crypto.createCipher(test.algo, test.password)
308
if (test.aad) encrypt.setAAD(new Buffer(test.aad, 'hex'))
309
var hex = encrypt.update(test.plain, 'ascii', 'hex')
310
hex += encrypt.final('hex')
311
var auth_tag = encrypt.getAuthTag()
312
// only test basic encryption run if output is marked as tampered.
313
if (!test.tampered) {
314
t.equal(hex.toUpperCase(), test.ct)
315
t.equal(auth_tag.toString('hex').toUpperCase(), test.tag)
316
}
317
})()
318
;(function () {
319
if (!test.password) return
320
var decrypt = crypto.createDecipher(test.algo, test.password)
321
decrypt.setAuthTag(new Buffer(test.tag, 'hex'))
322
if (test.aad) decrypt.setAAD(new Buffer(test.aad, 'hex'))
323
var msg = decrypt.update(test.ct, 'hex', 'ascii')
324
if (!test.tampered) {
325
msg += decrypt.final('ascii')
326
t.equal(msg, test.plain)
327
} else {
328
// assert that final throws if input data could not be verified!
329
t.throws(function () { decrypt.final('ascii') }, / auth/)
330
}
331
})()
332
333
// after normal operation, test some incorrect ways of calling the API:
334
// it's most certainly enough to run these tests with one algorithm only.
335
336
if (i > 0) {
337
t.end()
338
return
339
}
340
341
(function () {
342
// non-authenticating mode:
343
var encrypt = crypto.createCipheriv('aes-128-cbc',
344
'ipxp9a6i1Mb4USb4', '6fKjEjR3Vl30EUYC')
345
encrypt.update('blah', 'ascii')
346
encrypt.final()
347
t.throws(function () { encrypt.getAuthTag() })
348
t.throws(function () {
349
encrypt.setAAD(new Buffer('123', 'ascii'))
350
})
351
})()
352
;(function () {
353
// trying to get tag before inputting all data:
354
var encrypt = crypto.createCipheriv(test.algo,
355
new Buffer(test.key, 'hex'), new Buffer(test.iv, 'hex'))
356
encrypt.update('blah', 'ascii')
357
t.throws(function () { encrypt.getAuthTag() }, / state/)
358
})()
359
;(function () {
360
// trying to set tag on encryption object:
361
var encrypt = crypto.createCipheriv(test.algo,
362
new Buffer(test.key, 'hex'), new Buffer(test.iv, 'hex'))
363
t.throws(function () {
364
encrypt.setAuthTag(new Buffer(test.tag, 'hex'))
365
}, / state/)
366
})()
367
;(function () {
368
// trying to read tag from decryption object:
369
var decrypt = crypto.createDecipheriv(test.algo,
370
new Buffer(test.key, 'hex'), new Buffer(test.iv, 'hex'))
371
t.throws(function () { decrypt.getAuthTag() }, / state/)
372
})()
373
t.end()
374
})
375
}
376
for (var i in TEST_CASES) {
377
testIt(i)
378
}
379
})
380
}
381
function corectPaddingWords (padding, result) {
382
test('correct padding ' + padding.toString('hex'), function (t) {
383
t.plan(1)
384
var block1 = new Buffer(16)
385
block1.fill(4)
386
result = block1.toString('hex') + result.toString('hex')
387
var cipher = _crypto.createCipher('aes128', new Buffer('password'))
388
cipher.setAutoPadding(false)
389
var decipher = crypto.createDecipher('aes128', new Buffer('password'))
390
var out = new Buffer('')
391
out = Buffer.concat([out, cipher.update(block1)])
392
out = Buffer.concat([out, cipher.update(padding)])
393
var deciphered = decipher.update(out)
394
deciphered = Buffer.concat([deciphered, decipher.final()])
395
t.equals(deciphered.toString('hex'), result)
396
})
397
}
398
399
var sixteens = new Buffer(16)
400
sixteens.fill(16)
401
corectPaddingWords(sixteens, new Buffer(''))
402
var fifteens = new Buffer(16)
403
fifteens.fill(15)
404
fifteens[0] = 5
405
corectPaddingWords(fifteens, new Buffer([5]))
406
var one = _crypto.randomBytes(16)
407
one[15] = 1
408
corectPaddingWords(one, one.slice(0, -1))
409
function incorectPaddingthrows (padding) {
410
test('incorrect padding ' + padding.toString('hex'), function (t) {
411
t.plan(2)
412
var block1 = new Buffer(16)
413
block1.fill(4)
414
var cipher = crypto.createCipher('aes128', new Buffer('password'))
415
cipher.setAutoPadding(false)
416
var decipher = crypto.createDecipher('aes128', new Buffer('password'))
417
var decipher2 = _crypto.createDecipher('aes128', new Buffer('password'))
418
var out = new Buffer('')
419
out = Buffer.concat([out, cipher.update(block1)])
420
out = Buffer.concat([out, cipher.update(padding)])
421
decipher.update(out)
422
decipher2.update(out)
423
t.throws(function () {
424
decipher.final()
425
}, 'mine')
426
t.throws(function () {
427
decipher2.final()
428
}, 'node')
429
})
430
}
431
function incorectPaddingDoesNotThrow (padding) {
432
test('stream incorrect padding ' + padding.toString('hex'), function (t) {
433
t.plan(2)
434
var block1 = new Buffer(16)
435
block1.fill(4)
436
var cipher = crypto.createCipher('aes128', new Buffer('password'))
437
cipher.setAutoPadding(false)
438
var decipher = crypto.createDecipher('aes128', new Buffer('password'))
439
var decipher2 = _crypto.createDecipher('aes128', new Buffer('password'))
440
cipher.pipe(decipher)
441
cipher.pipe(decipher2)
442
cipher.write(block1)
443
cipher.write(padding)
444
decipher.on('error', function (e) {
445
t.ok(e, 'mine')
446
})
447
decipher2.on('error', function (e) {
448
t.ok(e, 'node')
449
})
450
cipher.end()
451
})
452
}
453
var sixteens2 = new Buffer(16)
454
sixteens2.fill(16)
455
sixteens2[3] = 5
456
incorectPaddingthrows(sixteens2)
457
incorectPaddingDoesNotThrow(sixteens2)
458
var fifteens2 = new Buffer(16)
459
fifteens2.fill(15)
460
fifteens2[0] = 5
461
fifteens2[1] = 6
462
incorectPaddingthrows(fifteens2)
463
incorectPaddingDoesNotThrow(fifteens2)
464
var two = _crypto.randomBytes(16)
465
two[15] = 2
466
two[14] = 1
467
incorectPaddingthrows(two)
468
incorectPaddingDoesNotThrow(two)
469
test('autopadding false decipher', function (t) {
470
t.plan(2)
471
var mycipher = crypto.createCipher('AES-128-ECB', new Buffer('password'))
472
var nodecipher = _crypto.createCipher('AES-128-ECB', new Buffer('password'))
473
var myEnc = mycipher.final()
474
var nodeEnc = nodecipher.final()
475
t.equals(myEnc.toString('hex'), nodeEnc.toString('hex'), 'same encryption')
476
var decipher = crypto.createDecipher('aes-128-ecb', new Buffer('password'))
477
decipher.setAutoPadding(false)
478
var decipher2 = _crypto.createDecipher('aes-128-ecb', new Buffer('password'))
479
decipher2.setAutoPadding(false)
480
t.equals(decipher.update(myEnc).toString('hex'), decipher2.update(nodeEnc).toString('hex'), 'same decryption')
481
})
482
483
test('autopadding false cipher throws', function (t) {
484
t.plan(2)
485
var mycipher = crypto.createCipher('aes-128-ecb', new Buffer('password'))
486
mycipher.setAutoPadding(false)
487
var nodecipher = _crypto.createCipher('aes-128-ecb', new Buffer('password'))
488
nodecipher.setAutoPadding(false)
489
mycipher.update('foo')
490
nodecipher.update('foo')
491
t.throws(function () {
492
mycipher.final()
493
}, 'mine')
494
t.throws(function () {
495
nodecipher.final()
496
}, 'node')
497
})
498
499
test('getCiphers works', function (t) {
500
t.plan(1)
501
t.ok(crypto.getCiphers().length, 'get some ciphers')
502
})
503
504