1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
From: Yadd <yadd@debian.org>
Date: mars, 09 2026 21:46:52 +0100
Subject: [PATCH] drop tests that call unexistent functions in Nodejs 22
Forwarded: not-needed
--- a/test/index.js
+++ b/test/index.js
@@ -40,25 +40,6 @@
suite.end()
})
- test('fixture ' + i + ' ' + cipher + '-legacy', function (t) {
- t.plan(3)
- var suite = crypto.createCipher(cipher, Buffer.from(f.password))
- var buf = Buffer.alloc(0)
- var suite2 = _crypto.createCipher(cipher, Buffer.from(f.password))
- var buf2 = Buffer.alloc(0)
- var inbuf = Buffer.from(f.text)
- var mid = ~~(inbuf.length / 2)
- 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'), buf2.toString('hex'), 'final')
- })
-
test('fixture ' + i + ' ' + cipher + '-decrypt', function (t) {
t.plan(1)
var suite = crypto.createDecipher(cipher, Buffer.from(f.password))
@@ -78,26 +59,6 @@
suite.write(Buffer.from(f.results.ciphers[cipher], 'hex'))
suite.end()
})
-
- test('fixture ' + i + ' ' + cipher + '-decrypt-legacy', function (t) {
- t.plan(4)
- var suite = crypto.createDecipher(cipher, Buffer.from(f.password))
- var buf = Buffer.alloc(0)
- var suite2 = _crypto.createDecipher(cipher, Buffer.from(f.password))
- var buf2 = Buffer.alloc(0)
- var inbuf = Buffer.from(f.results.ciphers[cipher], 'hex')
- var mid = ~~(inbuf.length / 2)
- 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'), f.text)
- t.equals(buf.toString('utf8'), buf2.toString('utf8'), 'final')
- })
})
CIPHERS.forEach(function (cipher) {
@@ -361,44 +322,13 @@
})
})
-test('autopadding false decipher', function (t) {
- t.plan(2)
- var mycipher = crypto.createCipher('AES-128-ECB', Buffer.from('password'))
- var nodecipher = _crypto.createCipher('AES-128-ECB', Buffer.from('password'))
- var myEnc = mycipher.final()
- var nodeEnc = nodecipher.final()
- t.equals(myEnc.toString('hex'), nodeEnc.toString('hex'), 'same encryption')
- var decipher = crypto.createDecipher('aes-128-ecb', Buffer.from('password'))
- decipher.setAutoPadding(false)
- var decipher2 = _crypto.createDecipher('aes-128-ecb', Buffer.from('password'))
- decipher2.setAutoPadding(false)
- t.equals(decipher.update(myEnc).toString('hex'), decipher2.update(nodeEnc).toString('hex'), 'same decryption')
-})
-
-test('autopadding false cipher throws', function (t) {
- t.plan(2)
-
- var mycipher = crypto.createCipher('aes-128-ecb', Buffer.from('password'))
- mycipher.setAutoPadding(false)
- var nodecipher = _crypto.createCipher('aes-128-ecb', Buffer.from('password'))
- nodecipher.setAutoPadding(false)
- mycipher.update('foo')
- nodecipher.update('foo')
- t.throws(function () {
- mycipher.final()
- }, /data not multiple of block length/)
- t.throws(function () {
- nodecipher.final()
- }, /./)
-})
-
test('getCiphers works', function (t) {
t.plan(1)
t.ok(crypto.getCiphers().length, 'get some ciphers')
})
test('correctly handle incremental base64 output', function (t) {
- t.plan(2)
+ t.plan(1)
var encoding = 'base64'
function encrypt (data, key, algorithm) {
@@ -426,7 +356,6 @@
var key = 'this is a very secure key'
var data = 'The quick brown fox jumps over the lazy dog.'
var encrypted = encrypt(data, key)
- t.equals(encrypted, encryptNode(data, key), 'encrypt correctly')
var decrypted = decrypt(encrypted, key)
t.equals(data, decrypted, 'round trips')
})
@@ -517,63 +446,36 @@
})
})
-function corectPaddingWords (padding, result) {
- test('correct padding ' + padding.toString('hex'), function (t) {
- t.plan(1)
- var block1 = Buffer.alloc(16, 4)
- result = block1.toString('hex') + result.toString('hex')
- var cipher = _crypto.createCipher('aes128', Buffer.from('password'))
- cipher.setAutoPadding(false)
- var decipher = crypto.createDecipher('aes128', Buffer.from('password'))
- var out = Buffer.alloc(0)
- out = Buffer.concat([out, cipher.update(block1)])
- out = Buffer.concat([out, cipher.update(padding)])
- var deciphered = decipher.update(out)
- deciphered = Buffer.concat([deciphered, decipher.final()])
- t.equals(deciphered.toString('hex'), result)
- })
-}
-
function incorectPaddingthrows (padding) {
test('incorrect padding ' + padding.toString('hex'), function (t) {
- t.plan(2)
+ t.plan(1)
var block1 = Buffer.alloc(16, 4)
var cipher = crypto.createCipher('aes128', Buffer.from('password'))
cipher.setAutoPadding(false)
var decipher = crypto.createDecipher('aes128', Buffer.from('password'))
- var decipher2 = _crypto.createDecipher('aes128', Buffer.from('password'))
var out = Buffer.alloc(0)
out = Buffer.concat([out, cipher.update(block1)])
out = Buffer.concat([out, cipher.update(padding)])
decipher.update(out)
- decipher2.update(out)
t.throws(function () {
decipher.final()
}, 'mine')
- t.throws(function () {
- decipher2.final()
- }, 'node')
})
}
function incorectPaddingDoesNotThrow (padding) {
test('stream incorrect padding ' + padding.toString('hex'), function (t) {
- t.plan(2)
+ t.plan(1)
var block1 = Buffer.alloc(16, 4)
var cipher = crypto.createCipher('aes128', Buffer.from('password'))
cipher.setAutoPadding(false)
var decipher = crypto.createDecipher('aes128', Buffer.from('password'))
- var decipher2 = _crypto.createDecipher('aes128', Buffer.from('password'))
cipher.pipe(decipher)
- cipher.pipe(decipher2)
cipher.write(block1)
cipher.write(padding)
decipher.on('error', function (e) {
t.ok(e, 'mine')
})
- decipher2.on('error', function (e) {
- t.ok(e, 'node')
- })
cipher.end()
})
}
@@ -595,9 +497,6 @@
var seventeens = Buffer.alloc(16, 17)
var ff = Buffer.alloc(16, 0xff)
-corectPaddingWords(sixteens, Buffer.alloc(0))
-corectPaddingWords(fifteens, Buffer.from([5]))
-corectPaddingWords(one, one.slice(0, -1))
;[sixteens2, fifteens2, two, zeroes, seventeens, ff].forEach((x) => {
incorectPaddingthrows(x)
incorectPaddingDoesNotThrow(x)
|