gchq/CyberChef · error · OperationError

Unable to decrypt: authentication failed. The ciphertext, ke

Error message

Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.

What it means

Thrown by AsconDecrypt.run when JsAscon.decrypt raises any exception during AEAD decryption. Ascon-AEAD128 is an authenticated cipher: it computes and verifies a tag over the ciphertext and associated data, and a mismatch (wrong key, wrong/modified nonce, tampered ciphertext, or mismatched associated data) causes the library to throw rather than emit garbage. The catch collapses every internal failure into this single authentication-failure message, hiding the specific reason by design.

Source

Thrown at src/core/operations/AsconDecrypt.mjs:106

        const inputData = Utils.convertToByteArray(input, inputType);

        const keyUint8 = new Uint8Array(key);
        const nonceUint8 = new Uint8Array(nonce);
        const adUint8 = new Uint8Array(ad);
        const ciphertextUint8 = new Uint8Array(inputData);

        try {
            // Decrypt (returns Uint8Array containing plaintext)
            const plaintext = JsAscon.decrypt(keyUint8, nonceUint8, adUint8, ciphertextUint8);

            // Return in requested format
            if (outputType === "Hex") {
                return toHexFast(plaintext);
            } else {
                return Utils.arrayBufferToStr(Uint8Array.from(plaintext).buffer);
            }
        } catch (e) {
            throw new OperationError("Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.");
        }
    }

}

export default AsconDecrypt;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Verify the key and nonce exactly match those used to encrypt (both 16 bytes).
  2. Ensure the associated data (AD) argument is identical on encrypt and decrypt, including empty vs absent.
  3. Re-check that the full ciphertext including the authentication tag was copied without truncation.
  4. Treat this error as authoritative: do not retry with tweaked parameters hoping for output.

Example fix

// before - AD mismatch: encrypted with AD, decrypting without
chef.asconDecrypt(ct, { key, nonce, ad: "" });

// after - AD matches what was used at encryption
chef.asconDecrypt(ct, { key, nonce, ad: "header-v1" });
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const pt = chef.asconDecrypt(ct, { key, nonce, ad });
} catch (e) {
  if (e.message.includes("authentication failed")) {
    // expected on wrong key/nonce/ad/tampered ciphertext; do not retry blindly
    throw new Error("Ascon authentication failed: verify key, nonce, and AD");
  }
  throw e;
}

Prevention

When it happens

Trigger: Any of: wrong key, wrong nonce, wrong/missing associated data (AD), truncated ciphertext (tag missing), or a single bit flip in the ciphertext/tag from corruption or copy error.

Common situations: Decrypting with a key that does not match the encryption key; AD set on encrypt but omitted on decrypt (or vice versa); ciphertext copied incompletely (missing the trailing tag bytes); nonce mismatch between sides.

Understand the failure class

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/68a90f8de44fdf27. Report an issue: GitHub.