-
Notifications
You must be signed in to change notification settings - Fork 300
Closed
Labels
Description
Version
v21.7.1
Platform
Darwin Egors-MacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:45:49 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6020 arm64
Subsystem
crypto
What steps will reproduce the bug?
I tried to decrypt the cipher text and i was wondering that i don't need to use Auth Tag which is mandatory in AES GCM.
You can run the code bellow:
import { createDecipheriv, randomBytes } from 'crypto'
const algorithm = 'aes-256-gcm'
const keyHex = '9b25a4b717d0c827c926565758b99b89a24f83c03a6a8319fb0fc809787ae929'
const ivHex = 'ded281917f01b9d5f0a5abce'
const key: Buffer = Buffer.from(keyHex, 'hex');
const iv: Buffer = Buffer.from(ivHex, 'hex');
// const encrypt = (text: string): string => {
// const cipher = createCipheriv(algorithm, key, iv)
// const start = cipher.update(text, 'utf8')
// const end = cipher.final()
// return Buffer.concat([ start, end]).toString('base64')
// }
// const encrypted = encrypt('testValue')
const encrypted = "njvgROnsKdsG" //testValue string in base64 encrypted by the key and iv above
console.log('encrypted ---- ', encrypted)
const decrypt = (encrypted: string): string => {
const buffer = Buffer.from(encrypted, 'base64')
const decipher = createDecipheriv(algorithm, key, iv)
const decrypted = Buffer.concat([decipher.update(buffer), decipher.final()])
return decrypted.toString('utf8')
}
const decrypted = decrypt(encrypted)
console.log('decrypted ---- ',decrypted)
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
Mac authentication error
What do you see instead?
successfully decrypted text
Additional information
No response