% JWE-DECRYPT(1) jwe-decrypt User Manual | LibJWT C Library

NAME

jwe-decrypt - Decrypt and authenticate a JSON Web Encryption (JWE) token

SYNOPSIS

| jwe-decrypt -k KEY -a ALG -e ENC [options] [TOKEN]

DESCRIPTION

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 is given as the single argument or, with no argument, read as the whole of standard input. When it is read from standard input, one trailing newline is removed, and a NUL byte anywhere in the input is an error, as are empty input and a read error. A Compact token must be on one line: a second token, or a token split across lines, is an error rather than being joined. A JSON token may span lines. On success the decrypted plaintext is written to standard output. On any failure the program prints an error and exits non-zero.

OPTIONS

-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.

NOTES

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.

SEE ALSO

jwe-encrypt(1), key2jwk(1), jwt-verify(1)