| 1 |
package jwk |
| 2 |
|
| 3 |
import "github.com/urfave/cli" |
| 4 |
|
| 5 |
|
| 6 |
func Command() cli.Command { |
| 7 |
return cli.Command{ |
| 8 |
Name: "jwk", |
| 9 |
Usage: "create JWKs (JSON Web Keys) and manage JWK Key Sets", |
| 10 |
UsageText: "step crypto jwk <subcommand> [arguments] [global-flags] [subcommand-flags]", |
| 11 |
Description: `The **step crypto jwk** command group provides facilities for creating JWKs |
| 12 |
(JSON Web Keys) as defined in RFC7517. It also includes command line utilities |
| 13 |
for managing Key Sets and working with encrypted keys. |
| 14 |
|
| 15 |
A JWK is a JSON data structure that represents a cryptographic key. The |
| 16 |
members of this data structure represent properties of the key, including its |
| 17 |
value. A JWK Set is a simple data structure for representing a set of JWKs. A |
| 18 |
JWK Set is a JSON object with a "keys" member whose value is an array of JWKs. |
| 19 |
Cryptographic algorithms and identifiers for used by JWKs are defined by the |
| 20 |
JSON Web Algorithms (JWA) specification in RFC7518. This tool also supports |
| 21 |
extensions defined in standards track RFC8037 defining curve and algorithm |
| 22 |
identifiers for Edwards-curve Digial Signatures. |
| 23 |
|
| 24 |
JWKs and JWK Sets are used in the JSON Web Signature (JWS; RFC7515) and JSON |
| 25 |
Web Encryption (JWE; RFC7516) specifications for signing and encrypting JSON |
| 26 |
data, respectively. |
| 27 |
|
| 28 |
## EXAMPLES |
| 29 |
|
| 30 |
Create a JWK using the default parameters (NIST P-256 curve): |
| 31 |
''' |
| 32 |
$ step crypto jwk create pub.json priv.json |
| 33 |
''' |
| 34 |
|
| 35 |
Add the previous public keys to a JWK Set (JWKS): |
| 36 |
''' |
| 37 |
$ cat pub.json | step crypto jwk keyset add ks.json |
| 38 |
''' |
| 39 |
|
| 40 |
List the keys in a JWKS: |
| 41 |
''' |
| 42 |
$ step crypto jwk keyset list ks.json |
| 43 |
ZI9Ku2jJQL84ewxVn8C_67iDaTN_DFTXE9Gypo6-3YE |
| 44 |
L38TOXsig8h6FeBOos03nFy6iXmwusFcIBBB0ZilahY |
| 45 |
''' |
| 46 |
|
| 47 |
Remove a JWK from a JWKS: |
| 48 |
''' |
| 49 |
$ step crypto jwk keyset remove ks.json --kid ZI9Ku2jJQL84ewxVn8C_67iDaTN_DFTXE9Gypo6-3YE |
| 50 |
|
| 51 |
$ step crypto jwk keyset list ks.json |
| 52 |
L38TOXsig8h6FeBOos03nFy6iXmwusFcIBBB0ZilahY |
| 53 |
''' |
| 54 |
|
| 55 |
Extract a JWK from a JWKS: |
| 56 |
''' |
| 57 |
$ step crypto jwk keyset find ks.json --kid L38TOXsig8h6FeBOos03nFy6iXmwusFcIBBB0ZilahY |
| 58 |
{ |
| 59 |
"use": "sig", |
| 60 |
"kty": "EC", |
| 61 |
"kid": "L38TOXsig8h6FeBOos03nFy6iXmwusFcIBBB0ZilahY", |
| 62 |
"crv": "P-256", |
| 63 |
"alg": "ES256", |
| 64 |
"x": "n_vvepi2bAby8LhsmY396msumgs4EQGoNNzar6wtyAc", |
| 65 |
"y": "hDRyGFO3M0-4_4MReiwbwXvh6XL3PMh4BAPu0qnTItM" |
| 66 |
} |
| 67 |
''' |
| 68 |
|
| 69 |
See the public version of a private JWK: |
| 70 |
''' |
| 71 |
$ cat priv.json | step crypto jwk public |
| 72 |
{ |
| 73 |
"use": "sig", |
| 74 |
"kty": "EC", |
| 75 |
"kid": "L38TOXsig8h6FeBOos03nFy6iXmwusFcIBBB0ZilahY", |
| 76 |
"crv": "P-256", |
| 77 |
"alg": "ES256", |
| 78 |
"x": "n_vvepi2bAby8LhsmY396msumgs4EQGoNNzar6wtyAc", |
| 79 |
"y": "hDRyGFO3M0-4_4MReiwbwXvh6XL3PMh4BAPu0qnTItM" |
| 80 |
} |
| 81 |
''' |
| 82 |
|
| 83 |
Create a JWK Thumbprint for a JWK: |
| 84 |
''' |
| 85 |
$ cat priv.json | step crypto jwk thumbprint |
| 86 |
L38TOXsig8h6FeBOos03nFy6iXmwusFcIBBB0ZilahY |
| 87 |
'''`, |
| 88 |
Subcommands: cli.Commands{ |
| 89 |
createCommand(), |
| 90 |
keysetCommand(), |
| 91 |
publicCommand(), |
| 92 |
thumbprintCommand(), |
| 93 |
}, |
| 94 |
} |
| 95 |
} |