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)
