| 1 | # JOSE CLI |
| 2 | |
| 3 | The `jose-util` command line utility allows for encryption, decryption, signing |
| 4 | and verification of JOSE messages. Its main purpose is to facilitate dealing |
| 5 | with JOSE messages when testing or debugging. |
| 6 | |
| 7 | ## Usage |
| 8 | |
| 9 | The utility includes the subcommands `encrypt`, `decrypt`, `sign`, `verify` and |
| 10 | `expand`. Examples for each command can be found below. |
| 11 | |
| 12 | Algorithms are selected via the `--alg` and `--enc` flags, which influence the |
| 13 | `alg` and `enc` headers in respectively. For JWE, `--alg` specifies the key |
| 14 | managment algorithm (e.g. `RSA-OAEP`) and `--enc` specifies the content |
| 15 | encryption algorithm (e.g. `A128GCM`). For JWS, `--alg` specifies the |
| 16 | signature algorithm (e.g. `PS256`). |
| 17 | |
| 18 | Input and output files can be specified via the `--in` and `--out` flags. |
| 19 | Either flag can be omitted, in which case `jose-util` uses stdin/stdout for |
| 20 | input/output respectively. By default each command will output a compact |
| 21 | message, but it's possible to get the full serialization by supplying the |
| 22 | `--full` flag. |
| 23 | |
| 24 | Keys are specified via the `--key` flag. Supported key types are naked RSA/EC |
| 25 | keys and X.509 certificates with embedded RSA/EC keys. Keys must be in PEM |
| 26 | or DER formats. |
| 27 | |
| 28 | ## Examples |
| 29 | |
| 30 | ### Encrypt |
| 31 | |
| 32 | Takes a plaintext as input, encrypts, and prints the encrypted message. |
| 33 | |
| 34 | echo 'test message' | jose-util encrypt --key public-key.pem --alg RSA-OAEP --enc A128GCM |
| 35 | |
| 36 | ### Decrypt |
| 37 | |
| 38 | Takes an encrypted message (JWE) as input, decrypts, and prints the plaintext. |
| 39 | |
| 40 | jose-util decrypt --key private-key.pem |
| 41 | |
| 42 | ### Sign |
| 43 | |
| 44 | Takes a payload as input, signs it, and prints the signed message with the embedded payload. |
| 45 | |
| 46 | jose-util sign --key private-key.pem --alg PS256 |
| 47 | |
| 48 | ### Verify |
| 49 | |
| 50 | Reads a signed message (JWS), verifies it, and extracts the payload. |
| 51 | |
| 52 | jose-util verify --key public-key.pem |
| 53 | |
| 54 | ### Expand |
| 55 | |
| 56 | Expands a compact message to the full serialization format. |
| 57 | |
| 58 | jose-util expand --format JWE # Expands a compact JWE to full format |
| 59 | jose-util expand --format JWS # Expands a compact JWS to full format |