ecfg 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0549b12acc4a5455eab8b0ea68f6842f60db304d
4
- data.tar.gz: e801695b9fd88dd4c2067ccac42b13da7aa15b33
3
+ metadata.gz: b986cd82f884b0230545deaa4e4b0fbc218780d1
4
+ data.tar.gz: 65e45874b83331398fe014724d139e90486eac94
5
5
  SHA512:
6
- metadata.gz: 43c148d8d42d3e540de16f4cc50d860e90c692cad41b7e10dd1a73873a005315ffdc11f0cbe4c5e659c467d835bf41bdab10e0714875465afc995d32242dd00a
7
- data.tar.gz: 6b94f754af12c0457ef1fc690c8c4b97b639a0b17fa774575844f078343c378f536b153ee7c5e5d089b1a55dcb52bde0d6e2c641dff0e6aa35d34c66831d9311
6
+ metadata.gz: c136457c14a125920ba2c000155e055d26f8cff2c43cd6fe5787d3d805ae5b61709b8d520c993489ae80195cc660cb32e9837d6826c1729a3b0658bf650af498
7
+ data.tar.gz: 41fed745f643d5c11a65a94cc0b1681fcbd22196bc4761bf684080021771da82eb437efce456e34de54aea236d5570956a0750a3734a40ac87d1a7b5e1561f98
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module Ecfg
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "ECFG\-DECRYPT" "1" "July 2016" "Shopify" "Version 0.3.0"
4
+ .TH "ECFG\-DECRYPT" "1" "July 2016" "Shopify" "Version 0.3.1"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBecfg\-decrypt\fR \- decrypt an ecfg file
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "ECFG\-ENCRYPT" "1" "July 2016" "Shopify" "Version 0.3.0"
4
+ .TH "ECFG\-ENCRYPT" "1" "July 2016" "Shopify" "Version 0.3.1"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBecfg\-encrypt\fR \- encrypt an ecfg file
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "ECFG\-KEYGEN" "1" "July 2016" "Shopify" "Version 0.3.0"
4
+ .TH "ECFG\-KEYGEN" "1" "July 2016" "Shopify" "Version 0.3.1"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBecfg\-keygen\fR \- generate a new keypair for use with ecfg
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "ECFG" "1" "July 2016" "Shopify" "Version 0.3.0"
4
+ .TH "ECFG" "1" "July 2016" "Shopify" "Version 0.3.1"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBecfg\fR \- manage application secrets via encrypted config
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "ECFG" "5" "July 2016" "Shopify" "Version 0.3.0"
4
+ .TH "ECFG" "5" "August 2016" "Shopify" "Version 0.3.1"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBecfg\fR \- JSON, YAML, or TOML file with asymmetric\-key\-encrypted values
@@ -13,7 +13,7 @@ An \fBecfg\fR file is syntactically a \fBjson\fR, \fByaml\fR, or \fBtoml\fR file
13
13
  Each \fBecfg\fR file must have a key at the top level named \fB_public_key\fR\. This implies that the top\-level structure must be a hashmap, not an array\.
14
14
  .
15
15
  .P
16
- The \fB_public_key\fR key must have a string value, which is a hex\-encoded 32\-byte (totalling 64 ASCII bytes) public key as generated by \fIecfg\-keygen\fR(1)\.
16
+ The \fB_public_key\fR key must have a string value, which is a hex\-encoded 32\-byte (totalling 64 ASCII bytes) public key as generated by ecfg\-keygen(1)\.
17
17
  .
18
18
  .P
19
19
  By convention, \fB_public_key\fR should be the first key in the file\.
@@ -25,7 +25,7 @@ A value is considered encryptable if:
25
25
  It is a string literal (numbers, true, false, null all remain unencrypted);
26
26
  .
27
27
  .IP "2." 4
28
- It is not an object key (ie\. not immediately followed by a ":");
28
+ It is not an object key (ie\. not immediately followed by a ":" in JSON, etc\.);
29
29
  .
30
30
  .IP "3." 4
31
31
  Its corresponding object key did not begin with an underscore ("_")\.
@@ -83,5 +83,111 @@ When a value is encrypted, it will be replaced by a relatively long string of th
83
83
  .
84
84
  .IP "" 0
85
85
  .
86
+ .SH "ENCRYPTION ALGORITHMS"
87
+ \fBecfg\fR values are encrypted using a Curve25519 x Salsa20 x Poly1305\-AES public\-key scheme\. This normally implies use of \fBNaCl\fR or \fBlibsodium\fR\.
88
+ .
89
+ .P
90
+ NaCl libraries generally take keys as a sequence of raw bytes, but they\'re embedded in ecfg files as hex\-encoded strings, so we need a routine to convert them:
91
+ .
92
+ .IP "" 4
93
+ .
94
+ .nf
95
+
96
+ base16_to_raw(key : string) \-> []byte =
97
+ # convert e\.g\. "1234beef" into [0x12, 0x34, 0xBE, 0xEF] or whatever
98
+ # the particular NaCl implementation/binding wants\.
99
+ .
100
+ .fi
101
+ .
102
+ .IP "" 0
103
+ .
104
+ .P
105
+ When we write the final encrypted message according to the \fBSECRET SCHEMA\fR section, we need to encode several sequences of raw bytes to base64, with newlines removed:
106
+ .
107
+ .IP "" 4
108
+ .
109
+ .nf
110
+
111
+ encode(raw : []byte) \-> string =
112
+ sub("\en", "", base64_encode(raw))
113
+ .
114
+ .fi
115
+ .
116
+ .IP "" 0
117
+ .
118
+ .P
119
+ Building the message given the ciphertext and other input parameters is just string concatenation:
120
+ .
121
+ .IP "" 4
122
+ .
123
+ .nf
124
+
125
+ format(pub : []byte, nonce : []byte, ct : []byte) \-> string =
126
+ "EJ[1:" + encode(pub) + ":" + encode(nonce) + ":" + encode(ct) + "]"
127
+ .
128
+ .fi
129
+ .
130
+ .IP "" 0
131
+ .
132
+ .P
133
+ During encryption, an ephemeral keypair is generated and the public key is embedded in the encrypted message\.
134
+ .
135
+ .P
136
+ The final encryption routine combines accepts a plaintext string and a hex\-encoded public key extracted from the input document, returning a formatted \fBecfg\fR message\. The NaCl API calls here are loosely paraphrased\.
137
+ .
138
+ .IP "" 4
139
+ .
140
+ .nf
141
+
142
+ encrypt(plaintext : string, peer_pub_hex : string) \-> string =
143
+ peer_pub = base16_to_raw(peer_pub_hex)
144
+
145
+ (ephemeral_pub, ephemeral_priv) = NACL\.crypto_box_keypair()
146
+
147
+ # 24 random bytes
148
+ nonce = NACL\.randombytes(NACL\.NONCE_BYTES)
149
+
150
+ # API here varies a lot depending on binding\.
151
+ ciphertext = NACL\.crypto_box(
152
+ plaintext,
153
+ ephemeral_priv, peer_pub, nonce
154
+ )
155
+
156
+ format(ephemeral_pub, nonce, ciphertext)
157
+ .
158
+ .fi
159
+ .
160
+ .IP "" 0
161
+ .
162
+ .P
163
+ If multiple values are being encrypted at once, a single ephemeral keypair may be reused\. It may make sense but is by no means necessary to use box precomputation if it\'s available\.
164
+ .
165
+ .SH "DECRYPTION ALGORITHMS"
166
+ To decrypt messages from a document, the caller must first retrieve the private key associated to the public key embedded in the document, then the message must be decomposed into the three encoded values\. This is just the inverse of the process from the encryption section above: remove the "EJ[]" enclosure; split the message on ":", check that the version is 1, then base64\-decode the remaining three components\.
167
+ .
168
+ .P
169
+ Given those three components (\fBpeer_pubkey\fR, \fBnonce\fR, and \fBciphertext\fR), the decryption routine looks like:
170
+ .
171
+ .IP "" 4
172
+ .
173
+ .nf
174
+
175
+ decrypt(
176
+ target_privkey : string,
177
+ peer_pubkey : []byte,
178
+ nonce : []byte,
179
+ ciphertext : []byte,
180
+ ) \-> string =
181
+ priv = base16_to_raw(target_privkey)
182
+
183
+ # like above, this API varies a lot by binding implementation\.
184
+ NACL\.crypto_box_open(
185
+ priv, peer_pubkey, nonce, ciphertext
186
+ )
187
+ .
188
+ .fi
189
+ .
190
+ .IP "" 0
191
+ .
86
192
  .SH "SEE ALSO"
87
193
  ecfg(1), ecfg\-encrypt(1), ecfg\-decrypt(1), ecfg\-keygen(1)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecfg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-19 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Secret management by encrypting values in a JSON or YAML file with a
14
14
  public/private keypair