Skip to content

Commit 3634429

Browse files
authored
Merge branch 'main' into NODE-5549
2 parents 1e4755e + 2323ca8 commit 3634429

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/integration/client-side-encryption/client_side_encryption.prose.14.decryption_events.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@ describe('14. Decryption Events', metadata, function () {
7575
keyId: keyId,
7676
algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
7777
});
78-
// Copy ``ciphertext`` into a variable named ``malformedCiphertext``.
79-
// Change the last byte to 0. This will produce an invalid HMAC tag.
78+
// Copy ``ciphertext`` into a variable named ``malformedCiphertext``. Change the
79+
// last byte to a different value. This will produce an invalid HMAC tag.
8080
const buffer = Buffer.from(cipherText.buffer);
81-
buffer.writeInt8(0, buffer.length - 1);
81+
const lastByte = buffer.readUInt8(buffer.length - 1);
82+
const replacementByte = lastByte === 0 ? 1 : 0;
83+
buffer.writeUInt8(replacementByte, buffer.length - 1);
8284
malformedCiphertext = new Binary(buffer, 6);
85+
8386
// Create a MongoClient named ``encryptedClient`` with these ``AutoEncryptionOpts``:
8487
// AutoEncryptionOpts {
8588
// keyVaultNamespace: "keyvault.datakeys";

0 commit comments

Comments
 (0)