diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 75d543420dea53..8e070688b1f250 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -25,8 +25,6 @@ test-worker-memory: PASS,FLAKY test-worker-message-port-transfer-terminate: PASS,FLAKY [$system==linux] -# https://github.com/nodejs/node/issues/35586 -test-webcrypto-encrypt-decrypt-aes: PASS,FLAKY [$system==macos] diff --git a/test/parallel/test-webcrypto-encrypt-decrypt-aes.js b/test/parallel/test-webcrypto-encrypt-decrypt-aes.js index 38d2b70bcb0567..7adb18918d2205 100644 --- a/test/parallel/test-webcrypto-encrypt-decrypt-aes.js +++ b/test/parallel/test-webcrypto-encrypt-decrypt-aes.js @@ -9,6 +9,9 @@ const assert = require('assert'); const { getRandomValues, subtle } = require('crypto').webcrypto; async function testEncrypt({ keyBuffer, algorithm, plaintext, result }) { + // Using a copy of plaintext to prevent tampering of the original + plaintext = Buffer.from(plaintext); + const key = await subtle.importKey( 'raw', keyBuffer, @@ -23,8 +26,10 @@ async function testEncrypt({ keyBuffer, algorithm, plaintext, result }) { Buffer.from(output).toString('hex'), Buffer.from(result).toString('hex')); - const check = await subtle.decrypt(algorithm, key, output); - output[0] = 255 - output[0]; + // Converting the returned ArrayBuffer into a Buffer right away, + // so that the next line works + const check = Buffer.from(await subtle.decrypt(algorithm, key, output)); + check[0] = 255 - check[0]; assert.strictEqual( Buffer.from(check).toString('hex'),