@@ -14,6 +14,53 @@ import (
1414
1515var Version string
1616
17+ const USAGE = `Usage:
18+ age-plugin-sss --generate-recipient <YAML policy file>
19+ age-plugin-sss --generate-identity <YAML identities file>
20+ age-plugin-sss --inspect <encrypte file>
21+ echo <recipient or identity string> | age-plugin-sss --decode
22+
23+ Options:
24+ --generate-recipient <PATH> Generate an recipient from a YAML policy file.
25+ --generate-identity <PATH> Generate an identity from a YAML file.
26+ --inspect <PATH> Display the policy structure of an encrypted file.
27+ -x, --decode Decode recipient or identity from STDIN back to YAML.
28+ -v, --version Show the version.
29+ -h, --help Show this help message.
30+
31+ Examples:
32+
33+ (Encryption)
34+
35+ $ cat <<EOF > policy.yaml
36+ threshold: 2
37+ shares:
38+ - age1q4ser2a5lu7ylu76ld07g2mn58sx5tqmtagmrucpdgcvv6zzyfds6ajx7z
39+ - age1u9pucxxkr9fh37e65wxf9nzf49pusq4ud9thd2m9xw5dxscdzg8sagm0jk
40+ # deep nesting and t=1 are possible
41+ - threshold: 1
42+ shares:
43+ - age1qdwjfqukwc0e0p6yg8k392t22ewkfgy9nttrl3hqm0zcmsswcqsqtg3uyn
44+ - age13csecsv5298ww6q5ky9n02heumdjxnekkvr8v64azaq5c3ps299qxupkqz
45+ EOF
46+ $ age-plugin-sss --generate-recipient policy.yaml > recipient.txt
47+ $ echo 'secret' | age -R recipient.txt -o secret.enc
48+
49+
50+ (Decryption)
51+
52+ $ cat <<EOF > identity.yaml
53+ # list of enough (not all) identities to meet the root threshold
54+ identities:
55+ - AGE-SECRET-KEY-1E7T...
56+ # you can pin the identity to a specific share id (identifies the matching recipient node/leaf)
57+ # share ids are shown when using the --inspect flag on an encrypted file
58+ - share_id: 3
59+ identity: AGE-SECRET-KEY-1E7T
60+ EOF
61+ $ age-plugin-sss --generate-identity identity.yaml > identity.txt
62+ $ age -d -i identity.txt secret.enc`
63+
1764func main () {
1865 var (
1966 pluginFlag string
@@ -25,14 +72,16 @@ func main() {
2572 versionFlag bool
2673 )
2774
28- flag .StringVar (& pluginFlag , "age-plugin" , "" , "Used by age for interacting with the plugin." )
29- flag .StringVar (& inspectFlag , "inspect" , "" , "Display the policy structure of `ENCRYPTED_FILE`." )
30- flag .StringVar (& generateRecipientFlag , "generate-recipient" , "" , "Generate a recipient from a YAML policy stored in `FILE`." )
31- flag .StringVar (& generateIdentityFlag , "generate-identity" , "" , "Generate an identity from a YAML policy stored in `FILE`." )
32- flag .BoolVar (& decodeFlag , "decode" , false , "Decode recipient or identity from STDIN back to YAML." )
33- flag .BoolVar (& versionFlag , "v" , false , "Show the version." )
34- flag .BoolVar (& helpFlag , "h" , false , "Show this help message." )
35- flag .BoolVar (& helpFlag , "help" , false , "Show this help message." )
75+ flag .Usage = func () { fmt .Fprintf (os .Stderr , "%s\n " , USAGE ) }
76+ flag .StringVar (& pluginFlag , "age-plugin" , "" , "" )
77+ flag .StringVar (& inspectFlag , "inspect" , "" , "" )
78+ flag .StringVar (& generateRecipientFlag , "generate-recipient" , "" , "" )
79+ flag .StringVar (& generateIdentityFlag , "generate-identity" , "" , "" )
80+ flag .BoolVar (& decodeFlag , "x" , false , "" )
81+ flag .BoolVar (& decodeFlag , "decode" , false , "" )
82+ flag .BoolVar (& versionFlag , "v" , false , "" )
83+ flag .BoolVar (& helpFlag , "h" , false , "" )
84+ flag .BoolVar (& helpFlag , "help" , false , "" )
3685
3786 flag .Parse ()
3887
0 commit comments