sym 2.3.0 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -2
- data/README.md +106 -70
- data/Rakefile +3 -2
- data/bin/sym.completion +6 -2
- data/lib/sym.rb +28 -15
- data/lib/sym/app.rb +1 -3
- data/lib/sym/app/args.rb +5 -1
- data/lib/sym/app/cli.rb +54 -6
- data/lib/sym/app/cli_slop.rb +35 -23
- data/lib/sym/app/commands/base_command.rb +12 -19
- data/lib/sym/app/commands/bash_completion.rb +19 -3
- data/lib/sym/app/commands/decrypt.rb +1 -1
- data/lib/sym/app/commands/encrypt.rb +1 -1
- data/lib/sym/app/commands/generate_key.rb +7 -3
- data/lib/sym/app/commands/keychain_add_key.rb +7 -2
- data/lib/sym/app/commands/open_editor.rb +1 -1
- data/lib/sym/app/commands/password_protect_key.rb +9 -4
- data/lib/sym/app/commands/print_key.rb +3 -3
- data/lib/sym/app/commands/show_examples.rb +25 -17
- data/lib/sym/app/commands/show_help.rb +2 -2
- data/lib/sym/app/keychain.rb +5 -0
- data/lib/sym/app/output/base.rb +3 -7
- data/lib/sym/app/output/file.rb +0 -1
- data/lib/sym/app/output/noop.rb +2 -1
- data/lib/sym/app/password/providers.rb +4 -0
- data/lib/sym/app/password/providers/memcached_provider.rb +1 -1
- data/lib/sym/app/private_key/base64_decoder.rb +1 -0
- data/lib/sym/app/private_key/decryptor.rb +1 -0
- data/lib/sym/app/private_key/detector.rb +45 -26
- data/lib/sym/app/private_key/handler.rb +20 -25
- data/lib/sym/app/private_key/key_source_check.rb +89 -0
- data/lib/sym/application.rb +115 -33
- data/lib/sym/configuration.rb +1 -0
- data/lib/sym/constants.rb +24 -0
- data/lib/sym/data/decoder.rb +2 -1
- data/lib/sym/data/wrapper_struct.rb +1 -1
- data/lib/sym/extensions/stdlib.rb +1 -0
- data/lib/sym/version.rb +1 -1
- data/sym.gemspec +1 -1
- metadata +5 -4
- data/lib/sym/encrypted_file.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c1acdb6cfcceef2df7e797519901ebec2105abf
|
4
|
+
data.tar.gz: 207fef73284f1ed1cad87b2112dbd3bba6615ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2064567295f89592911ce4f3cc105a11ed679286bc3345a5743700d60ec5facd8895ab97f35eb5fb9eb1f5c5a640ec2e5973fcdefd2c8b419698bd117e8e3984
|
7
|
+
data.tar.gz: 8a55697cf80cfdde490558404ca3c52533798e1446b40226e40e66511b81e6f8c49e270309104302712bf7751ec5dccf77af84943681a868ecd3d0facaec9880
|
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,61 @@
|
|
2
2
|
|
3
3
|
## [HEAD](https://github.com/kigster/sym/tree/HEAD)
|
4
4
|
|
5
|
-
[Changes since the last tag](https://github.com/kigster/sym/compare/v2.
|
6
|
-
|
5
|
+
[Changes since the last tag](https://github.com/kigster/sym/compare/v2.3.0...HEAD)
|
6
|
+
|
7
|
+
## [v2.4.2](https://github.com/kigster/sym/tree/v2.4.2) (2017-02-28)
|
8
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.4.1...v2.4.2)
|
9
|
+
|
10
|
+
* Fixing BASH completion for sym to look for files after `--negate` and
|
11
|
+
to auto-complete long options as well.
|
12
|
+
|
13
|
+
## [v2.4.1](https://github.com/kigster/sym/tree/v2.4.1) (2017-02-28)
|
14
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.4.0...v2.4.1)
|
15
|
+
|
16
|
+
* Added new feature: `-n/--negate` to quickly encrypt/decrypt a file to/from *.enc extension; extension is configurable.
|
17
|
+
* Refactored `application.opts` to be a hash.
|
18
|
+
* Refactored and consolidate key sources via the `Detector` class.
|
19
|
+
* Split off `KeySourceCheck` into a separate entity
|
20
|
+
* Simplified `Sym::Application`
|
21
|
+
* Removed `OrderedHash`
|
22
|
+
* Added `key_source` to logging with `-D`
|
23
|
+
* New tests.
|
24
|
+
* Fixed command ordering bug.
|
25
|
+
* Better "default" file handing, only when no options are supplied.
|
26
|
+
|
27
|
+
## [v2.4.0](https://github.com/kigster/sym/tree/v2.4.0) (2017-02-27)
|
28
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.3.0...v2.4.0)
|
29
|
+
|
30
|
+
* CLI API changes:
|
31
|
+
* Version 2.4.0
|
32
|
+
* New behavior: `-k <value>` now attempts to read a file, environment, keychain or a string.
|
33
|
+
* Removed `--keyfile / -K` (-k now accepts file)
|
34
|
+
* Removed all `require_relative` occurances, replaced with `require`
|
35
|
+
* Adding support for the default key file, stored in `~/.sym.key` by default.
|
36
|
+
* Moved all constants to `Sym::Constants`
|
37
|
+
* Added ability to map legacy (deprecated) flags
|
38
|
+
* Auto-disabling color when STDOUT is not a tty
|
39
|
+
* Changed Password Cache flags:
|
40
|
+
* Replaced `-C` with `-c` (to enable cache)
|
41
|
+
* Replaced `-T` with `-u` for timeout
|
42
|
+
* Replaced `-P` with `-r` for provider
|
43
|
+
* Changed `-A` (trace) to `-T`
|
44
|
+
* Now adding password to the cache upon generation
|
45
|
+
* Adding `KeyChain.get` method
|
46
|
+
* Replacing private key `Detector` with `Reader`
|
47
|
+
* Adding logger
|
48
|
+
* Fixing handling of STDIN and STDOUT with pipes
|
49
|
+
* Deleting unused files
|
50
|
+
|
51
|
+
## [v2.3.0](https://github.com/kigster/sym/tree/v2.3.0) (2017-02-23)
|
52
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.2.1...v2.3.0)
|
53
|
+
|
54
|
+
* Improving output, especially as it pertains to error reporting
|
55
|
+
* Split encrypt_decrypt command into encrypt and decrypt
|
56
|
+
* Fix permissions before `rake build`
|
57
|
+
* Improve Yard Doc by moving `Kernel` and `Object` monkey-patching
|
58
|
+
into `lib/sym/extensions/stdlib.rb`
|
59
|
+
|
7
60
|
## [v2.2.1](https://github.com/kigster/sym/tree/v2.2.1) (2017-02-15)
|
8
61
|
[Full Changelog](https://github.com/kigster/sym/compare/v2.2.0...v2.2.1)
|
9
62
|
|
data/README.md
CHANGED
@@ -33,24 +33,40 @@ __Sym__ is a layer built on top of the [`OpenSSL`](https://www.openssl.org/) lib
|
|
33
33
|
|
34
34
|
This gem includes two primary components:
|
35
35
|
|
36
|
-
* [Ruby API](#
|
37
|
-
* [Rich command line interface CLI](#cli) with many additional features to streamline handling of encrypted data
|
36
|
+
* [Ruby API](#rubyapi) for enabling encryption/decryption of any data within any Ruby class, with extremely easy-to-use methods
|
37
|
+
* [Rich command line interface CLI](#cli) with many additional features to streamline handling of encrypted data.
|
38
38
|
|
39
39
|
_Symmetric Encryption_ simply means that we are using the same private key to encrypt and decrypt. In addition to the private key, the encryption uses an IV vector. The library completely hides `iv` generation from the user, and automatically generates a random `iv` per encryption.
|
40
40
|
|
41
|
+
|
42
|
+
### Massive Time Savers
|
43
|
+
|
44
|
+
So how does `sym` substantiate its claim that it *streamlines* the encryption process? I thought about it, and turns out there are quite a few reasons:
|
45
|
+
|
46
|
+
* By using Mac OS-X Keychain, `sym` offers a simple yet secure way of storing the key on a local machine, much more secure then storing it on a file system.
|
47
|
+
* By using a password cache (`-c`) via an in-memory provider such as `memcached` or `drb`, `sym` invocations take advantage of password cache, and only ask for a password once per a configurable time period.
|
48
|
+
* By using `SYM_ARGS` environment variable, where common flags can be saved.
|
49
|
+
* By reading a key from the default key source file `~/.sym.key` which requires no flags at all.
|
50
|
+
* By utilizing the `--negate` option to quickly encrypt a regular file, or decrypt an encrypted file with extension `.enc`.
|
51
|
+
* By using the `-t` (edit) mode, that opens an encrypted file in your `$EDITOR`, and replaces the encrypted version upon save & exit.
|
52
|
+
|
53
|
+
As you can see, we really tried to build a tool that provides good security for application secrets, including password-based encryption, but does not annoyingly ask for password every time. With `--edit` option, and `--negate` options you can treat encrypted files like regular files.
|
54
|
+
|
55
|
+
> Encrypting application secrets had never been easier! –– Socrates.
|
56
|
+
|
41
57
|
### How It Works
|
42
58
|
|
43
|
-
1. You
|
44
|
-
2. You generate a new encryption key, that will be used to both encrypt and decrypt the data. The key is 256 bits, or 32 bytes, or 45 bytes when base64-encoded, and can be generated with `sym -g`.
|
59
|
+
1. You generate a new encryption key, that will be used to both encrypt and decrypt the data. The key is 256 bits, or 32 bytes, or 45 bytes when base64-encoded, and can be generated with `sym -g`.
|
45
60
|
* You can optionally password protect the key with `sym -gp`
|
46
|
-
* You can save the key into a file `sym -
|
47
|
-
* Or you can save it into the OS-X Keychain, with `sym -
|
61
|
+
* You can save the key into a file `sym -gpo key-file`
|
62
|
+
* Or you can save it into the OS-X Keychain, with `sym -gpcx keychain-name`, while caching its password for a period of time.
|
48
63
|
* or you can print it to STDOUT, which is the default.
|
49
|
-
|
50
|
-
|
51
|
-
*
|
52
|
-
*
|
53
|
-
*
|
64
|
+
2. You then take a piece of sensitive __data__ that you want to encrypt. This can be a file or a string.
|
65
|
+
3. You can then use the key to encrypt sensitive __data__, with `sym -e [key-option] [data-option]`, passing it the key in several accepted ways. Smart flag `-k` automatically interpretes the source of the key, by trying:
|
66
|
+
* a file with a pathname.
|
67
|
+
* or environment variable
|
68
|
+
* or OS-X Keychain password entry
|
69
|
+
* or you can paste the key interactively with `-i`
|
54
70
|
4. Input data can be read from a file with `-f file`, or read from STDIN, or a passed on the command line with `-s string`
|
55
71
|
4. Output is the encrypted data, which is printed to STDOUT by the default, or it can be saved to a file with `-o <file>`
|
56
72
|
5. Encrypted file can be later decrypted with `sym -d [key-option] [data-option]`
|
@@ -58,28 +74,35 @@ _Symmetric Encryption_ simply means that we are using the same private key to en
|
|
58
74
|
Sample session that uses Mac OS-X Keychain to store the password-protected key.
|
59
75
|
|
60
76
|
```bash
|
61
|
-
|
77
|
+
# Gen a new key, password-encrypt it, cache the password, save
|
78
|
+
# result in the key chain entry 'my-new-key' (but don't print it '-q')
|
79
|
+
❯ sym -gpqcx my-new-key
|
62
80
|
New Password : •••••••••
|
63
81
|
Confirm Password : •••••••••
|
64
|
-
BAhTOh1TeW06OkRhdGE6OldyYXBwZXJTdH.....
|
65
82
|
|
66
|
-
❯ sym -
|
83
|
+
❯ sym -eck my-new-key -s 'My secret data' -o secret.enc
|
67
84
|
Coin::Vault listening at: druby://127.0.0.1:24924
|
68
85
|
Password: •••••••••
|
69
86
|
|
70
87
|
❯ cat secret.enc
|
71
88
|
BAhTOh1TeW06OkRhdGE6OldyYXBFefDFFD.....
|
72
89
|
|
73
|
-
❯ sym -
|
90
|
+
❯ sym -dck my-new-key -f secret.enc
|
74
91
|
My secret data
|
75
92
|
|
93
|
+
# Now, let's save our keychain key in the default key file:
|
94
|
+
❯ sym -ck my-new-key -o ~/.sym.key
|
95
|
+
# Now we can decrypt/encrypt with this key at will
|
96
|
+
❯ sym -n secret.enc
|
97
|
+
# created a decrypted file `secret`
|
98
|
+
|
76
99
|
# Lets now save common flags in the SYM_ARGS bash variable:
|
77
|
-
❯ export SYM_ARGS="-
|
78
|
-
❯ sym -
|
100
|
+
❯ export SYM_ARGS="-ck my-new-key"
|
101
|
+
❯ sym -df secret.enc
|
79
102
|
My secret data
|
80
103
|
```
|
81
104
|
|
82
|
-
The line that says `Coin::Vault listening at: druby://127.0.0.1:24924` is the indication that the local dRB server used for caching passwords has been started. Password caching is off by default, but is enabled with `-
|
105
|
+
The line that says `Coin::Vault listening at: druby://127.0.0.1:24924` is the indication that the local dRB server used for caching passwords has been started. Password caching is off by default, but is enabled with `-c` flag. In the example above, the decryption step fetched the password from the cache, and so the user was not required to re-enter the password.
|
83
106
|
|
84
107
|
__Direct Editing Encrypted Files__
|
85
108
|
|
@@ -87,7 +110,7 @@ Instead of decrypting data anytime you need to change it, you can use the shortc
|
|
87
110
|
|
88
111
|
Example:
|
89
112
|
|
90
|
-
sym -t -f config/application/secrets.yml.enc -
|
113
|
+
sym -t -f config/application/secrets.yml.enc -k ~/.key
|
91
114
|
|
92
115
|
> This is one of those time-saving features that can make a difference in making encryption feel easy and transparent.
|
93
116
|
|
@@ -115,7 +138,7 @@ Optionally, after gem installation, you can also install bash-completion of gem'
|
|
115
138
|
|
116
139
|
Should you choose to install it (this part is optional), you will be able to use "tab-tab" after typing `sym`, and you'll be able to choose from all of the supported flags.
|
117
140
|
|
118
|
-
<a name="
|
141
|
+
<a name="cli"></a>
|
119
142
|
|
120
143
|
## Using `sym` with the Command Line
|
121
144
|
|
@@ -126,7 +149,7 @@ The private key is the cornerstone of the symmetric encryption. Using `sym`, the
|
|
126
149
|
* generated and printed to STDOUT, or saved to Mac OS-X KeyChain or a file
|
127
150
|
* fetched from the Keychain in subsequent operations
|
128
151
|
* password-protected during generation (or import) with the `-p` flag.
|
129
|
-
* password can be cached using either `memcached` or `dRB` server, if the `-
|
152
|
+
* password can be cached using either `memcached` or `dRB` server, if the `-c` flag is provided.
|
130
153
|
* must be kept very well protected and secure from attackers.
|
131
154
|
|
132
155
|
The __unencrypted private__ key will be in the form of a base64-encoded string, 45 characters long.
|
@@ -145,21 +168,25 @@ Or save a new key into a bash variable
|
|
145
168
|
|
146
169
|
Or save it to a file:
|
147
170
|
|
148
|
-
sym -g -o ~/.key
|
149
171
|
sym -go ~/.key
|
150
172
|
|
151
|
-
Or create a password-protected key (`-p`), and save it to a file (`-o`), and
|
173
|
+
Or create a password-protected key (`-p`), and save it to a file (`-o`), cache the password (`-c`), and don't print the new key to STDOUT (`-q` for quiet):
|
152
174
|
|
153
|
-
sym -
|
175
|
+
sym -gpcqo ~/.secret
|
154
176
|
New Password: ••••••••••
|
155
177
|
Confirm Password: ••••••••••
|
156
|
-
|
178
|
+
|
179
|
+
##### Key Sources
|
180
|
+
|
157
181
|
You can subsequently use the private key by passing either:
|
158
182
|
|
159
|
-
1. the `-k key
|
160
|
-
|
161
|
-
|
162
|
-
|
183
|
+
1. the `-k key` flag, where key is either:
|
184
|
+
* a file
|
185
|
+
* an environment variable name
|
186
|
+
* an actual base64-encoded key
|
187
|
+
* a keychain name
|
188
|
+
2. pasting or typing the key with the `-i` (interactive) flag
|
189
|
+
3. a default key file, in your home folder, `~/.sym.key`, used only when no other flags passed in.
|
163
190
|
|
164
191
|
#### Using KeyChain Access on Mac OS-X
|
165
192
|
|
@@ -170,11 +197,11 @@ Apple had released a `security` command line tool, which this library uses to se
|
|
170
197
|
* The private key won't be lying around your file system unencrypted, so if your Mac is ever stolen, you don't need to worry about the keys running wild.
|
171
198
|
* If you sync your keychain with the iCloud you will have access to it on other machines
|
172
199
|
|
173
|
-
To activate the KeyChain mode on the Mac, use `-x <key-name>`
|
200
|
+
To activate the KeyChain mode on the Mac, use `-x <key-name>` flag with `-g` flag when generating a key. The `key name` is what you call this particular key, based on how you plan to use it. For example, you may call it `staging`, etc.
|
174
201
|
|
175
202
|
The following command generates the private key and immediately stores it in the KeyChain access under the name provided:
|
176
203
|
|
177
|
-
sym -
|
204
|
+
sym -gx staging
|
178
205
|
|
179
206
|
Now, whenever you need to encrypt something you can specify the key with `-x staging`.
|
180
207
|
|
@@ -194,15 +221,15 @@ It's help message is self-explanatory:
|
|
194
221
|
|
195
222
|
#### Moving a Key to the Keychain
|
196
223
|
|
197
|
-
You can easily move an existing key from a file or a string to a keychain by combining -k or -
|
224
|
+
You can easily move an existing key from a file or a string to a keychain by combining -k or -k to read the key, with -x to write it.
|
198
225
|
|
199
|
-
sym -k $
|
226
|
+
sym -k $keysource -x mykey
|
200
227
|
|
201
228
|
#### Adding Password to Existing Key
|
202
229
|
|
203
|
-
You can add a password to a key by combining one of the key description flags (-k, -
|
230
|
+
You can add a password to a key by combining one of the key description flags (-k, -i) and then also -p. Use `-q` to hide new key from the STDOUT, and `c` to cache the password.
|
204
231
|
|
205
|
-
sym -k $mykey -
|
232
|
+
sym -k $mykey -pqcx moo
|
206
233
|
|
207
234
|
The above example will take an unencrypted key passed in `$mykey`, ask for a password and save password protected key into the keychain with name "moo."
|
208
235
|
|
@@ -214,22 +241,22 @@ Specifics of configuring both Cache Providers is left to the `Configuration` cla
|
|
214
241
|
|
215
242
|
In order to control password caching, the following flags are available:
|
216
243
|
|
217
|
-
* `-
|
218
|
-
* `-
|
219
|
-
* `-
|
244
|
+
* `-c` turns on caching
|
245
|
+
* `-u seconds` sets the expiration for cached passwords
|
246
|
+
* `-r memcached | drb` controls which of the providers is used. Without this flag, *sym* auto-detects caching provider by first checking for `memcached`, and then starting the `dRB` server.
|
220
247
|
|
221
248
|
#### Saving Common Flags in an Environment Variable
|
222
249
|
|
223
250
|
You can optionally store frequently used flags for `sym` in the `SYM_ARGS` environment variable. For example, to always cache passwords, and to always use the same encryption key from the keychain named "production", set the following in your `~/.bashrc`:
|
224
251
|
|
225
252
|
```
|
226
|
-
export SYM_ARGS="-
|
253
|
+
export SYM_ARGS="-cx production"
|
227
254
|
```
|
228
255
|
|
229
256
|
This will always be appended to the command line, and so to encrypt/decrypt anything with password caching enabled and using that particular key, you would simply type:
|
230
257
|
|
231
258
|
```bash
|
232
|
-
# -
|
259
|
+
# -cx production are added from SYM_ARGS
|
233
260
|
sym -ef file -o file.enc
|
234
261
|
|
235
262
|
# And to decrypt:
|
@@ -244,27 +271,27 @@ sym -tf file.enc
|
|
244
271
|
This may be a good time to take a look at the full help message for the `sym` tool, shown naturally with a `-h` or `--help` option.
|
245
272
|
|
246
273
|
```
|
247
|
-
Sym (2.
|
274
|
+
Sym (2.4.1) – encrypt/decrypt data with a private key
|
248
275
|
|
249
276
|
Usage:
|
250
|
-
# Generate a new key
|
251
|
-
|
277
|
+
# Generate a new key, optionally password protected, and save it
|
278
|
+
# in one of: keychain, file, or STDOUT (-q turns off STDOUT)
|
279
|
+
sym -g [ -p/--password ] [ -x keychain | -o file | ] [ -q ]
|
252
280
|
|
253
|
-
# To specify a key for an operation use one of...
|
254
|
-
<key-spec> = -k key | -K file | -x keychain | -i
|
255
281
|
|
256
|
-
# Encrypt/Decrypt to STDOUT
|
257
|
-
sym -e <key-spec> [-f
|
258
|
-
sym -d <key-spec> [-f
|
282
|
+
# Encrypt/Decrypt from STDIN/file/args, to STDOUT/file:
|
283
|
+
sym -e/--encrypt <key-spec> [-f [file | - ] | -s string ] [-o file]
|
284
|
+
sym -d/--decrypt <key-spec> [-f [file | - ] | -s string ] [-o file]
|
259
285
|
|
260
286
|
# Edit an encrypted file in $EDITOR
|
261
|
-
sym -t
|
287
|
+
sym -t/--edit <key-spec> -f file [ -b/--backup ]
|
262
288
|
|
263
|
-
# Specify any
|
264
|
-
|
289
|
+
# Specify any common flags in the BASH variable. Here we
|
290
|
+
# specify KeyChain name "staging" and turn on password caching
|
291
|
+
export SYM_ARGS="-ck staging"
|
265
292
|
|
266
|
-
# And now encrypt
|
267
|
-
sym -e -f
|
293
|
+
# And now encrypt using default key location /Users/kig/.sym.key
|
294
|
+
sym -e -f file
|
268
295
|
# May need to disable SYM_ARGS with -M, eg for help:
|
269
296
|
sym -h -M
|
270
297
|
|
@@ -276,29 +303,30 @@ Modes:
|
|
276
303
|
Create a new private key:
|
277
304
|
-g, --generate generate a new private key
|
278
305
|
-p, --password encrypt the key with a password
|
306
|
+
-x, --keychain [key-name] write the key to OS-X Keychain
|
279
307
|
|
280
308
|
Read existing private key from:
|
281
|
-
-k, --
|
282
|
-
-K, --keyfile [key-file] private key from a file
|
283
|
-
-x, --keychain [key-name] add to (or read from) the OS-X Keychain
|
309
|
+
-k, --key [key-spec] private key, key file, or keychain
|
284
310
|
-i, --interactive Paste or type the key interactively
|
285
311
|
|
286
312
|
Password Cache:
|
287
|
-
-
|
288
|
-
-
|
289
|
-
-
|
313
|
+
-c, --cache-passwords enable password cache
|
314
|
+
-u, --cache-timeout [seconds] expire passwords after
|
315
|
+
-r, --cache-provider [provider] cache provider, one of memcached, drb
|
290
316
|
|
291
317
|
Data to Encrypt/Decrypt:
|
292
318
|
-s, --string [string] specify a string to encrypt/decrypt
|
293
319
|
-f, --file [file] filename to read from
|
294
320
|
-o, --output [file] filename to write to
|
321
|
+
-n, --negate [file] encrypts any regular file into file.enc
|
322
|
+
conversely decrypts file.enc into file.
|
295
323
|
|
296
324
|
Flags:
|
297
325
|
-b, --backup create a backup file in the edit mode
|
298
326
|
-v, --verbose show additional information
|
299
|
-
-A, --trace print a backtrace of any errors
|
300
|
-
-D, --debug print debugging information
|
301
327
|
-q, --quiet do not print to STDOUT
|
328
|
+
-T, --trace print a backtrace of any errors
|
329
|
+
-D, --debug print debugging information
|
302
330
|
-V, --version print library version
|
303
331
|
-N, --no-color disable color output
|
304
332
|
-M, --no-environment disable reading flags from SYM_ARGS
|
@@ -309,6 +337,7 @@ Utility:
|
|
309
337
|
Help & Examples:
|
310
338
|
-E, --examples show several examples
|
311
339
|
-h, --help show help
|
340
|
+
|
312
341
|
```
|
313
342
|
|
314
343
|
### CLI Usage Examples
|
@@ -360,7 +389,7 @@ In this mode several flags are of importance:
|
|
360
389
|
-b (--backup) – will create a backup of the original file
|
361
390
|
-v (--verbose) - will show additional info about file sizes
|
362
391
|
|
363
|
-
Here is a full command that opens a file specified by `-f | --file`, using the key specified in `-
|
392
|
+
Here is a full command that opens a file specified by `-f | --file`, using the key specified in `-k | --keyfile`, in the editor defined by the `$EDITOR` environment variable (or if not set – defaults to `/bin/vi`)".
|
364
393
|
|
365
394
|
To edit an encrypted file in `$EDITOR`, while asking to paste the key (`-i | --interactive`), while creating a backup file (`-b | --backup`):
|
366
395
|
|
@@ -373,7 +402,7 @@ To edit an encrypted file in `$EDITOR`, while asking to paste the key (`-i | --i
|
|
373
402
|
# ---
|
374
403
|
# # (c) 2016 Konstantin Gredeskoul. All rights reserved.
|
375
404
|
|
376
|
-
<a name="
|
405
|
+
<a name="rubyapi"></a>
|
377
406
|
|
378
407
|
## Ruby API
|
379
408
|
|
@@ -449,12 +478,18 @@ The library offers a typical `Sym::Configuration` class which can be used to twe
|
|
449
478
|
require 'zlib'
|
450
479
|
require 'sym'
|
451
480
|
Sym::Configuration.configure do |config|
|
452
|
-
config.password_cipher
|
453
|
-
config.
|
454
|
-
config.
|
455
|
-
config.
|
456
|
-
|
457
|
-
config.
|
481
|
+
config.password_cipher = 'AES-128-CBC'
|
482
|
+
config.data_cipher = 'AES-256-CBC'
|
483
|
+
config.private_key_cipher = config.data_cipher
|
484
|
+
config.compression_enabled = true
|
485
|
+
config.compression_level = Zlib::BEST_COMPRESSION
|
486
|
+
config.encrypted_file_extension = 'enc'
|
487
|
+
config.default_key_file = "#{ENV['HOME']}/.sym.key"
|
488
|
+
|
489
|
+
config.password_cache_timeout = 300
|
490
|
+
|
491
|
+
# When nil is selected, providers are auto-detected.
|
492
|
+
config.password_cache_default_provider = nil
|
458
493
|
config.password_cache_arguments = {
|
459
494
|
drb: {
|
460
495
|
opts: {
|
@@ -471,6 +506,7 @@ Sym::Configuration.configure do |config|
|
|
471
506
|
}
|
472
507
|
}
|
473
508
|
end
|
509
|
+
|
474
510
|
```
|
475
511
|
|
476
512
|
As you can see, it's possible to change the default cipher type, although not all ciphers will be code-compatible with the current algorithm, and may require additional code changes.
|
@@ -480,7 +516,7 @@ As you can see, it's possible to change the default cipher type, although not al
|
|
480
516
|
The `sym` executable as well as the Ruby API provide:
|
481
517
|
|
482
518
|
* Symmetric data encryption with:
|
483
|
-
* the Cipher `AES-256-
|
519
|
+
* the Cipher `AES-256-cBC` used by the US Government
|
484
520
|
* 256-bit private key, that
|
485
521
|
* can be generated and is a *base64-encoded* string about 45 characters long. The *decoded* key is always 32 characters (or 256 bytes) long.
|
486
522
|
* can be optionally password-encrypted using the 128-bit key, and then be automatically detected (and password requested) when the key is used
|
data/Rakefile
CHANGED
@@ -8,8 +8,9 @@ def shell(*args)
|
|
8
8
|
end
|
9
9
|
|
10
10
|
task :permissions do
|
11
|
-
shell(
|
12
|
-
shell("
|
11
|
+
shell('rm -rf pkg/')
|
12
|
+
shell("chmod -v o+r,g+r * */* */*/* */*/*/* */*/*/*/* */*/*/*/*/*")
|
13
|
+
shell("find . -type d -exec chmod o+x,g+x {} \\;")
|
13
14
|
end
|
14
15
|
|
15
16
|
task :build => :permissions
|
data/bin/sym.completion
CHANGED
@@ -46,17 +46,21 @@ _sym()
|
|
46
46
|
_expand || return 0
|
47
47
|
|
48
48
|
case "$prev" in
|
49
|
-
--@(key
|
49
|
+
--@(key|file|output|negate))
|
50
50
|
_filedir
|
51
51
|
return 0
|
52
52
|
;;
|
53
|
-
-@(f|
|
53
|
+
-@(f|k|o|n))
|
54
54
|
_filedir
|
55
55
|
return 0
|
56
56
|
;;
|
57
57
|
esac
|
58
58
|
|
59
59
|
case "$cur" in
|
60
|
+
--*)
|
61
|
+
export DICT_SYM_COMP_LONG_OPTIONS=${DICT_SYM_COMP_LONG_OPTIONS:-$(sym -hM | grep -- '--' | egrep '^ -' | awk '{print $2}')}
|
62
|
+
COMPREPLY=( $( compgen -W "$DICT_SYM_COMP_LONG_OPTIONS" -- "$cur" ))
|
63
|
+
;;
|
60
64
|
-*)
|
61
65
|
export DICT_SYM_COMP_OPTIONS=${DICT_SYM_COMP_OPTIONS:-$(sym --dictionary | sed -E 's/ /\n/g')}
|
62
66
|
COMPREPLY=( $( compgen -W "$DICT_SYM_COMP_OPTIONS" -- "$cur" ))
|