capbac 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8c94180a1ba2aae3ee93fef73743ec1527836c7dabcb77c807fd9ec8bccec1e
4
- data.tar.gz: 3e819f48d2ab757cdf14ad5b8f66b21844ab713d6d4ee39f856602f3d16ac739
3
+ metadata.gz: 9aea3202cf722c59f88ff0cc3ac473c5d70d05727bf2887a9665ff554552fa02
4
+ data.tar.gz: e0a1ea74ed0b853ccb8e3619015bd599f4f20ea30f8c9eb4caadf331dbfc979f
5
5
  SHA512:
6
- metadata.gz: 13964f92d0cc1f7ba8e3e1d9d011c5de8fe6135fd8b8c2c3f704484642e055d280ff92167e5eed7b8c286249e182c92d04a7a5c8fe4244e61aa280a626214209
7
- data.tar.gz: '082bda60f8a29e84e9922af550dc4535406bfcbb822866087fd04b3c94de377248a050c80e35ea23842f3200ca7fd1c0080107cbe2b63988b96b241e86f6298c'
6
+ metadata.gz: 1ea6fb01de7bd48e299b32602b2ee276bbed2581c2e75fb724deba69f776386edb05b61e6492867152d97bb02989b894145dee0a8bf6d94bdd301d60ee181f55
7
+ data.tar.gz: f1a7f43fbfb3df31dc1272edd15f74b27c3b29fcf83c4b765290f976a5eec5e07f3c1cdfb63772f1e6fe4813f1df3eea0fb224b6bda2ae80697f60e22732b4c2
data/Cargo.toml CHANGED
@@ -11,6 +11,7 @@ crate-type = ["cdylib"]
11
11
  rutie = "0.6.1"
12
12
  url = "2.1"
13
13
  openssl = "0.10"
14
+ ring = "0.16.15"
14
15
  lazy_static = "1"
15
16
  protobuf = "2.16.2"
16
17
  capbac = "0.2.1"
@@ -1,3 +1,3 @@
1
1
  module CapBAC
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
Binary file
data/src/lib.rs CHANGED
@@ -10,6 +10,11 @@ use openssl::ec::EcKey;
10
10
  use protobuf::{Message};
11
11
  use std::fmt;
12
12
 
13
+ use ring::{
14
+ rand,
15
+ signature::{self, KeyPair, EcdsaKeyPair},
16
+ };
17
+
13
18
  class!(URI);
14
19
 
15
20
  impl VerifiedObject for URI {
@@ -411,6 +416,33 @@ methods!(
411
416
  }
412
417
  );
413
418
 
419
+ class!(KeyGen);
420
+
421
+ methods!(
422
+ KeyGen,
423
+ itself,
424
+
425
+ fn ruby_generate_keypair() -> Hash {
426
+ let rng = rand::SystemRandom::new();
427
+ let key_pair = EcdsaKeyPair::generate_pkcs8(&signature::ECDSA_P256_SHA256_FIXED_SIGNING, &rng).unwrap();
428
+ let mut sk = Array::new();
429
+ for item in key_pair.as_ref().iter() {
430
+ sk.push(Fixnum::new(i64::from(*item)));
431
+ };
432
+
433
+ let key_pair = EcdsaKeyPair::from_pkcs8(&signature::ECDSA_P256_SHA256_FIXED_SIGNING, &key_pair.as_ref()).unwrap();
434
+ let mut pk = Array::new();
435
+ for item in key_pair.public_key().as_ref().iter() {
436
+ pk.push(Fixnum::new(i64::from(*item)));
437
+ };
438
+
439
+ let mut res = Hash::new();
440
+ res.store(Symbol::new("sk"), sk);
441
+ res.store(Symbol::new("pk"), pk);
442
+ res
443
+ }
444
+ );
445
+
414
446
  #[allow(non_snake_case)]
415
447
  #[no_mangle]
416
448
  pub extern "C" fn Init_capbac() {
@@ -427,5 +459,9 @@ pub extern "C" fn Init_capbac() {
427
459
  itself.def("validate_cert", ruby_validator_validate_cert);
428
460
  itself.def("validate_invocation", ruby_validator_validate_invocation);
429
461
  });
462
+
463
+ itself.define_nested_class("KeyPair", None).define(|itself| {
464
+ itself.def("generate!", ruby_generate_keypair);
465
+ });
430
466
  });
431
467
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capbac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Chernyshov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-15 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thermite