enquo-core 0.3.0-aarch64-linux → 0.4.0-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/enquo/src/lib.rs +60 -3
- data/lib/2.7/enquo.so +0 -0
- data/lib/3.0/enquo.so +0 -0
- data/lib/3.1/enquo.so +0 -0
- data/lib/enquo/field.rb +34 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 14300d7e8d5a6a3122666cd3c7a83686d294373c5537defb60d8531d722cd4eb
         | 
| 4 | 
            +
              data.tar.gz: db807a0c99d1aa1670251261e6918c55cac14b17831f1317607db91d18a19f98
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 50ae282576040722cc4f2fdcb0940ff8728e6edf61ac8c43e02a9d0aaec355245ab7d0d71d137cc9628f698bc28388c4a693aa910f03522a80ecb960ea4053b8
         | 
| 7 | 
            +
              data.tar.gz: 1adcd8c8bc6054d5e8733ac3bd483d675938c73037d91a77af79c7585833be6817b4870566e68b48ee58794db59734eda5558099feb7c8f3f4f5b632fac6705d
         | 
    
        data/ext/enquo/src/lib.rs
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            #[macro_use]
         | 
| 2 2 | 
             
            extern crate rutie;
         | 
| 3 3 |  | 
| 4 | 
            -
            use enquo_core::{Field, Root, I64};
         | 
| 5 | 
            -
            use rutie::{Class, Integer, Module, Object, RString, Symbol, VerifiedObject, VM};
         | 
| 4 | 
            +
            use enquo_core::{Date, Field, Root, I64};
         | 
| 5 | 
            +
            use rutie::{AnyObject, Class, Integer, Module, Object, RString, Symbol, VerifiedObject, VM};
         | 
| 6 6 |  | 
| 7 7 | 
             
            class!(EnquoRoot);
         | 
| 8 8 | 
             
            class!(EnquoRootKeyStatic);
         | 
| @@ -57,7 +57,8 @@ methods!( | |
| 57 57 | 
             
                EnquoRootKeyStatic,
         | 
| 58 58 | 
             
                _rbself,
         | 
| 59 59 | 
             
                fn enquo_root_key_static_new(root_key: RString) -> EnquoRootKeyStatic {
         | 
| 60 | 
            -
                     | 
| 60 | 
            +
                    #[allow(clippy::redundant_clone)]
         | 
| 61 | 
            +
                    let k = root_key.unwrap().to_vec_u8_unchecked().to_owned();
         | 
| 61 62 | 
             
                    let klass = Module::from_existing("Enquo")
         | 
| 62 63 | 
             
                        .get_nested_class("RootKey")
         | 
| 63 64 | 
             
                        .get_nested_class("Static");
         | 
| @@ -78,6 +79,8 @@ impl VerifiedObject for EnquoRootKeyStatic { | |
| 78 79 | 
             
                }
         | 
| 79 80 | 
             
            }
         | 
| 80 81 |  | 
| 82 | 
            +
            // rustfmt fucks this so it doesn't compile
         | 
| 83 | 
            +
            #[rustfmt::skip]
         | 
| 81 84 | 
             
            methods!(
         | 
| 82 85 | 
             
                EnquoField,
         | 
| 83 86 | 
             
                rbself,
         | 
| @@ -114,6 +117,58 @@ methods!( | |
| 114 117 | 
             
                        "Failed to decrypt i64 value",
         | 
| 115 118 | 
             
                    );
         | 
| 116 119 | 
             
                    Integer::from(value)
         | 
| 120 | 
            +
                },
         | 
| 121 | 
            +
                fn enquo_field_encrypt_date(
         | 
| 122 | 
            +
                    y_r: Integer,
         | 
| 123 | 
            +
                    m_r: Integer,
         | 
| 124 | 
            +
                    d_r: Integer,
         | 
| 125 | 
            +
                    context: RString,
         | 
| 126 | 
            +
                    mode: Symbol
         | 
| 127 | 
            +
                ) -> RString {
         | 
| 128 | 
            +
                    let y = y_r.unwrap().to_i32() as i16;
         | 
| 129 | 
            +
                    let m = m_r.unwrap().to_i32() as u8;
         | 
| 130 | 
            +
                    let d = d_r.unwrap().to_i32() as u8;
         | 
| 131 | 
            +
                    let field = rbself.get_data(&*FIELD_WRAPPER);
         | 
| 132 | 
            +
                    let r_mode = mode.unwrap();
         | 
| 133 | 
            +
                    let s_mode = r_mode.to_str();
         | 
| 134 | 
            +
             | 
| 135 | 
            +
                    let mut res = maybe_raise(
         | 
| 136 | 
            +
                        if s_mode == "unsafe" {
         | 
| 137 | 
            +
                            Date::new_with_unsafe_parts(
         | 
| 138 | 
            +
                                (y, m, d),
         | 
| 139 | 
            +
                                &context.unwrap().to_vec_u8_unchecked(),
         | 
| 140 | 
            +
                                field,
         | 
| 141 | 
            +
                            )
         | 
| 142 | 
            +
                        } else {
         | 
| 143 | 
            +
                            Date::new((y, m, d), &context.unwrap().to_vec_u8_unchecked(), field)
         | 
| 144 | 
            +
                        },
         | 
| 145 | 
            +
                        "Failed to create encrypted date",
         | 
| 146 | 
            +
                    );
         | 
| 147 | 
            +
                    if s_mode == "no_query" {
         | 
| 148 | 
            +
                        res.drop_ore_ciphertexts();
         | 
| 149 | 
            +
                    }
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                    RString::new_utf8(&serde_json::to_string(&res).unwrap())
         | 
| 152 | 
            +
                },
         | 
| 153 | 
            +
                fn enquo_field_decrypt_date(ciphertext: RString, context: RString) -> AnyObject {
         | 
| 154 | 
            +
                    let ct_r = ciphertext.unwrap();
         | 
| 155 | 
            +
                    let ct = ct_r.to_str_unchecked();
         | 
| 156 | 
            +
                    let e_value: Date =
         | 
| 157 | 
            +
                        maybe_raise(serde_json::from_str(ct), "Failed to deserialize ciphertext");
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                    let field = rbself.get_data(&*FIELD_WRAPPER);
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                    let (y, m, d) = maybe_raise(
         | 
| 162 | 
            +
                        e_value.decrypt(&context.unwrap().to_vec_u8_unchecked(), field),
         | 
| 163 | 
            +
                        "Failed to decrypt date value",
         | 
| 164 | 
            +
                    );
         | 
| 165 | 
            +
                    let klass = Class::from_existing("Date");
         | 
| 166 | 
            +
                    let args: [AnyObject; 3] = [
         | 
| 167 | 
            +
                        Integer::from(y as i32).into(),
         | 
| 168 | 
            +
                        Integer::from(m as i32).into(),
         | 
| 169 | 
            +
                        Integer::from(d as i32).into(),
         | 
| 170 | 
            +
                    ];
         | 
| 171 | 
            +
                    klass.protect_send("new", &args).unwrap()
         | 
| 117 172 | 
             
                }
         | 
| 118 173 | 
             
            );
         | 
| 119 174 |  | 
| @@ -135,6 +190,8 @@ pub extern "C" fn Init_enquo() { | |
| 135 190 | 
             
                        .define(|fieldklass| {
         | 
| 136 191 | 
             
                            fieldklass.def_private("_encrypt_i64", enquo_field_encrypt_i64);
         | 
| 137 192 | 
             
                            fieldklass.def_private("_decrypt_i64", enquo_field_decrypt_i64);
         | 
| 193 | 
            +
                            fieldklass.def_private("_encrypt_date", enquo_field_encrypt_date);
         | 
| 194 | 
            +
                            fieldklass.def_private("_decrypt_date", enquo_field_decrypt_date);
         | 
| 138 195 | 
             
                        });
         | 
| 139 196 | 
             
                    topmod.define_nested_module("RootKey").define(|rkmod| {
         | 
| 140 197 | 
             
                        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
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            require "date"
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module Enquo
         | 
| 2 4 | 
             
            	class Field
         | 
| 3 5 | 
             
            		def self.new(*_)
         | 
| @@ -35,5 +37,37 @@ module Enquo | |
| 35 37 |  | 
| 36 38 | 
             
            			_decrypt_i64(data, ctx)
         | 
| 37 39 | 
             
            		end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            		def encrypt_date(d, ctx, safety: true, no_query: false)
         | 
| 42 | 
            +
            			unless d.is_a?(Date)
         | 
| 43 | 
            +
            				raise ArgumentError, "Enquo::Field#encrypt_date can only encrypt Dates"
         | 
| 44 | 
            +
            			end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            			unless d.year >= -2 ** 15 && d.year < 2 ** 15 - 1
         | 
| 47 | 
            +
            				raise RangeError, "Enquo::Field#encrypt_date can only encrypt dates where the year is between -32,768 and 32,767 (got #{d.year})"
         | 
| 48 | 
            +
            			end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            			unless ctx.is_a?(String)
         | 
| 51 | 
            +
            				raise ArgumentError, "Encryption context must be a string (got a #{ctx.class})"
         | 
| 52 | 
            +
            			end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            			_encrypt_date(d.year, d.month, d.day, ctx, no_query ? :no_query : safety == :unsafe ? :unsafe : :default)
         | 
| 55 | 
            +
            		end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            		def decrypt_date(data, ctx)
         | 
| 58 | 
            +
            			unless data.is_a?(String)
         | 
| 59 | 
            +
            				raise ArgumentError, "Enquo::Field#decrypt_date can only decrypt from a string (got #{data.class})"
         | 
| 60 | 
            +
            			end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            			unless data.encoding == Encoding::UTF_8 && data.valid_encoding?
         | 
| 63 | 
            +
            				raise ArgumentError, "Enquo::Field#decrypt_date can only decrypt validly-encoded UTF-8 strings (got #{data.encoding})"
         | 
| 64 | 
            +
            			end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            			unless ctx.is_a?(String)
         | 
| 67 | 
            +
            				raise ArgumentError, "Encryption context must be a string (got a #{ctx.class})"
         | 
| 68 | 
            +
            			end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            			_decrypt_date(data, ctx)
         | 
| 71 | 
            +
            		end
         | 
| 38 72 | 
             
            	end
         | 
| 39 73 | 
             
            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. | 
| 4 | 
            +
              version: 0.4.0
         | 
| 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- | 
| 11 | 
            +
            date: 2022-10-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |