enquo-core 0.1.0.4.gdb566eb → 0.2.0.1.g790fccd

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: 07b77707b3e001e2a8c1fac99b08351c08c98d01fa0633e1fefb7686ba221b75
4
- data.tar.gz: fd733f530d3e1df259b4001e07bf6f83ed7b1aafdb309f4fa9dbfc63eee67304
3
+ metadata.gz: f94bb637e8f6a63b6091e5801e6f5aa2e3f2e6b8c2dafb530e6baaa228abed6c
4
+ data.tar.gz: b7bc5d5e9d7b1546533e7926454a7db743927321beddae88855a308596b3cb9c
5
5
  SHA512:
6
- metadata.gz: 16e763c58c721d371137bc4457e2de0aaefde7923384a70e85c20fbd1f89c795ea63cf0319d1d2b5146416c5222467032e6831d56fa8cfda01a967230c3522fd
7
- data.tar.gz: 5dbde0e083acce2f9c9bf6067120192c1eddd2fb868a739730ab7eb1963290fd85152626a94a37f92831adef8e7b38bc45d04fc9f19ae9e3781a28dbb113e0a1
6
+ metadata.gz: 5bc43e0ce7018896e7089371b3068d3b17d7ccd9a47cc784a76bb6f7fd367de70b287028fcc14a8ab0c4f9426d9ec9760522dc19e9ddd5204d0157f1ede6b3d3
7
+ data.tar.gz: e798b96decc361ec8695a4eb39768a5bcc2bfbc5711ec01969fd6d48ece567199ee0df6165ae2bd1ee3b27174144bee6888a1088ba763152bcc5825e0af09acb
data/ext/enquo/src/lib.rs CHANGED
@@ -2,7 +2,7 @@
2
2
  extern crate rutie;
3
3
 
4
4
  use enquo_core::{Field, Root, I64};
5
- use rutie::{Boolean, Class, Integer, Module, Object, RString, VerifiedObject, VM};
5
+ use rutie::{Class, Integer, Module, Object, RString, Symbol, VerifiedObject, VM};
6
6
 
7
7
  class!(EnquoRoot);
8
8
  class!(EnquoRootKeyStatic);
@@ -81,18 +81,24 @@ impl VerifiedObject for EnquoRootKeyStatic {
81
81
  methods!(
82
82
  EnquoField,
83
83
  rbself,
84
- fn enquo_field_encrypt_i64(value: Integer, context: RString, unsafe_parts: Boolean) -> RString {
84
+ fn enquo_field_encrypt_i64(value: Integer, context: RString, mode: Symbol) -> RString {
85
85
  let i = value.unwrap().to_i64();
86
86
  let field = rbself.get_data(&*FIELD_WRAPPER);
87
+ let r_mode = mode.unwrap();
88
+ let s_mode = r_mode.to_str();
87
89
 
88
- let res = maybe_raise(
89
- if unsafe_parts.unwrap().to_bool() {
90
+ let mut res = maybe_raise(
91
+ if s_mode == "unsafe" {
90
92
  I64::new_with_unsafe_parts(i, &context.unwrap().to_vec_u8_unchecked(), field)
91
93
  } else {
92
94
  I64::new(i, &context.unwrap().to_vec_u8_unchecked(), field)
93
95
  },
94
96
  "Failed to create encrypted i64",
95
97
  );
98
+ if s_mode == "no_query" {
99
+ res.drop_ore_ciphertext();
100
+ }
101
+
96
102
  RString::new_utf8(&serde_json::to_string(&res).unwrap())
97
103
  },
98
104
  fn enquo_field_decrypt_i64(ciphertext: RString, context: RString) -> Integer {
data/lib/enquo/field.rb CHANGED
@@ -4,7 +4,7 @@ module Enquo
4
4
  raise RuntimeError, "Enquo::Field cannot be instantiated directly; use Enquo::Crypto#field instead"
5
5
  end
6
6
 
7
- def encrypt_i64(i, ctx, safety: nil)
7
+ def encrypt_i64(i, ctx, safety: true, no_query: false)
8
8
  unless i.is_a?(Integer)
9
9
  raise ArgumentError, "Enquo::Field#encrypt_i64 can only encrypt integers"
10
10
  end
@@ -17,7 +17,7 @@ module Enquo
17
17
  raise ArgumentError, "Encryption context must be a string (got a #{ctx.class})"
18
18
  end
19
19
 
20
- _encrypt_i64(i, ctx, safety == :unsafe)
20
+ _encrypt_i64(i, ctx, no_query ? :no_query : safety == :unsafe ? :unsafe : :default)
21
21
  end
22
22
 
23
23
  def decrypt_i64(data, ctx)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enquo-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.4.gdb566eb
4
+ version: 0.2.0.1.g790fccd
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer