Debian Codegraph @

command/crypto/jws/jws.go

raw symbols SCIP
1 package jws
2
3 import "github.com/urfave/cli"
4
5 // Command returns the jwk subcommand.
6 func Command() cli.Command {
7 return cli.Command{
8 Name: "jws",
9 Usage: "sign and verify data using JSON Web Signature (JWS)",
10 UsageText: "step crypto jws <subcommand> [arguments] [global-flags] [subcommand-flags]",
11 Description: `JSON Web Signature (JWS) represents content secured with digital signatures or
12 Message Authentication Codes (MACs) using JSON-based data structures.
13
14 ## EXAMPLES
15
16 Create a signed JWS of a message using an Ed25519 private JWK (with line
17 breaks for display purposes only):
18 '''
19 $ echo -n message | step crypto jws sign --key ed25519.priv.json
20 eyJhbGciOiJFZERTQSIsImtpZCI6IjlxaVFZUFU3SHJTOXBYdXpYYzc1WGctMXc5c0JGM2lXVld2cDhieE5oc28ifQ
21 .
22 bWVzc2FnZQ
23 .
24 ZlJvznC3iE4zhwmnCL74UtHXEUs6pb62vf38GFBLbFMKnIFiOGpAFcNv3es-WvPHYfyIIClAjwCfe505gxz5BQ
25 '''
26
27 Verify and display the message using the public key:
28 '''
29 $ echo $TOKEN | step crypto jws verify --key ed25519.pub.json
30 message
31 '''
32
33 Verify and display a JSON representation of the token, the message is base64
34 encoded in the payload:
35 '''
36 $ echo $TOKEN | step crypto jws verify --key ed25519.pub.json --json
37 {
38 "header": {
39 "alg": "EdDSA",
40 "kid": "9qiQYPU7HrS9pXuzXc75Xg-1w9sBF3iWVWvp8bxNhso"
41 },
42 "payload": "bWVzc2FnZQ",
43 "signature": "ZlJvznC3iE4zhwmnCL74UtHXEUs6pb62vf38GFBLbFMKnIFiOGpAFcNv3es-WvPHYfyIIClAjwCfe505gxz5BQ"
44 }
45 '''
46
47 Inspect the content of the JWS without verifying it:
48 '''
49 $ echo $TOKEN | step crypto jws inspect --insecure
50 message
51
52 $ echo $TOKEN | step crypto jws inspect --insecure --json
53 {
54 "header": {
55 "alg": "EdDSA",
56 "kid": "9qiQYPU7HrS9pXuzXc75Xg-1w9sBF3iWVWvp8bxNhso"
57 },
58 "payload": "bWVzc2FnZQ",
59 "signature": "ZlJvznC3iE4zhwmnCL74UtHXEUs6pb62vf38GFBLbFMKnIFiOGpAFcNv3es-WvPHYfyIIClAjwCfe505gxz5BQ"
60 }
61 '''
62
63 Using a JSON message using an P-256 curve and adding the content type json:
64 '''
65 $ echo -n {"dns":"https://dns.example.com"} | step crypto jws sign --key p256.priv.json --cty json
66 eyJhbGciOiJFUzI1NiIsImN0eSI6Impzb24iLCJraWQiOiJWOTNBLVloN0JodzFXMkUwaWdGY2l2aUp6WDRQWFBzd29WZ3JpZWhtOUNvIn0
67 .
68 eyJkbnMiOiJodHRwczovL2Rucy5leGFtcGxlLmNvbSJ9
69 .
70 ZI8q75r3PCXeu-Tubw7bHiDGxloPpAHV2hNfEp9N4WM2r3Wsk5uFhAkBTVIqryPtxmAgfRHGnE3hj-3Dp9nZmA
71
72 $ echo $TOKEN | step crypto jws verify --key p256.pub.json
73 {"dns":"https://dns.example.com"}
74
75 $ echo $TOKEN | step crypto jws verify --key p256.pub.json --json
76 {
77 "header": {
78 "alg": "ES256",
79 "cty": "json",
80 "kid": "V93A-Yh7Bhw1W2E0igFciviJzX4PXPswoVgriehm9Co"
81 },
82 "payload": "eyJkbnMiOiJodHRwczovL2Rucy5leGFtcGxlLmNvbSJ9",
83 "signature": "ZI8q75r3PCXeu-Tubw7bHiDGxloPpAHV2hNfEp9N4WM2r3Wsk5uFhAkBTVIqryPtxmAgfRHGnE3hj-3Dp9nZmA"
84 }
85 '''`,
86 Subcommands: cli.Commands{
87 signCommand(),
88 inspectCommand(),
89 verifyCommand(),
90 },
91 }
92 }