confium 0.3.0 → 0.3.1

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/Cargo.lock +105 -5
  4. data/Rakefile +7 -7
  5. data/confium.gemspec +28 -28
  6. data/ext/confium_native/Cargo.toml +1 -0
  7. data/ext/confium_native/extconf.rb +4 -4
  8. data/ext/confium_native/src/attributes.rs +1 -1
  9. data/ext/confium_native/src/audit.rs +1 -1
  10. data/ext/confium_native/src/composite.rs +1 -1
  11. data/ext/confium_native/src/deployment.rs +1 -1
  12. data/ext/confium_native/src/ers.rs +1 -1
  13. data/ext/confium_native/src/openpgp.rs +1 -1
  14. data/ext/confium_native/src/path.rs +1 -1
  15. data/ext/confium_native/src/pki.rs +1 -1
  16. data/ext/confium_native/src/tc.rs +2 -2
  17. data/ext/confium_native/src/transparency.rs +5 -3
  18. data/ext/confium_native/src/util.rs +5 -0
  19. data/lib/confium/audit.rb +5 -5
  20. data/lib/confium/cfm.rb +2 -1
  21. data/lib/confium/digest.rb +4 -2
  22. data/lib/confium/errors/coerce.rb +1 -3
  23. data/lib/confium/errors/crypto_error.rb +8 -6
  24. data/lib/confium/errors/index_error.rb +9 -7
  25. data/lib/confium/errors/not_found_error.rb +9 -7
  26. data/lib/confium/errors/parse_error.rb +9 -7
  27. data/lib/confium/errors/policy_violation_error.rb +9 -7
  28. data/lib/confium/errors/threshold_error.rb +9 -7
  29. data/lib/confium/errors/unresolved_signer_error.rb +8 -6
  30. data/lib/confium/errors/validation_error.rb +10 -8
  31. data/lib/confium/errors/verification_error.rb +9 -7
  32. data/lib/confium/errors.rb +1 -1
  33. data/lib/confium/ffi.rb +4 -4
  34. data/lib/confium/lib.rb +18 -19
  35. data/lib/confium/pki/certificate_builder.rb +3 -3
  36. data/lib/confium/pki/cms/signed_data_builder.rb +10 -10
  37. data/lib/confium/pki/cms.rb +1 -1
  38. data/lib/confium/pki/cnml.rb +8 -8
  39. data/lib/confium/pki.rb +1 -1
  40. data/lib/confium/policy.rb +13 -13
  41. data/lib/confium/secure_bytes.rb +91 -89
  42. data/lib/confium/tc/coordinator.rb +7 -6
  43. data/lib/confium/tc/session.rb +5 -3
  44. data/lib/confium/tc/session_stub.rb +2 -2
  45. data/lib/confium/tc/share_file.rb +13 -13
  46. data/lib/confium/tc.rb +2 -2
  47. data/lib/confium/version.rb +1 -1
  48. data/lib/confium.rb +20 -20
  49. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36b9e9d9aa6a0b038c85ea24caefa5d0e16e9a4efda0bc9a73b1558cc2b52d97
4
- data.tar.gz: d2490e0cf9169a5bf7f05a74600d0a0de115a13d2bb08d58e3e5e121cbe39d2c
3
+ metadata.gz: 975eebface92795a6a5493274a696fae3bd9bc451fdd8011be74af8ab5bf7b9b
4
+ data.tar.gz: a0b92a831f5391175e789fbc02ad5e674d097b20d92e1fd7059cc91890a9fbc8
5
5
  SHA512:
6
- metadata.gz: fd4fde001b8e29ce40d58df86914b2ef6f5322d48bee02858df0a954a7e1575ef4ce42750acd27830bbe1e4ad6e247df56931c9bd8ee1eff0f25b9477fed8602
7
- data.tar.gz: 8b99c6f42ee573a1075fc950dc49ec167b3bde4180243df990c2fcab946d2c5a10af6f226434005158e740441dd84097f0efcd2ce0ee72e187e5792237dbc8df
6
+ metadata.gz: 244d4c7edcafe5cc22234cc3ad58676f765e8b840c22b1427817d3ed6e33f22cb5f57415cc2fdc7dccf7faa2bad217ec50ede0ea6a4bfd859ae3ea61ed6e5c25
7
+ data.tar.gz: 8a71c86a8b467209b49e1526d0be8a9c35d528e339851db5703e7a0e64993c70d6d68ea8198c8c22649daa1e3688fabaad8d9d2eb8a32dfb2502ca225e4fb38e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.1] — 2026-08-21
4
+
5
+ Native platform gems (linux x86_64/aarch64, macOS x86_64/arm64,
6
+ Windows x64-mingw-ucrt) ship alongside the source gem — `gem install`
7
+ no longer needs a Rust toolchain on those platforms.
8
+
9
+ ### Added
10
+
11
+ - ERS archival binding (`Confium::EvidenceRecord`, RFC 4998) and the
12
+ `CONFIUM_LIB` explicit dylib path override.
13
+ - Audit log bindings with sign-triggered autofire and an Enumerable
14
+ `MemorySink`.
15
+ - Typed error hierarchy across all subsystems with native-error
16
+ coercion.
17
+ - CMP20/GG18 in-process threshold ECDSA (`Confium::TC::Cmp20`,
18
+ `Confium::TC::Gg18`) and TC share files with the documented
19
+ envelope shape.
20
+ - Twenty worked examples plus the examples and CNML-profile guides.
21
+
22
+ ### Fixed
23
+
24
+ - The PKI CSR spec no longer shells out to the openssl CLI (it
25
+ generated its fixture with a key file that was never created).
26
+ - CI: first `.rubocop.yml`, Ruby-3.1-compatible lockfile, and a test
27
+ matrix matching the shipped platforms.
28
+
3
29
  ## [0.3.0] — 2026-08-04
4
30
 
5
31
  Synced with Confium Rust workspace v0.3.0 (product restructuring).
data/Cargo.lock CHANGED
@@ -1,6 +1,6 @@
1
1
  # This file is automatically @generated by Cargo.
2
2
  # It is not intended for manual editing.
3
- version = 3
3
+ version = 4
4
4
 
5
5
  [[package]]
6
6
  name = "adler2"
@@ -239,6 +239,8 @@ dependencies = [
239
239
  [[package]]
240
240
  name = "confium-api"
241
241
  version = "0.3.0"
242
+ source = "registry+https://github.com/rust-lang/crates.io-index"
243
+ checksum = "edbc3fc8f6518e979ff76837b40c543b85bfc764bac2855d87ae79c68cbfcc5a"
242
244
  dependencies = [
243
245
  "confium-macros",
244
246
  "inventory",
@@ -273,6 +275,8 @@ dependencies = [
273
275
  [[package]]
274
276
  name = "confium-coordinator"
275
277
  version = "0.3.0"
278
+ source = "registry+https://github.com/rust-lang/crates.io-index"
279
+ checksum = "e8c96d4d5997726cf0eb794410e3e8bbce839cfba9c4a32e26ede0c076b02e64"
276
280
  dependencies = [
277
281
  "chrono",
278
282
  "confium-api",
@@ -310,6 +314,45 @@ dependencies = [
310
314
  "zeroize",
311
315
  ]
312
316
 
317
+ [[package]]
318
+ name = "confium-crypto-vss"
319
+ version = "0.3.0"
320
+ source = "registry+https://github.com/rust-lang/crates.io-index"
321
+ checksum = "19bea8bcb5a76b88ccca2471352176ea234e86c1360982f4a1d7357c2f89ab73"
322
+ dependencies = [
323
+ "hex",
324
+ "hmac",
325
+ "num-bigint",
326
+ "num-integer",
327
+ "num-traits",
328
+ "p256",
329
+ "rand",
330
+ "rand_core",
331
+ "serde",
332
+ "serde_json",
333
+ "sha2",
334
+ "subtle",
335
+ "thiserror",
336
+ ]
337
+
338
+ [[package]]
339
+ name = "confium-crypto-zk"
340
+ version = "0.3.0"
341
+ source = "registry+https://github.com/rust-lang/crates.io-index"
342
+ checksum = "f65c763c1e55aee550db1ba49ba0b97fbfd8373766e4ca48d9ca742897c82f34"
343
+ dependencies = [
344
+ "hex",
345
+ "hmac",
346
+ "num-bigint",
347
+ "num-traits",
348
+ "p256",
349
+ "rand_core",
350
+ "serde",
351
+ "serde_json",
352
+ "sha2",
353
+ "thiserror",
354
+ ]
355
+
313
356
  [[package]]
314
357
  name = "confium-deployment"
315
358
  version = "0.3.0"
@@ -329,6 +372,8 @@ dependencies = [
329
372
  [[package]]
330
373
  name = "confium-macros"
331
374
  version = "0.3.0"
375
+ source = "registry+https://github.com/rust-lang/crates.io-index"
376
+ checksum = "783f0dbfa6cd490f4670a5491254f4122d1f87604931724d99a2de37f0a73123"
332
377
  dependencies = [
333
378
  "proc-macro2",
334
379
  "quote",
@@ -338,6 +383,8 @@ dependencies = [
338
383
  [[package]]
339
384
  name = "confium-net"
340
385
  version = "0.3.0"
386
+ source = "registry+https://github.com/rust-lang/crates.io-index"
387
+ checksum = "98a17fd08f3f04772fa0227e0855d38d7de0637996fb44e058da098e069fab28"
341
388
  dependencies = [
342
389
  "confium-api",
343
390
  "inventory",
@@ -345,6 +392,21 @@ dependencies = [
345
392
  "url",
346
393
  ]
347
394
 
395
+ [[package]]
396
+ name = "confium-observability"
397
+ version = "0.3.0"
398
+ source = "registry+https://github.com/rust-lang/crates.io-index"
399
+ checksum = "767f898b6437a5cc67d403140bcf8cd1dbffa35a450afe28c64147e3175ee091"
400
+ dependencies = [
401
+ "chrono",
402
+ "hex",
403
+ "hmac",
404
+ "rand_core",
405
+ "serde",
406
+ "serde_json",
407
+ "sha2",
408
+ ]
409
+
348
410
  [[package]]
349
411
  name = "confium-pki"
350
412
  version = "0.3.1"
@@ -363,9 +425,31 @@ dependencies = [
363
425
  "x509-cert",
364
426
  ]
365
427
 
428
+ [[package]]
429
+ name = "confium-privacy"
430
+ version = "0.3.0"
431
+ source = "registry+https://github.com/rust-lang/crates.io-index"
432
+ checksum = "6dcbe8f16e42291a63bcc480745653aa1ad993982fb708531778270de9677dd9"
433
+ dependencies = [
434
+ "chrono",
435
+ "hex",
436
+ "hmac",
437
+ "num-bigint",
438
+ "num-traits",
439
+ "p256",
440
+ "rand",
441
+ "rand_core",
442
+ "serde",
443
+ "serde_json",
444
+ "sha2",
445
+ "thiserror",
446
+ ]
447
+
366
448
  [[package]]
367
449
  name = "confium-store"
368
450
  version = "0.3.0"
451
+ source = "registry+https://github.com/rust-lang/crates.io-index"
452
+ checksum = "66f760cf6182b532f7746b95842e2b4599ab78a5bbe35af2992df309417e5975"
369
453
  dependencies = [
370
454
  "confium-api",
371
455
  "inventory",
@@ -374,7 +458,9 @@ dependencies = [
374
458
 
375
459
  [[package]]
376
460
  name = "confium-tc"
377
- version = "0.3.0"
461
+ version = "0.3.1"
462
+ source = "registry+https://github.com/rust-lang/crates.io-index"
463
+ checksum = "3dd7d4965aef12324cb76d397294c317b83b774de029f1d37b387cf54ba9593c"
378
464
  dependencies = [
379
465
  "chrono",
380
466
  "confium-api",
@@ -405,7 +491,9 @@ dependencies = [
405
491
 
406
492
  [[package]]
407
493
  name = "confium-tc-cmp20"
408
- version = "0.3.0"
494
+ version = "0.3.1"
495
+ source = "registry+https://github.com/rust-lang/crates.io-index"
496
+ checksum = "7f28758121e44a86beefdf54a63428ab9bd9ec7a3797f7c065351b876518815c"
409
497
  dependencies = [
410
498
  "confium-tc",
411
499
  "confium-tc-core",
@@ -426,6 +514,8 @@ dependencies = [
426
514
  [[package]]
427
515
  name = "confium-tc-core"
428
516
  version = "0.3.0"
517
+ source = "registry+https://github.com/rust-lang/crates.io-index"
518
+ checksum = "add3e15337ce81944f78c9ce844d870a081cbe91506a85b9a5c4e4c0da983771"
429
519
  dependencies = [
430
520
  "chrono",
431
521
  "confium-api",
@@ -477,7 +567,9 @@ dependencies = [
477
567
 
478
568
  [[package]]
479
569
  name = "confium-tc-gg18"
480
- version = "0.3.0"
570
+ version = "0.3.1"
571
+ source = "registry+https://github.com/rust-lang/crates.io-index"
572
+ checksum = "f5e3522da6c2352ff26f1a0719781e8f392cdfb7c264c681c87d0f0207540384"
481
573
  dependencies = [
482
574
  "confium-tc",
483
575
  "confium-tc-core",
@@ -494,6 +586,8 @@ dependencies = [
494
586
  [[package]]
495
587
  name = "confium-tc-keys"
496
588
  version = "0.3.0"
589
+ source = "registry+https://github.com/rust-lang/crates.io-index"
590
+ checksum = "476fce2efcefa4d7a48cfe5accecd1bc3f39959b5ea719fdedac9cfcbfeeb710"
497
591
  dependencies = [
498
592
  "chrono",
499
593
  "confium-tc-core",
@@ -525,15 +619,21 @@ dependencies = [
525
619
 
526
620
  [[package]]
527
621
  name = "confium_native"
528
- version = "0.1.0"
622
+ version = "0.3.0"
529
623
  dependencies = [
530
624
  "chrono",
531
625
  "confium-attributes",
532
626
  "confium-composite",
533
627
  "confium-core",
628
+ "confium-crypto-vss",
629
+ "confium-crypto-zk",
534
630
  "confium-deployment",
631
+ "confium-observability",
535
632
  "confium-pki",
633
+ "confium-privacy",
634
+ "confium-tc",
536
635
  "confium-tc-cmp20",
636
+ "confium-tc-core",
537
637
  "confium-tc-elgamal-p256",
538
638
  "confium-tc-frost-p256",
539
639
  "confium-tc-gg18",
data/Rakefile CHANGED
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- require "rubocop/rake_task"
7
+ require 'rubocop/rake_task'
8
8
  RuboCop::RakeTask.new
9
9
 
10
- require "rb_sys/extensiontask"
11
- gemspec = Gem::Specification.load("confium.gemspec")
12
- RbSys::ExtensionTask.new("confium_native", gemspec) do |ext|
13
- ext.lib_dir = "lib/confium_native"
10
+ require 'rb_sys/extensiontask'
11
+ gemspec = Gem::Specification.load('confium.gemspec')
12
+ RbSys::ExtensionTask.new('confium_native', gemspec) do |ext|
13
+ ext.lib_dir = 'lib/confium_native'
14
14
  end
15
15
 
16
16
  task compile: :clean
data/confium.gemspec CHANGED
@@ -1,35 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/confium/version"
3
+ require_relative 'lib/confium/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "confium"
6
+ spec.name = 'confium'
7
7
  spec.version = Confium::VERSION
8
8
  spec.platform = Gem::Platform::RUBY
9
9
 
10
- spec.authors = ["Ribose Open"]
11
- spec.email = ["open.source@ribose.com"]
10
+ spec.authors = ['Ribose Open']
11
+ spec.email = ['open.source@ribose.com']
12
12
 
13
- spec.summary = "Ruby bindings for the Confium multi-stakeholder threshold cryptography framework."
14
- spec.description = "Confium provides threshold cryptography for Ruby: FROST / CMP20 / GG18 " \
15
- "signing sessions, X.509 certificate issuance (CNML-ready), composite " \
16
- "PQ-migration signatures, and transparency-log anchoring. Powered by a " \
17
- "Rust native extension (magnus + rb_sys) — no separate C ABI to install."
18
- spec.homepage = "https://www.confium.org"
19
- spec.license = "BSD-2-Clause"
13
+ spec.summary = 'Ruby bindings for the Confium multi-stakeholder threshold cryptography framework.'
14
+ spec.description = 'Confium provides threshold cryptography for Ruby: FROST / CMP20 / GG18 ' \
15
+ 'signing sessions, X.509 certificate issuance (CNML-ready), composite ' \
16
+ 'PQ-migration signatures, and transparency-log anchoring. Powered by a ' \
17
+ 'Rust native extension (magnus + rb_sys) — no separate C ABI to install.'
18
+ spec.homepage = 'https://www.confium.org'
19
+ spec.license = 'BSD-2-Clause'
20
20
 
21
21
  spec.metadata = {
22
- "bug_tracker_uri" => "https://github.com/confium/confium-ruby/issues",
23
- "changelog_uri" => "https://github.com/confium/confium-ruby/blob/main/CHANGELOG.md",
24
- "homepage_uri" => spec.homepage,
25
- "source_code_uri" => "https://github.com/confium/confium-ruby",
26
- "rubygems_mfa_required" => "true",
22
+ 'bug_tracker_uri' => 'https://github.com/confium/confium-ruby/issues',
23
+ 'changelog_uri' => 'https://github.com/confium/confium-ruby/blob/main/CHANGELOG.md',
24
+ 'homepage_uri' => spec.homepage,
25
+ 'source_code_uri' => 'https://github.com/confium/confium-ruby',
26
+ 'rubygems_mfa_required' => 'true'
27
27
  }
28
28
 
29
29
  # Rust extension — compiled at gem install via rb_sys.
30
- spec.extensions = ["ext/confium_native/extconf.rb"]
30
+ spec.extensions = ['ext/confium_native/extconf.rb']
31
31
 
32
- spec.files = Dir.glob("{lib,ext}/**/*") + %w[
32
+ spec.files = Dir.glob('{lib,ext}/**/*') + %w[
33
33
  CHANGELOG.md
34
34
  LICENSE.txt
35
35
  Rakefile
@@ -40,17 +40,17 @@ Gem::Specification.new do |spec|
40
40
  ]
41
41
  spec.files.reject! { |f| File.directory?(f) }
42
42
  spec.files.reject! { |f| f =~ /\.(dll|so|dylib|lib|bundle)\Z/ }
43
- spec.require_paths = ["lib"]
43
+ spec.require_paths = ['lib']
44
44
 
45
- spec.required_ruby_version = ">= 3.1.0"
45
+ spec.required_ruby_version = '>= 3.1.0'
46
46
 
47
47
  # Required for the Rust extension.
48
- spec.add_dependency "rb_sys", "~> 0.9.39"
49
-
50
- spec.add_development_dependency "rake", "~> 13.0"
51
- spec.add_development_dependency "rake-compiler", "~> 1.2.0"
52
- spec.add_development_dependency "rake-compiler-dock", "~> 1.3"
53
- spec.add_development_dependency "rspec", "~> 3.0"
54
- spec.add_development_dependency "rubocop", "~> 1.0"
55
- spec.add_development_dependency "steep", "~> 1.5"
48
+ spec.add_dependency 'rb_sys', '~> 0.9.39'
49
+
50
+ spec.add_development_dependency 'rake', '~> 13.0'
51
+ spec.add_development_dependency 'rake-compiler', '~> 1.2.0'
52
+ spec.add_development_dependency 'rake-compiler-dock', '~> 1.3'
53
+ spec.add_development_dependency 'rspec', '~> 3.0'
54
+ spec.add_development_dependency 'rubocop', '~> 1.0'
55
+ spec.add_development_dependency 'steep', '~> 1.5'
56
56
  end
@@ -50,6 +50,7 @@ ed25519-dalek = { version = "2", features = ["rand_core"] }
50
50
  rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
51
51
 
52
52
  sha2 = "0.10"
53
+ subtle = "2"
53
54
  chrono = "0.4"
54
55
  hex = "0.4"
55
56
  serde_json = "1"
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "mkmf"
4
- require "rb_sys/mkmf"
3
+ require 'mkmf'
4
+ require 'rb_sys/mkmf'
5
5
 
6
- create_rust_makefile("confium_native") do |r|
7
- r.profile = ENV.fetch("RB_SYS_CARGO_PROFILE", :dev).to_sym
6
+ create_rust_makefile('confium_native') do |r|
7
+ r.profile = ENV.fetch('RB_SYS_CARGO_PROFILE', :dev).to_sym
8
8
  r.use_stable_api_compiled_fallback = true
9
9
  r.force_install_rust_toolchain = false
10
10
  end
@@ -12,7 +12,7 @@
12
12
 
13
13
  use confium_attributes::{evaluate, parse as dsl_parse, Predicate, SignerAttributes};
14
14
  use magnus::{
15
- exception, function, method, prelude::*, typed_data::Obj, DataTypeFunctions, Error, Module,
15
+ exception, function, method, typed_data::Obj, DataTypeFunctions, Error, Module,
16
16
  Object, Ruby, TryConvert, TypedData, Value,
17
17
  };
18
18
 
@@ -11,7 +11,7 @@
11
11
  //! sink raises, the calling operation still succeeds. Audit
12
12
  //! failures must never break a signing ceremony.
13
13
 
14
- use magnus::{exception, function, prelude::*, Error, Module, Object, RHash, Ruby, Value};
14
+ use magnus::{exception, function, prelude::*, Error, Module, Ruby, Value};
15
15
  use sha2::{Digest, Sha256};
16
16
 
17
17
  const SINK_IVAR: &str = "@sink";
@@ -12,7 +12,7 @@
12
12
  //! with `#all_verified?` and `#per_component` accessors.
13
13
 
14
14
  use confium_composite::{CompositeSignature, ComponentSignature, VerificationResult};
15
- use ed25519_dalek::{Signer, SigningKey};
15
+ use ed25519_dalek::SigningKey;
16
16
  use magnus::{
17
17
  exception, function, method, prelude::*, scan_args,
18
18
  typed_data::Obj, DataTypeFunctions, Error, IntoValue,
@@ -12,7 +12,7 @@ use confium_deployment::{
12
12
  validate::validate_manifest,
13
13
  };
14
14
  use crate::util::enforce_size;
15
- use magnus::{exception, function, method, prelude::*, typed_data::Obj, DataTypeFunctions, Error, Module, Object, Ruby, TypedData};
15
+ use magnus::{exception, function, method, typed_data::Obj, DataTypeFunctions, Error, Module, Object, Ruby, TypedData};
16
16
 
17
17
  #[derive(TypedData, DataTypeFunctions)]
18
18
  #[magnus(class = "Confium::Identity::Actor", size)]
@@ -5,7 +5,7 @@ use confium_transparency::ers::{
5
5
  EvidenceRecord, HashAlgorithm,
6
6
  };
7
7
  use magnus::{
8
- exception, function, method, prelude::*, typed_data::Obj,
8
+ exception, function, method, typed_data::Obj,
9
9
  DataTypeFunctions, Error, Module, Object, Ruby, TryConvert, TypedData, Value,
10
10
  };
11
11
 
@@ -39,7 +39,7 @@ fn native_dearmor(ruby: &Ruby, data: Value) -> Result<magnus::RString, Error> {
39
39
  }
40
40
 
41
41
  /// Initialize the `Confium::OpenPGP` module.
42
- pub fn init(ruby: &Ruby, parent: RModule) -> Result<(), Error> {
42
+ pub fn init(_ruby: &Ruby, parent: RModule) -> Result<(), Error> {
43
43
  let openpgp = parent.define_module("OpenPGP")?;
44
44
 
45
45
  openpgp.define_singleton_method("_native_armor", function!(native_armor, 2))?;
@@ -10,7 +10,7 @@ use confium_pki::{
10
10
  path::{validate_path, CertPath},
11
11
  result::VerificationResult as PathVerificationResult,
12
12
  };
13
- use magnus::{exception, function, method, prelude::*, DataTypeFunctions, Error, Module, Object, Ruby, TypedData, Value};
13
+ use magnus::{exception, function, method, prelude::*, DataTypeFunctions, Error, Module, Ruby, TypedData, Value};
14
14
 
15
15
  /// Wraps a confium_pki::path::VerificationResult.
16
16
  #[derive(TypedData, DataTypeFunctions)]
@@ -205,7 +205,7 @@ impl SignedData {
205
205
  /// any standards-compliant CMS consumer.
206
206
  fn to_der(&self) -> Result<RString, Error> {
207
207
  let ruby = Ruby::get().map_err(|e| Error::new(exception::runtime_error(), e.to_string()))?;
208
- let der = encode_signed_data_der(&*self.inner.borrow())
208
+ let der = encode_signed_data_der(&self.inner.borrow())
209
209
  .map_err(|e| Error::new(exception::runtime_error(), e.to_string()))?;
210
210
  Ok(bytes_to_rstring(&ruby, &der))
211
211
  }
@@ -97,7 +97,7 @@ fn recover(shares_value: Value) -> Result<magnus::RString, Error> {
97
97
  let secret = recover_secret(&refs)
98
98
  .map_err(|e| Error::new(exception::runtime_error(), e.to_string()))?;
99
99
  let ruby = Ruby::get().map_err(|e| Error::new(exception::runtime_error(), e.to_string()))?;
100
- Ok(bytes_to_rstring(&ruby, &scalar_to_bytes(&secret).to_vec()))
100
+ Ok(bytes_to_rstring(&ruby, scalar_to_bytes(&secret).as_ref()))
101
101
  }
102
102
 
103
103
  fn keypair(ruby: &Ruby) -> Result<RHash, Error> {
@@ -105,7 +105,7 @@ fn keypair(ruby: &Ruby) -> Result<RHash, Error> {
105
105
  let result = ruby.hash_new();
106
106
  let signing_bytes = kp.to_signing_key().to_bytes();
107
107
  let verifying_bytes = kp.to_verifying_key().to_sec1_bytes();
108
- result.aset("private_key", bytes_to_rstring(ruby, &signing_bytes.to_vec()))?;
108
+ result.aset("private_key", bytes_to_rstring(ruby, &signing_bytes))?;
109
109
  result.aset("public_key", bytes_to_rstring(ruby, &verifying_bytes))?;
110
110
  Ok(result)
111
111
  }
@@ -11,7 +11,7 @@ use confium_transparency::{
11
11
  };
12
12
  use magnus::{
13
13
  exception, function, method, prelude::*, typed_data::Obj, DataTypeFunctions, Error, IntoValue,
14
- Module, Object, RHash, RString, Ruby, TryConvert, TypedData, Value,
14
+ Module, Object, RString, Ruby, TryConvert, TypedData, Value,
15
15
  };
16
16
 
17
17
  #[derive(TypedData, DataTypeFunctions)]
@@ -221,7 +221,8 @@ impl InclusionProofWrap {
221
221
  Side::Right => hash_internal(current, step.sibling),
222
222
  };
223
223
  }
224
- Ok(current == root)
224
+ use subtle::ConstantTimeEq;
225
+ Ok(current.ct_eq(&root).into())
225
226
  }
226
227
 
227
228
  /// External-auditor inclusion verification. Accepts an explicit
@@ -255,7 +256,8 @@ impl InclusionProofWrap {
255
256
  Side::Right => hash_internal(current, step.sibling),
256
257
  };
257
258
  }
258
- Ok(current == root)
259
+ use subtle::ConstantTimeEq;
260
+ Ok(current.ct_eq(&root).into())
259
261
  }
260
262
  }
261
263
 
@@ -134,6 +134,7 @@ pub fn new_details(ruby: &Ruby) -> RHash {
134
134
  // only the domain-specific fields; :operation and :component are
135
135
  // filled automatically.
136
136
 
137
+ #[allow(dead_code)]
137
138
  pub fn parse_error(msg: impl Into<String>, operation: &str, format: Option<&str>, offset: Option<usize>) -> Error {
138
139
  let ruby = match Ruby::get() {
139
140
  Ok(r) => r,
@@ -147,6 +148,7 @@ pub fn parse_error(msg: impl Into<String>, operation: &str, format: Option<&str>
147
148
  confium_error(msg, "ParseError", d)
148
149
  }
149
150
 
151
+ #[allow(dead_code)]
150
152
  pub fn validation_error(msg: impl Into<String>, operation: &str, param: &str, expected: &str, actual: &str) -> Error {
151
153
  let ruby = match Ruby::get() {
152
154
  Ok(r) => r,
@@ -160,6 +162,7 @@ pub fn validation_error(msg: impl Into<String>, operation: &str, param: &str, ex
160
162
  confium_error(msg, "ValidationError", d)
161
163
  }
162
164
 
165
+ #[allow(dead_code)]
163
166
  pub fn verification_error(msg: impl Into<String>, operation: &str, signer_index: Option<usize>, algorithm: Option<&str>) -> Error {
164
167
  let ruby = match Ruby::get() {
165
168
  Ok(r) => r,
@@ -172,6 +175,7 @@ pub fn verification_error(msg: impl Into<String>, operation: &str, signer_index:
172
175
  confium_error(msg, "VerificationError", d)
173
176
  }
174
177
 
178
+ #[allow(dead_code)]
175
179
  pub fn crypto_error(msg: impl Into<String>, operation: &str, primitive: &str) -> Error {
176
180
  let ruby = match Ruby::get() {
177
181
  Ok(r) => r,
@@ -183,6 +187,7 @@ pub fn crypto_error(msg: impl Into<String>, operation: &str, primitive: &str) ->
183
187
  confium_error(msg, "CryptoError", d)
184
188
  }
185
189
 
190
+ #[allow(dead_code)]
186
191
  pub fn threshold_error(msg: impl Into<String>, operation: &str, have: usize, need: usize) -> Error {
187
192
  let ruby = match Ruby::get() {
188
193
  Ok(r) => r,
data/lib/confium/audit.rb CHANGED
@@ -12,8 +12,8 @@
12
12
  # per record). Custom sinks can subclass {Sink} for HTTP / syslog /
13
13
  # Kafka backends.
14
14
 
15
- require "json"
16
- require "time"
15
+ require 'json'
16
+ require 'time'
17
17
 
18
18
  module Confium
19
19
  module Audit
@@ -81,8 +81,8 @@ module Confium
81
81
  end
82
82
 
83
83
  # Enumerable contract: yield each record in insertion order.
84
- def each(&block)
85
- @records.each(&block)
84
+ def each(&)
85
+ @records.each(&)
86
86
  end
87
87
  end
88
88
 
@@ -109,7 +109,7 @@ module Confium
109
109
 
110
110
  def initialize(path)
111
111
  @path = path
112
- @io = File.open(path, "a")
112
+ @io = File.open(path, 'a')
113
113
  @io.sync = true
114
114
  end
115
115
 
data/lib/confium/cfm.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ffi'
2
4
 
3
5
  module Confium
@@ -17,6 +19,5 @@ module Confium
17
19
  def load_plugin(name, path)
18
20
  Confium.call_ffi(:cfm_plugin_load, @ptr, name, path, nil, nil)
19
21
  end
20
-
21
22
  end
22
23
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ffi'
2
4
  require 'digest'
3
5
 
4
6
  module Confium
5
7
  class Digest < ::Digest::Class
6
- attr_reader :name
7
- attr_reader :ptr
8
+ attr_reader :name, :ptr
8
9
 
9
10
  def initialize(cfm, name)
10
11
  @name = name
@@ -12,6 +13,7 @@ module Confium
12
13
  Confium.call_ffi(:cfm_hash_create, cfm.ptr, pptr, name, nil, nil, nil)
13
14
  ptr = pptr.read_pointer
14
15
  raise if ptr.null?
16
+
15
17
  @ptr = ::FFI::AutoPointer.new(ptr, self.class.method(:destroy))
16
18
  end
17
19
 
@@ -39,9 +39,7 @@ module Confium
39
39
  kwargs = message.transform_keys(&:to_sym).merge(kwargs)
40
40
  message = kwargs.delete(:message)
41
41
  end
42
- if details_hash.is_a?(Hash)
43
- kwargs = details_hash.transform_keys(&:to_sym).merge(kwargs)
44
- end
42
+ kwargs = details_hash.transform_keys(&:to_sym).merge(kwargs) if details_hash.is_a?(Hash)
45
43
  [message, kwargs]
46
44
  end
47
45
  end
@@ -2,12 +2,14 @@
2
2
 
3
3
  # Raised when a primitive-level crypto operation fails (invalid scalar,
4
4
  # bad key derivation).
5
- class Confium::CryptoError < Confium::Error
6
- attr_reader :primitive
5
+ module Confium
6
+ class CryptoError < Confium::Error
7
+ attr_reader :primitive
7
8
 
8
- def initialize(message = nil, details_hash = nil, **kwargs)
9
- message, kwargs = Confium::Errors::Coerce.args(message, details_hash, kwargs)
10
- @primitive = kwargs.delete(:primitive)
11
- super(message, details: { primitive: @primitive, **kwargs })
9
+ def initialize(message = nil, details_hash = nil, **kwargs)
10
+ message, kwargs = Confium::Errors::Coerce.args(message, details_hash, kwargs)
11
+ @primitive = kwargs.delete(:primitive)
12
+ super(message, details: { primitive: @primitive, **kwargs })
13
+ end
12
14
  end
13
15
  end