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
- Verify the key and nonce exactly match those used to encrypt (both 16 bytes).
- Ensure the associated data (AD) argument is identical on encrypt and decrypt, including empty vs absent.
- Re-check that the full ciphertext including the authentication tag was copied without truncation.
- 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
- Transport key, nonce, and AD together with the ciphertext.
- Keep AD identical on encrypt and decrypt (empty vs absent matters).
- Copy the full ciphertext including the trailing tag.
- Treat auth failure as definitive; never surface partial plaintext.
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
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Invalid key length: ${key.length} bytes. Ascon-AEAD128 requ
- Invalid nonce length: ${nonce.length} bytes. Ascon-AEAD128
- Invalid key length: ${key.length} bytes. Ascon-AEAD128 requ
- Invalid nonce length: ${nonce.length} bytes. Ascon-AEAD128
- Invalid key length: ${keyArray.length} bytes. Ascon-Mac req
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/68a90f8de44fdf27.
Report an issue: GitHub.