Module: PQCrypto::Serialization
- Defined in:
- lib/pq_crypto/serialization.rb
Constant Summary collapse
- ALGORITHM_METADATA =
{ ml_kem_768: { family: :ml_kem, oid: "2.25.186599352125448088867056807454444238446", }.freeze, ml_kem_768_x25519_hkdf_sha256: { family: :ml_kem_hybrid, oid: "2.25.260242945110721168101139140490528778800", }.freeze, ml_dsa_65: { family: :ml_dsa, oid: "2.25.305232938483772195555080795650659207792", }.freeze, }.freeze
Class Method Summary collapse
- .algorithm_metadata(algorithm) ⇒ Object
- .algorithm_to_family(algorithm) ⇒ Object
- .algorithm_to_oid(algorithm) ⇒ Object
- .public_key_from_pqc_container_der(expected_algorithm, der) ⇒ Object
- .public_key_from_pqc_container_pem(expected_algorithm, pem) ⇒ Object
- .public_key_to_pqc_container_der(algorithm, bytes) ⇒ Object
- .public_key_to_pqc_container_pem(algorithm, bytes) ⇒ Object
- .secret_key_from_pqc_container_der(expected_algorithm, der) ⇒ Object
- .secret_key_from_pqc_container_pem(expected_algorithm, pem) ⇒ Object
- .secret_key_to_pqc_container_der(algorithm, bytes) ⇒ Object
- .secret_key_to_pqc_container_pem(algorithm, bytes) ⇒ Object
Class Method Details
.algorithm_metadata(algorithm) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/pq_crypto/serialization.rb', line 21 def (algorithm) = ALGORITHM_METADATA[algorithm] raise SerializationError, "Unsupported serialization algorithm: #{algorithm.inspect}" unless end |
.algorithm_to_family(algorithm) ⇒ Object
32 33 34 |
# File 'lib/pq_crypto/serialization.rb', line 32 def algorithm_to_family(algorithm) (algorithm).fetch(:family) end |
.algorithm_to_oid(algorithm) ⇒ Object
28 29 30 |
# File 'lib/pq_crypto/serialization.rb', line 28 def algorithm_to_oid(algorithm) (algorithm).fetch(:oid) end |
.public_key_from_pqc_container_der(expected_algorithm, der) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/pq_crypto/serialization.rb', line 60 def public_key_from_pqc_container_der(expected_algorithm, der) algorithm, bytes = PQCrypto.__send__(:native_public_key_from_pqc_container_der, String(der).b) validate_algorithm_expectation!(expected_algorithm, algorithm) [algorithm, bytes] rescue ArgumentError, PQCrypto::Error => e raise SerializationError, e. end |
.public_key_from_pqc_container_pem(expected_algorithm, pem) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/pq_crypto/serialization.rb', line 68 def public_key_from_pqc_container_pem(expected_algorithm, pem) algorithm, bytes = PQCrypto.__send__(:native_public_key_from_pqc_container_pem, String(pem).b) validate_algorithm_expectation!(expected_algorithm, algorithm) [algorithm, bytes] rescue ArgumentError, PQCrypto::Error => e raise SerializationError, e. end |
.public_key_to_pqc_container_der(algorithm, bytes) ⇒ Object
36 37 38 39 40 |
# File 'lib/pq_crypto/serialization.rb', line 36 def public_key_to_pqc_container_der(algorithm, bytes) PQCrypto.__send__(:native_public_key_to_pqc_container_der, String(algorithm), String(bytes).b) rescue ArgumentError, PQCrypto::Error => e raise SerializationError, e. end |
.public_key_to_pqc_container_pem(algorithm, bytes) ⇒ Object
42 43 44 45 46 |
# File 'lib/pq_crypto/serialization.rb', line 42 def public_key_to_pqc_container_pem(algorithm, bytes) PQCrypto.__send__(:native_public_key_to_pqc_container_pem, String(algorithm), String(bytes).b) rescue ArgumentError, PQCrypto::Error => e raise SerializationError, e. end |
.secret_key_from_pqc_container_der(expected_algorithm, der) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/pq_crypto/serialization.rb', line 76 def secret_key_from_pqc_container_der(expected_algorithm, der) algorithm, bytes = PQCrypto.__send__(:native_secret_key_from_pqc_container_der, String(der).b) validate_algorithm_expectation!(expected_algorithm, algorithm) [algorithm, bytes] rescue ArgumentError, PQCrypto::Error => e raise SerializationError, e. end |
.secret_key_from_pqc_container_pem(expected_algorithm, pem) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/pq_crypto/serialization.rb', line 84 def secret_key_from_pqc_container_pem(expected_algorithm, pem) algorithm, bytes = PQCrypto.__send__(:native_secret_key_from_pqc_container_pem, String(pem).b) validate_algorithm_expectation!(expected_algorithm, algorithm) [algorithm, bytes] rescue ArgumentError, PQCrypto::Error => e raise SerializationError, e. end |
.secret_key_to_pqc_container_der(algorithm, bytes) ⇒ Object
48 49 50 51 52 |
# File 'lib/pq_crypto/serialization.rb', line 48 def secret_key_to_pqc_container_der(algorithm, bytes) PQCrypto.__send__(:native_secret_key_to_pqc_container_der, String(algorithm), String(bytes).b) rescue ArgumentError, PQCrypto::Error => e raise SerializationError, e. end |
.secret_key_to_pqc_container_pem(algorithm, bytes) ⇒ Object
54 55 56 57 58 |
# File 'lib/pq_crypto/serialization.rb', line 54 def secret_key_to_pqc_container_pem(algorithm, bytes) PQCrypto.__send__(:native_secret_key_to_pqc_container_pem, String(algorithm), String(bytes).b) rescue ArgumentError, PQCrypto::Error => e raise SerializationError, e. end |