enveloperb 0.1.2-x86_64-linux → 0.1.4-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -13
- data/enveloperb.gemspec +1 -2
- data/{target/release/deps → lib/2.7.0}/libenveloperb.so +0 -0
- data/lib/enveloperb.rb +9 -3
- metadata +6 -30
- data/Cargo.toml +0 -17
- data/ext/Rakefile +0 -5
- data/src/lib.rs +0 -195
- data/target/release/deps/libasync_trait-d616c5275efb3885.so +0 -0
- data/target/release/deps/libfutures_macro-0f8ad5ae6e34b161.so +0 -0
- data/target/release/deps/libpin_project_internal-ef8d149cf28b24bc.so +0 -0
- data/target/release/deps/libserde_derive-3653e4229ae528ef.so +0 -0
- data/target/release/deps/libthiserror_impl-c49e7233e0f6f247.so +0 -0
- data/target/release/deps/libtracing_attributes-ae844bddcb3f978b.so +0 -0
- data/target/release/libenveloperb.so +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c783aeda24e29352ee837e44e082310ff6679e235a3f66861ff73267a29af7cb
|
4
|
+
data.tar.gz: b2af145d653968417b5f9ad7618ca8419473494ea69dfc78d9bf187e572eefe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1298feeaffa939f9652519d194dca45de664f0fd270a00cad1c863605b101ec59bd6493550492411645ffdcfb7c31d53dabc17952f29691c962573ebbc5f2d20
|
7
|
+
data.tar.gz: a9708a5ff1bd0ffcbd63d6b3a0c74a6d5c88375c85358c66278328a70bb3abab74e6074f51f2993c8f127eba347153a2321794a22a33d81fbb383ec7d6859aa0
|
data/README.md
CHANGED
@@ -19,24 +19,22 @@ Except for testing purposes, it is not common to use envelope encryption in situ
|
|
19
19
|
|
20
20
|
# Installation
|
21
21
|
|
22
|
-
|
23
|
-
|
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
24
|
|
25
|
-
|
25
|
+
* Linux `x86_64` and `aarch64`
|
26
|
+
* macOS `x86_64` and `arm64`
|
26
27
|
|
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).
|
28
30
|
|
29
|
-
|
31
|
+
For other platforms, you will need to install the source gem, which requires that you have Rust 1.31.0 or later installed.
|
32
|
+
On ARM-based platforms, you must use Rust nightly, for SIMD intrinsics support.
|
30
33
|
|
31
|
-
|
34
|
+
## Installing from Git
|
32
35
|
|
33
|
-
If you
|
34
|
-
|
35
|
-
bundle install
|
36
|
-
rake install
|
37
|
-
|
38
|
-
Or, if you've eschewed the convenience of Rubygems entirely, then you
|
39
|
-
presumably know what to do already.
|
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.
|
40
38
|
|
41
39
|
|
42
40
|
# Usage
|
data/enveloperb.gemspec
CHANGED
@@ -24,10 +24,9 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
s.required_ruby_version = ">= 2.7.0"
|
26
26
|
|
27
|
-
s.add_runtime_dependency
|
27
|
+
s.add_runtime_dependency 'fiddle', '~> 1.1'
|
28
28
|
|
29
29
|
s.add_development_dependency 'bundler'
|
30
|
-
s.add_development_dependency 'gem-compiler'
|
31
30
|
s.add_development_dependency 'github-release'
|
32
31
|
s.add_development_dependency 'guard-rspec'
|
33
32
|
s.add_development_dependency 'rake', '~> 10.4', '>= 10.4.2'
|
Binary file
|
data/lib/enveloperb.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
require "
|
1
|
+
require "fiddle"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
begin
|
4
|
+
Fiddle::Function.new(Fiddle.dlopen("#{__dir__}/#{RbConfig::CONFIG["ruby_version"]}/libenveloperb.#{RbConfig::CONFIG["SOEXT"]}")["Init_libenveloperb"], [], Fiddle::TYPE_VOIDP).call
|
5
|
+
rescue Fiddle::DLError
|
6
|
+
begin
|
7
|
+
Fiddle::Function.new(Fiddle.dlopen("#{__dir__}/libenveloperb.#{RbConfig::CONFIG["SOEXT"]}")["Init_libenveloperb"], [], Fiddle::TYPE_VOIDP).call
|
8
|
+
rescue Fiddle::DLError
|
9
|
+
raise LoadError, "Failed to initialize libenveloperb.#{RbConfig::CONFIG["SOEXT"]}; either it hasn't been built, or was built incorrectly for your system"
|
10
|
+
end
|
5
11
|
end
|
6
12
|
|
7
13
|
require_relative "./enveloperb/encrypted_record"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enveloperb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: x86_64-linux
|
6
6
|
authors:
|
7
7
|
- Matt Palmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: fiddle
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: gem-compiler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: github-release
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,24 +165,14 @@ extra_rdoc_files: []
|
|
179
165
|
files:
|
180
166
|
- CODE_OF_CONDUCT.md
|
181
167
|
- CONTRIBUTING.md
|
182
|
-
- Cargo.toml
|
183
168
|
- LICENCE
|
184
169
|
- README.md
|
185
170
|
- enveloperb.gemspec
|
186
|
-
-
|
171
|
+
- lib/2.7.0/libenveloperb.so
|
187
172
|
- lib/enveloperb.rb
|
188
173
|
- lib/enveloperb/awskms.rb
|
189
174
|
- lib/enveloperb/encrypted_record.rb
|
190
175
|
- lib/enveloperb/simple.rb
|
191
|
-
- src/lib.rs
|
192
|
-
- target/release/deps/libasync_trait-d616c5275efb3885.so
|
193
|
-
- target/release/deps/libenveloperb.so
|
194
|
-
- target/release/deps/libfutures_macro-0f8ad5ae6e34b161.so
|
195
|
-
- target/release/deps/libpin_project_internal-ef8d149cf28b24bc.so
|
196
|
-
- target/release/deps/libserde_derive-3653e4229ae528ef.so
|
197
|
-
- target/release/deps/libthiserror_impl-c49e7233e0f6f247.so
|
198
|
-
- target/release/deps/libtracing_attributes-ae844bddcb3f978b.so
|
199
|
-
- target/release/libenveloperb.so
|
200
176
|
homepage: https://github.com/cipherstash/enveloperb
|
201
177
|
licenses: []
|
202
178
|
metadata: {}
|
data/Cargo.toml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
[package]
|
2
|
-
name = "enveloperb"
|
3
|
-
version = "0.0.0"
|
4
|
-
edition = "2021"
|
5
|
-
|
6
|
-
[dependencies]
|
7
|
-
enveloper = { git = "https://github.com/cipherstash/enveloper", branch = "main" }
|
8
|
-
lazy_static = "^0.2.2"
|
9
|
-
rutie = "0.8.4"
|
10
|
-
tokio = { version = "^1.17.0", features = [ "rt-multi-thread" ] }
|
11
|
-
aws-config = "0.10.1"
|
12
|
-
aws-sdk-kms = "0.10.1"
|
13
|
-
aws-types = { version = "0.10.1", features = [ "hardcoded-credentials" ] }
|
14
|
-
|
15
|
-
[lib]
|
16
|
-
name = "enveloperb"
|
17
|
-
crate-type = ["cdylib"]
|
data/ext/Rakefile
DELETED
data/src/lib.rs
DELETED
@@ -1,195 +0,0 @@
|
|
1
|
-
#[macro_use]
|
2
|
-
extern crate rutie;
|
3
|
-
|
4
|
-
#[macro_use]
|
5
|
-
extern crate lazy_static;
|
6
|
-
|
7
|
-
// I have deliberately not used more-specific symbols inside the aws_* crates because the
|
8
|
-
// names are quite generic, and in the near future when we have more providers, we'll
|
9
|
-
// almost certainly end up with naming clashes.
|
10
|
-
use aws_config;
|
11
|
-
use aws_sdk_kms;
|
12
|
-
use aws_types;
|
13
|
-
use enveloper::{EncryptedRecord, EnvelopeCipher, KMSKeyProvider, SimpleKeyProvider};
|
14
|
-
use std::borrow::Cow;
|
15
|
-
use tokio::runtime::Runtime;
|
16
|
-
use rutie::{Class, Encoding, Hash, Module, Object, RString, Symbol, VerifiedObject, VM};
|
17
|
-
|
18
|
-
module!(Enveloperb);
|
19
|
-
class!(EnveloperbSimple);
|
20
|
-
class!(EnveloperbAWSKMS);
|
21
|
-
class!(EnveloperbEncryptedRecord);
|
22
|
-
|
23
|
-
impl VerifiedObject for EnveloperbEncryptedRecord {
|
24
|
-
fn is_correct_type<T: Object>(object: &T) -> bool {
|
25
|
-
let klass = Module::from_existing("Enveloperb").get_nested_class("EncryptedRecord");
|
26
|
-
klass.case_equals(object)
|
27
|
-
}
|
28
|
-
|
29
|
-
fn error_message() -> &'static str {
|
30
|
-
"Error converting to Enveloperb::EncryptedRecord"
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
pub struct SimpleCipher {
|
35
|
-
cipher: EnvelopeCipher<SimpleKeyProvider>,
|
36
|
-
runtime: Runtime,
|
37
|
-
}
|
38
|
-
|
39
|
-
pub struct AWSKMSCipher {
|
40
|
-
cipher: EnvelopeCipher<KMSKeyProvider>,
|
41
|
-
runtime: Runtime,
|
42
|
-
}
|
43
|
-
|
44
|
-
wrappable_struct!(SimpleCipher, SimpleCipherWrapper, SIMPLE_CIPHER_WRAPPER);
|
45
|
-
wrappable_struct!(AWSKMSCipher, AWSKMSCipherWrapper, AWSKMS_CIPHER_WRAPPER);
|
46
|
-
wrappable_struct!(EncryptedRecord, EncryptedRecordWrapper, ENCRYPTED_RECORD_WRAPPER);
|
47
|
-
|
48
|
-
methods!(
|
49
|
-
EnveloperbSimple,
|
50
|
-
rbself,
|
51
|
-
|
52
|
-
fn enveloperb_simple_new(rbkey: RString) -> EnveloperbSimple {
|
53
|
-
let mut key: [u8; 16] = Default::default();
|
54
|
-
|
55
|
-
key.clone_from_slice(rbkey.unwrap().to_bytes_unchecked());
|
56
|
-
|
57
|
-
let provider = SimpleKeyProvider::init(key);
|
58
|
-
let cipher = EnvelopeCipher::init(provider);
|
59
|
-
|
60
|
-
let klass = Module::from_existing("Enveloperb").get_nested_class("Simple");
|
61
|
-
return klass.wrap_data(SimpleCipher{ cipher: cipher, runtime: Runtime::new().unwrap() }, &*SIMPLE_CIPHER_WRAPPER);
|
62
|
-
}
|
63
|
-
|
64
|
-
fn enveloperb_simple_encrypt(rbtext: RString) -> EnveloperbEncryptedRecord {
|
65
|
-
let cipher = rbself.get_data(&*SIMPLE_CIPHER_WRAPPER);
|
66
|
-
let er_r = cipher.runtime.block_on(async {
|
67
|
-
cipher.cipher.encrypt(rbtext.unwrap().to_bytes_unchecked()).await
|
68
|
-
});
|
69
|
-
let er = er_r.map_err(|e| VM::raise(Class::from_existing("RuntimeError"), &format!("Failed to perform encryption: {:?}", e))).unwrap();
|
70
|
-
|
71
|
-
let klass = Module::from_existing("Enveloperb").get_nested_class("EncryptedRecord");
|
72
|
-
return klass.wrap_data(er, &*ENCRYPTED_RECORD_WRAPPER);
|
73
|
-
}
|
74
|
-
|
75
|
-
fn enveloperb_simple_decrypt(rbrecord: EnveloperbEncryptedRecord) -> RString {
|
76
|
-
let cipher = rbself.get_data(&*SIMPLE_CIPHER_WRAPPER);
|
77
|
-
let e_record = rbrecord.unwrap();
|
78
|
-
let record = e_record.get_data(&*ENCRYPTED_RECORD_WRAPPER);
|
79
|
-
|
80
|
-
let vec_r = cipher.runtime.block_on(async {
|
81
|
-
cipher.cipher.decrypt(record).await
|
82
|
-
});
|
83
|
-
let vec = vec_r.map_err(|e| VM::raise(Class::from_existing("RuntimeError"), &format!("Failed to perform decryption: {:?}", e))).unwrap();
|
84
|
-
|
85
|
-
return RString::from_bytes(&vec, &Encoding::find("BINARY").unwrap());
|
86
|
-
}
|
87
|
-
);
|
88
|
-
|
89
|
-
methods!(
|
90
|
-
EnveloperbAWSKMS,
|
91
|
-
rbself,
|
92
|
-
|
93
|
-
fn enveloperb_awskms_new(rbkey: RString, rbcreds: Hash) -> EnveloperbAWSKMS {
|
94
|
-
let raw_creds = rbcreds.unwrap();
|
95
|
-
let rt = Runtime::new().unwrap();
|
96
|
-
|
97
|
-
let kmsclient_config = if raw_creds.at(&Symbol::new("access_key_id")).is_nil() {
|
98
|
-
rt.block_on(async {
|
99
|
-
aws_config::load_from_env().await
|
100
|
-
})
|
101
|
-
} else {
|
102
|
-
let rbregion = raw_creds.at(&Symbol::new("region")).try_convert_to::<RString>().unwrap();
|
103
|
-
let region = Some(aws_types::region::Region::new(rbregion.to_str().to_owned()));
|
104
|
-
|
105
|
-
let rbkey_id = raw_creds.at(&Symbol::new("access_key_id")).try_convert_to::<RString>().unwrap();
|
106
|
-
let key_id = rbkey_id.to_str();
|
107
|
-
|
108
|
-
let rbsecret = raw_creds.at(&Symbol::new("secret_access_key")).try_convert_to::<RString>().unwrap();
|
109
|
-
let secret = rbsecret.to_str();
|
110
|
-
|
111
|
-
let token = match raw_creds.at(&Symbol::new("session_token")).try_convert_to::<RString>() {
|
112
|
-
Ok(str) => Some(str.to_string()),
|
113
|
-
Err(_) => None
|
114
|
-
};
|
115
|
-
|
116
|
-
let aws_creds = aws_types::Credentials::from_keys(key_id, secret, token);
|
117
|
-
let creds_provider = aws_types::credentials::SharedCredentialsProvider::new(aws_creds);
|
118
|
-
|
119
|
-
aws_types::sdk_config::SdkConfig::builder().region(region).credentials_provider(creds_provider).build()
|
120
|
-
};
|
121
|
-
|
122
|
-
let kmsclient = aws_sdk_kms::Client::new(&kmsclient_config);
|
123
|
-
let provider = KMSKeyProvider::new(kmsclient, rbkey.unwrap().to_string());
|
124
|
-
let cipher = EnvelopeCipher::init(provider);
|
125
|
-
|
126
|
-
let klass = Module::from_existing("Enveloperb").get_nested_class("AWSKMS");
|
127
|
-
return klass.wrap_data(AWSKMSCipher{ cipher: cipher, runtime: rt }, &*AWSKMS_CIPHER_WRAPPER);
|
128
|
-
}
|
129
|
-
|
130
|
-
fn enveloperb_awskms_encrypt(rbtext: RString) -> EnveloperbEncryptedRecord {
|
131
|
-
let cipher = rbself.get_data(&*AWSKMS_CIPHER_WRAPPER);
|
132
|
-
let er_r = cipher.runtime.block_on(async {
|
133
|
-
cipher.cipher.encrypt(rbtext.unwrap().to_bytes_unchecked()).await
|
134
|
-
});
|
135
|
-
let er = er_r.map_err(|e| VM::raise(Class::from_existing("RuntimeError"), &format!("Failed to perform encryption: {:?}", e))).unwrap();
|
136
|
-
|
137
|
-
let klass = Module::from_existing("Enveloperb").get_nested_class("EncryptedRecord");
|
138
|
-
return klass.wrap_data(er, &*ENCRYPTED_RECORD_WRAPPER);
|
139
|
-
}
|
140
|
-
|
141
|
-
fn enveloperb_awskms_decrypt(rbrecord: EnveloperbEncryptedRecord) -> RString {
|
142
|
-
let cipher = rbself.get_data(&*AWSKMS_CIPHER_WRAPPER);
|
143
|
-
let e_record = rbrecord.unwrap();
|
144
|
-
let record = e_record.get_data(&*ENCRYPTED_RECORD_WRAPPER);
|
145
|
-
|
146
|
-
let vec_r = cipher.runtime.block_on(async {
|
147
|
-
cipher.cipher.decrypt(record).await
|
148
|
-
});
|
149
|
-
let vec = vec_r.map_err(|e| VM::raise(Class::from_existing("RuntimeError"), &format!("Failed to perform decryption: {:?}", e))).unwrap();
|
150
|
-
|
151
|
-
return RString::from_bytes(&vec, &Encoding::find("BINARY").unwrap());
|
152
|
-
}
|
153
|
-
);
|
154
|
-
|
155
|
-
methods!(
|
156
|
-
EnveloperbEncryptedRecord,
|
157
|
-
rbself,
|
158
|
-
|
159
|
-
fn enveloperb_encrypted_record_new(serialized_record: RString) -> EnveloperbEncryptedRecord {
|
160
|
-
let s = serialized_record.unwrap().to_vec_u8_unchecked();
|
161
|
-
let ct = EncryptedRecord::from_vec(s).map_err(|e| VM::raise(Class::from_existing("ArgumentError"), &format!("Failed to decode encrypted record: {:?}", e))).unwrap();
|
162
|
-
|
163
|
-
let klass = Module::from_existing("Enveloperb").get_nested_class("EncryptedRecord");
|
164
|
-
return klass.wrap_data(ct, &*ENCRYPTED_RECORD_WRAPPER);
|
165
|
-
}
|
166
|
-
|
167
|
-
fn enveloperb_encrypted_record_serialize() -> RString {
|
168
|
-
let record = rbself.get_data(&*ENCRYPTED_RECORD_WRAPPER);
|
169
|
-
|
170
|
-
return RString::from_bytes(&record.to_vec().map_err(|e| VM::raise(Class::from_existing("RuntimeError"), &format!("Failed to encode encrypted record: {:?}", e))).unwrap(), &Encoding::find("BINARY").unwrap());
|
171
|
-
}
|
172
|
-
);
|
173
|
-
|
174
|
-
#[allow(non_snake_case)]
|
175
|
-
#[no_mangle]
|
176
|
-
pub extern "C" fn Init_enveloperb() {
|
177
|
-
Module::from_existing("Enveloperb").define(|envmod| {
|
178
|
-
envmod.define_nested_class("Simple", None).define(|klass| {
|
179
|
-
klass.singleton_class().def_private("_new", enveloperb_simple_new);
|
180
|
-
klass.def_private("_encrypt", enveloperb_simple_encrypt);
|
181
|
-
klass.def_private("_decrypt", enveloperb_simple_decrypt);
|
182
|
-
});
|
183
|
-
|
184
|
-
envmod.define_nested_class("AWSKMS", None).define(|klass| {
|
185
|
-
klass.singleton_class().def_private("_new", enveloperb_awskms_new);
|
186
|
-
klass.def_private("_encrypt", enveloperb_awskms_encrypt);
|
187
|
-
klass.def_private("_decrypt", enveloperb_awskms_decrypt);
|
188
|
-
});
|
189
|
-
|
190
|
-
envmod.define_nested_class("EncryptedRecord", None).define(|klass| {
|
191
|
-
klass.singleton_class().def_private("_new", enveloperb_encrypted_record_new);
|
192
|
-
klass.def_private("_serialize", enveloperb_encrypted_record_serialize);
|
193
|
-
});
|
194
|
-
});
|
195
|
-
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|