enquo-core 0.5.0-aarch64-linux → 0.5.0.2.g015cdff-aarch64-linux

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
  SHA256:
3
- metadata.gz: 0b30675da9cddc9e757446df84024bb0be24512d484732460fdae3316a3808ee
4
- data.tar.gz: 400b52836e010030474a09d3bca8b1ffac54f38f6ea3be906b94792286bb1354
3
+ metadata.gz: a9a076320c4c35d3ab688ee2aa3fa8559772ab4b6505ea456350a99cb72027ab
4
+ data.tar.gz: f88e08ee73d64a2bb8bc14a9eaec80d87e1e98bafe2e8e18d0a0392e8edf1c47
5
5
  SHA512:
6
- metadata.gz: d87e366269feed4f22733c9cba25e26034a99a9d8bd25b8287b851b219921165c5dede5ecaa8b5b737632e629fd52a386a2a6f90edc7a78022bb4907d48f2970
7
- data.tar.gz: c8eb5ca4f435e7c448085bfdcc63688ddb87429681f183beaaf3761cdb476dd76544c2e9622d7395663fc5ccdbf44a63a793284ddb49aaf5af0c2d02fe2095ee
6
+ metadata.gz: 0abbc0c9840d3b1a2388d198d8ae93b8b94d18869eb05fecca980e3c8197ecbad9f2b607442e23a3612adc6d4c8b8ebb9779dbd1b9dd2154afcdbc117e67dedd
7
+ data.tar.gz: 43b9456b853f0f0d1c9f4b7e054c4c97fa267befae28ad780d642fad529225fa09b78cd5c9ef8a8de5351dd049b11a969f3e0858bbc6d6a55fb02dc48aa64088
data/ext/enquo/Cargo.lock CHANGED
@@ -296,6 +296,7 @@ dependencies = [
296
296
  "serde_bytes",
297
297
  "sha2",
298
298
  "thiserror",
299
+ "unicode-normalization",
299
300
  ]
300
301
 
301
302
  [[package]]
@@ -788,6 +789,21 @@ dependencies = [
788
789
  "syn",
789
790
  ]
790
791
 
792
+ [[package]]
793
+ name = "tinyvec"
794
+ version = "1.6.0"
795
+ source = "registry+https://github.com/rust-lang/crates.io-index"
796
+ checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
797
+ dependencies = [
798
+ "tinyvec_macros",
799
+ ]
800
+
801
+ [[package]]
802
+ name = "tinyvec_macros"
803
+ version = "0.1.0"
804
+ source = "registry+https://github.com/rust-lang/crates.io-index"
805
+ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
806
+
791
807
  [[package]]
792
808
  name = "typenum"
793
809
  version = "1.15.0"
@@ -800,6 +816,15 @@ version = "1.0.3"
800
816
  source = "registry+https://github.com/rust-lang/crates.io-index"
801
817
  checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
802
818
 
819
+ [[package]]
820
+ name = "unicode-normalization"
821
+ version = "0.1.22"
822
+ source = "registry+https://github.com/rust-lang/crates.io-index"
823
+ checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
824
+ dependencies = [
825
+ "tinyvec",
826
+ ]
827
+
803
828
  [[package]]
804
829
  name = "unicode-width"
805
830
  version = "0.1.9"
data/ext/enquo/src/lib.rs CHANGED
@@ -1,7 +1,7 @@
1
1
  #[macro_use]
2
2
  extern crate rutie;
3
3
 
4
- use enquo_core::{key_provider, Date, Field, Root, I64};
4
+ use enquo_core::{key_provider, Date, Field, Root, Text, I64};
5
5
  use rutie::{AnyObject, Class, Integer, Module, Object, RString, Symbol, VerifiedObject, VM};
6
6
 
7
7
  class!(EnquoRoot);
@@ -100,7 +100,7 @@ unsafe_methods!(
100
100
  "Failed to create encrypted i64",
101
101
  );
102
102
  if mode == "no_query" {
103
- res.drop_ore_ciphertext();
103
+ res.make_unqueryable();
104
104
  }
105
105
 
106
106
  RString::new_utf8(&maybe_raise(serde_json::to_string(&res), "Failed to JSONify ciphertext"))
@@ -149,7 +149,7 @@ unsafe_methods!(
149
149
  "Failed to create encrypted date",
150
150
  );
151
151
  if mode == "no_query" {
152
- res.drop_ore_ciphertexts();
152
+ res.make_unqueryable();
153
153
  }
154
154
 
155
155
  RString::new_utf8(&maybe_raise(serde_json::to_string(&res), "Failed to JSONify ciphertext"))
@@ -175,6 +175,48 @@ unsafe_methods!(
175
175
  ];
176
176
  klass.protect_send("new", &args).unwrap()
177
177
  }
178
+ fn enquo_field_encrypt_text(
179
+ text_obj: RString,
180
+ context_obj: RString,
181
+ mode_obj: Symbol
182
+ ) -> RString {
183
+ let text = text_obj.to_str();
184
+ let context = context_obj.to_vec_u8_unchecked();
185
+ let mode = mode_obj.to_str();
186
+
187
+ let field = rbself.get_data(&*FIELD_WRAPPER);
188
+
189
+ let mut res = maybe_raise(
190
+ if mode == "unsafe" {
191
+ Text::new_with_unsafe_parts(
192
+ text,
193
+ &context,
194
+ field,
195
+ )
196
+ } else {
197
+ Text::new(text, &context, field)
198
+ },
199
+ "Failed to create encrypted date",
200
+ );
201
+ if mode == "no_query" {
202
+ res.make_unqueryable();
203
+ }
204
+
205
+ RString::new_utf8(&maybe_raise(serde_json::to_string(&res), "Failed to JSONify ciphertext"))
206
+ },
207
+ fn enquo_field_decrypt_text(ciphertext_obj: RString, context_obj: RString) -> RString {
208
+ let ct = ciphertext_obj.to_str_unchecked();
209
+ let context = context_obj.to_vec_u8_unchecked();
210
+
211
+ let field = rbself.get_data(&*FIELD_WRAPPER);
212
+
213
+ let e_value: Text =
214
+ maybe_raise(serde_json::from_str(ct), "Failed to deserialize ciphertext");
215
+
216
+ let s = maybe_raise(e_value.decrypt(&context, field), "Failed to decrypt text value");
217
+
218
+ RString::new_utf8(&s)
219
+ }
178
220
  );
179
221
 
180
222
  #[allow(non_snake_case)]
@@ -197,6 +239,8 @@ pub extern "C" fn Init_enquo() {
197
239
  fieldklass.def_private("_decrypt_i64", enquo_field_decrypt_i64);
198
240
  fieldklass.def_private("_encrypt_date", enquo_field_encrypt_date);
199
241
  fieldklass.def_private("_decrypt_date", enquo_field_decrypt_date);
242
+ fieldklass.def_private("_encrypt_text", enquo_field_encrypt_text);
243
+ fieldklass.def_private("_decrypt_text", enquo_field_decrypt_text);
200
244
  });
201
245
  topmod.define_nested_module("RootKey").define(|rkmod| {
202
246
  rkmod
data/lib/2.7/enquo.so CHANGED
Binary file
data/lib/3.0/enquo.so CHANGED
Binary file
data/lib/3.1/enquo.so CHANGED
Binary file
data/lib/enquo/field.rb CHANGED
@@ -69,5 +69,41 @@ module Enquo
69
69
 
70
70
  _decrypt_date(data, ctx)
71
71
  end
72
+
73
+ def encrypt_text(t, ctx, safety: true, no_query: false)
74
+ unless t.is_a?(String)
75
+ raise ArgumentError, "Enquo::Field#encrypt_string can only encrypt Strings"
76
+ end
77
+
78
+ unless t.encoding == Encoding::UTF_8
79
+ raise ArgumentError, "Enquo::Field#encrypt_string can only encrypt UTF-8 strings (got a string encoding of #{t.encoding})"
80
+ end
81
+
82
+ unless t.valid_encoding?
83
+ raise ArgumentError, "Enquo::Field#encrypt_string can only encrypt validly-encoded UTF-8 strings"
84
+ end
85
+
86
+ unless ctx.is_a?(String)
87
+ raise ArgumentError, "Encryption context must be a string (got a #{ctx.class})"
88
+ end
89
+
90
+ _encrypt_text(t, ctx, no_query ? :no_query : safety == :unsafe ? :unsafe : :default)
91
+ end
92
+
93
+ def decrypt_text(data, ctx)
94
+ unless data.is_a?(String)
95
+ raise ArgumentError, "Enquo::Field#decrypt_text can only decrypt from a string (got #{data.class})"
96
+ end
97
+
98
+ unless data.encoding == Encoding::UTF_8 && data.valid_encoding?
99
+ raise ArgumentError, "Enquo::Field#decrypt_date can only decrypt validly-encoded UTF-8 strings (got #{data.encoding})"
100
+ end
101
+
102
+ unless ctx.is_a?(String)
103
+ raise ArgumentError, "Encryption context must be a string (got a #{ctx.class})"
104
+ end
105
+
106
+ _decrypt_text(data, ctx)
107
+ end
72
108
  end
73
109
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enquo-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.0.2.g015cdff
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-07 00:00:00.000000000 Z
11
+ date: 2022-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -193,9 +193,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
193
  version: 3.2.dev
194
194
  required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  requirements:
196
- - - ">="
196
+ - - ">"
197
197
  - !ruby/object:Gem::Version
198
- version: '0'
198
+ version: 1.3.1
199
199
  requirements: []
200
200
  rubygems_version: 3.3.22
201
201
  signing_key: