enveloperb 0.1.5.4.g10f5d39-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,124 @@
1
+ Ruby bindings for the [envelopers](https://github.com/cipherstash/enveloper) envelope encryption library.
2
+
3
+ Envelope encryption is a mechanism by which a plaintext is encrypted into a ciphertext using a single-use key (known as the "data key"), and then that data key is encrypted with a second key (known as the "wrapping key", or "key-encryption key", or sometimes "KEK").
4
+ The encrypted data key is then stored alongside the ciphertext, so that all that is needed for decryption is the key-encryption key and the ciphertext/encrypted data key bundle.
5
+
6
+ The benefits of this mechanism are:
7
+
8
+ 1. Compromise of the key used to encrypt a plaintext (say, by short-term penetration of a process performing decryption) does not compromise all data;
9
+
10
+ 2. The key-encryption key can be stored securely and entirely separate from any plaintext data, in an HSM (Hardware Security Module) or other hardened environment;
11
+
12
+ 3. The entity operating the key-encryption key environment never has (direct) access to plaintexts (as would be the case if you sent the plaintext to the HSM for encryption);
13
+
14
+ 4. Large volumes of data can be encrypted efficiently on a local machine, and only the small data key needs to be sent over a slow network link to be encrypted.
15
+
16
+ As you can see, the benefits of envelope encryption mostly center around environments where KEK material is HSM-managed.
17
+ Except for testing purposes, it is not common to use envelope encryption in situations where the KEK is provided directly to the envelope encryption system.
18
+
19
+
20
+ # Installation
21
+
22
+ For the most common platforms, we provide "native" gems (which have the shared object that provides the cryptographic primitives pre-compiled).
23
+ At present, we provide native gems for:
24
+
25
+ * Linux `x86_64` and `aarch64`
26
+ * macOS `x86_64` and `arm64`
27
+
28
+ On these platforms, you can just install the `enveloperb` gem via your preferred method, and it should "just work".
29
+ If it doesn't, please [report that as a bug](https://github.com/cipherstash/enveloperb/issues).
30
+
31
+ For other platforms, you will need to install the source gem, which requires that you have Rust 1.57.0 or later installed.
32
+ On ARM-based platforms, you must use Rust nightly, for SIMD intrinsics support.
33
+
34
+ ## Installing from Git
35
+
36
+ If you have a burning need to install directly from a checkout of the git repository, you can do so by running `bundle install && rake install`.
37
+ As this is a source-based installation, you will need to have Rust installed, as described above.
38
+
39
+
40
+ # Usage
41
+
42
+ First off, load the library:
43
+
44
+ ```ruby
45
+ require "enveloperb"
46
+ ```
47
+
48
+ Then create a new cryptography engine, using your choice of wrapping key provider.
49
+ For this example, we'll use the "simple" key provider, which takes a 16 byte *binary* string as the key-encryption-key.
50
+
51
+ ```ruby
52
+ require "securerandom"
53
+ kek = SecureRandom.bytes(16)
54
+
55
+ engine = Enveloperb::Simple.new(kek)
56
+ ```
57
+
58
+ Now you can encrypt whatever data you like:
59
+
60
+ ```ruby
61
+ ct = engine.encrypt("This is a super-important secret")
62
+ ```
63
+
64
+ This produces an `Enveloperb::EncryptedRecord`, which can be turned into a (binary) string very easily:
65
+
66
+ ```ruby
67
+ File.binwrite("/tmp/ciphertext", ct1.to_s)
68
+ ```
69
+
70
+ To turn a binary string back into a ciphertext, just create a new `EncryptedRecord` with it:
71
+
72
+ ```ruby
73
+ ct_new = Enveloperb::EncryptedRecord.new(File.binread("/tmp/ciphertext"))
74
+ ```
75
+
76
+ Then you can decrypt it again:
77
+
78
+ ```ruby
79
+ engine.decrypt(ct_new) # => "This ia super-important secret"
80
+ ```
81
+
82
+
83
+ ## AWS KMS Key Provider
84
+
85
+ When using a locally-managed wrapping key, the benefits over direct encryption aren't significant.
86
+ The real benefits come when using a secured key provider for the wrapping key, such as AWS KMS.
87
+
88
+ To use an AWS KMS key as the wrapping key, you use an `Enveloperb::AWSKMS` instance as the cryptography engine, like so:
89
+
90
+ ```ruby
91
+ engine = Enveloperb::AWSKMS.key(keyid, profile: "example", region: "xx-example-1", credentials: { ... })
92
+ ```
93
+
94
+ While `keyid` is mandatory, `profile`, `region` and `credentials` are all optional.
95
+ If not specified, they will be extracted from the usual places (environment, metadata service, etc) as specified in [the AWS SDK for Rust documentation](https://docs.aws.amazon.com/sdk-for-rust/latest/dg/credentials.html).
96
+ Yes, the Rust SDK -- `enveloperb` is just a thin wrapper around a Rust library.
97
+ We are truly living in the future.
98
+
99
+ Once you have your AWS KMS cryptography engine, its usage is the familiar `#encrypt` / `#decrypt` cycle.
100
+
101
+
102
+ # Contributing
103
+
104
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md).
105
+
106
+
107
+ # Licence
108
+
109
+ Unless otherwise stated, everything in this repo is covered by the following
110
+ copyright notice:
111
+
112
+ Copyright (C) 2022 CipherStash Inc.
113
+
114
+ This program is free software: you can redistribute it and/or modify it
115
+ under the terms of the GNU General Public License version 3, as
116
+ published by the Free Software Foundation.
117
+
118
+ This program is distributed in the hope that it will be useful,
119
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
120
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
121
+ GNU General Public License for more details.
122
+
123
+ You should have received a copy of the GNU General Public License
124
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -0,0 +1,39 @@
1
+ begin
2
+ require 'git-version-bump'
3
+ rescue LoadError
4
+ nil
5
+ end
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "enveloperb"
9
+
10
+ s.version = ENV.fetch("GVB_VERSION_OVERRIDE") { GVB.version rescue "0.0.0.1.NOGVB" }
11
+ s.date = GVB.date rescue Time.now.strftime("%Y-%m-%d")
12
+
13
+ s.platform = Gem::Platform::RUBY
14
+
15
+ s.summary = "Ruby bindings for the envelopers envelope encryption library"
16
+
17
+ s.authors = ["Matt Palmer"]
18
+ s.email = ["matt@cipherstash.com"]
19
+ s.homepage = "https://github.com/cipherstash/enveloperb"
20
+
21
+ s.files = `git ls-files -z`.split("\0").reject { |f| f =~ /^(\.|G|spec|Rakefile)/ }
22
+
23
+ s.extensions = ["ext/enveloperb/extconf.rb"]
24
+
25
+ s.required_ruby_version = ">= 2.7.0"
26
+
27
+ s.add_development_dependency 'bundler'
28
+ s.add_development_dependency 'github-release'
29
+ s.add_development_dependency 'guard-rspec'
30
+ s.add_development_dependency 'rake', '~> 13.0'
31
+ s.add_development_dependency 'rake-compiler', '~> 1.2'
32
+ s.add_development_dependency 'rake-compiler-dock', '~> 1.2'
33
+ s.add_development_dependency 'rb-inotify', '~> 0.9'
34
+ s.add_development_dependency 'rb_sys', '~> 0.1'
35
+ s.add_development_dependency 'redcarpet'
36
+ s.add_development_dependency 'rspec'
37
+ s.add_development_dependency 'simplecov'
38
+ s.add_development_dependency 'yard'
39
+ end
@@ -0,0 +1,4 @@
1
+ /target
2
+ # Cargo.lock is deliberately *not* ignored; despite *technically* being a
3
+ # library package, it is not a Rust library that is built into other projects,
4
+ # but rather a standalone binary object that should be built reproducibly.