Module: PQCrypto::JWT::JWA::MLDSA
Instance Method Summary collapse
- #key_kind ⇒ Object
- #pq_crypto_algorithm ⇒ Object
- #sign(data:, signing_key:) ⇒ Object
- #sign_io ⇒ Object
- #streaming_supported? ⇒ Boolean
- #valid_alg?(alg_to_validate) ⇒ Boolean
- #verify(data:, signature:, verification_key:) ⇒ Object
- #verify_io ⇒ Object
- #verify_io! ⇒ Object
Instance Method Details
#key_kind ⇒ Object
34 35 36 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 34 def key_kind :signature end |
#pq_crypto_algorithm ⇒ Object
14 15 16 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 14 def pq_crypto_algorithm self::PQ_CRYPTO_ALGORITHM end |
#sign(data:, signing_key:) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 38 def sign(data:, signing_key:) ensure_secret_key!(signing_key) raise ArgumentError, "data must be a String" unless data.is_a?(String) signing_key.sign(data.b) rescue PQCrypto::JWT::KeyTypeError, ArgumentError raise rescue StandardError => e raise ::JWT::EncodeError, e. end |
#sign_io ⇒ Object
22 23 24 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 22 def sign_io(**) raise PQCrypto::JWT::UnsupportedAlgorithm, "#{alg} does not support streaming JWS" end |
#streaming_supported? ⇒ Boolean
18 19 20 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 18 def streaming_supported? false end |
#valid_alg?(alg_to_validate) ⇒ Boolean
10 11 12 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 10 def valid_alg?(alg_to_validate) alg_to_validate == alg end |
#verify(data:, signature:, verification_key:) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 49 def verify(data:, signature:, verification_key:) return false unless public_key_for_this_algorithm?(verification_key) return false unless data.is_a?(String) return false unless signature.is_a?(String) return false unless signature_length_valid?(signature) verification_key.verify(data.b, signature.b) rescue PQCrypto::InvalidKeyError, PQCrypto::JWT::Error, ArgumentError false end |
#verify_io ⇒ Object
26 27 28 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 26 def verify_io(**) raise PQCrypto::JWT::UnsupportedAlgorithm, "#{alg} does not support streaming JWS" end |
#verify_io! ⇒ Object
30 31 32 |
# File 'lib/pq_crypto/jwt/jwa.rb', line 30 def verify_io!(**) raise PQCrypto::JWT::UnsupportedAlgorithm, "#{alg} does not support streaming JWS" end |