Module: PQCrypto::Serialization
- Defined in:
- lib/pq_crypto/serialization.rb
Constant Summary collapse
- ALGORITHM_METADATA =
AlgorithmRegistry..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
8 9 10 11 12 13 |
# File 'lib/pq_crypto/serialization.rb', line 8 def (algorithm) = ALGORITHM_METADATA[algorithm] raise SerializationError, "Unsupported serialization algorithm: #{algorithm.inspect}" unless end |
.algorithm_to_family(algorithm) ⇒ Object
19 20 21 |
# File 'lib/pq_crypto/serialization.rb', line 19 def algorithm_to_family(algorithm) (algorithm).fetch(:family) end |
.algorithm_to_oid(algorithm) ⇒ Object
15 16 17 |
# File 'lib/pq_crypto/serialization.rb', line 15 def algorithm_to_oid(algorithm) (algorithm).fetch(:oid) end |
.public_key_from_pqc_container_der(expected_algorithm, der) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/pq_crypto/serialization.rb', line 47 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
55 56 57 58 59 60 61 |
# File 'lib/pq_crypto/serialization.rb', line 55 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
23 24 25 26 27 |
# File 'lib/pq_crypto/serialization.rb', line 23 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
29 30 31 32 33 |
# File 'lib/pq_crypto/serialization.rb', line 29 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
63 64 65 66 67 68 69 |
# File 'lib/pq_crypto/serialization.rb', line 63 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
71 72 73 74 75 76 77 |
# File 'lib/pq_crypto/serialization.rb', line 71 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
35 36 37 38 39 |
# File 'lib/pq_crypto/serialization.rb', line 35 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
41 42 43 44 45 |
# File 'lib/pq_crypto/serialization.rb', line 41 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 |