% JWE-DECRYPT(1) jwe-decrypt User Manual | LibJWT C Library
jwe-decrypt - Decrypt and authenticate a JSON Web Encryption (JWE) token
| jwe-decrypt -k KEY -a ALG -e ENC [options] [TOKEN]
jwe-decrypt parses a JWE token, recovers the Content Encryption Key, and decrypts and authenticates the content. The serialization is detected automatically: a token beginning with { is parsed as a JSON Serialization (Flattened or General), otherwise as the Compact Serialization.
The key is supplied as a JSON Web Key with -k. The expected key management algorithm (-a) and content encryption algorithm (-e) act as an allow-list: a token whose header does not match the configured pair is rejected. This prevents a token from selecting an unexpected algorithm. For a General JSON token with several recipients, the recipient whose algorithm matches -a and whose key is -k is selected.
The token may be given as the final argument or, if omitted, read from standard input. On success the decrypted plaintext is written to standard output. On any failure the program prints an error and exits non-zero.
-h, --help : Show help and exit.
-k, --key=FILE : File containing the JSON Web Key used to recover the CEK. Required.
-a, --algorithm=ALG : The expected JWE key management algorithm. Required.
-e, --enc=ENC : The expected JWE content encryption algorithm. Required.
A failure to recover the CEK (a wrong key, bad RSA padding, or a corrupted wrapped key) is not distinguished from a failed content authentication tag: per RFC 7516, the decrypter substitutes a random CEK and fails uniformly at the tag, denying a padding oracle. A General JSON token in which no recipient matches the configured algorithm and key fails with the same generic error.
jwe-encrypt(1), key2jwk(1), jwt-verify(1)