AES GCM decrypt Firefox error only: "DOMException: The operation failed for an operation-specific reason", Chromium OK though

Viewed 262

I followed former answers from Webcrypto AES-CBC Decrypt: Operation Error - The operation failed for an operation-specific reason and JavaScript AES encryption and decryption (Advanced Encryption Standard) and used:

iv = crypto.getRandomValues(new Uint8Array(16))
key = window.crypto.subtle.generateKey(
            {
                name: "AES-GCM",
                length: 256,
            },
            false,
            ["encrypt", "decrypt"]
        )

to generate the key and

Uint8ArrayEncrypted = window.crypto.subtle.encrypt(
        {name: "aes-gcm", iv: iv, tagLength: 128}, 
        key,
        Uint8ArrayVar)

to encrypt and

Uint8ArrayDecrypted = window.crypto.subtle.decrypt(
        {name: "aes-gcm", iv: iv, tagLength: 128}, 
        key,
        Uint8ArrayEncrypted)

to decrypt

On Chromium 83 (Ubuntu) and Firefox 88, I successfully generate the key, the iv and encrypt. And on Chromium, it simply also decrypts without problem.Uint8ArrayDecrypted is correct ArrayBuffer.

But FF throws the error "The operation failed for an operation-specific reason" and stop there. No Uint8ArrayDecrypted returned.

I didn't use tag, like in WebCrypto API: DOMException: The provided data is too small

Reading https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt, I don't see it uses tag.

Does Firefox need something else specific?

Why the error message is so "generic"? Which operation or specific reason? With an error so generic, I don't know where to look.

0 Answers
Related