Module: JsonWebToken::Algorithm::Ecdsa
- Extended by:
- Common, Format::Asn1
- Defined in:
- lib/json_web_token/algorithm/ecdsa.rb
Constant Summary collapse
- MAC_BYTE_COUNT =
{ '256' => 64, # secp256k1 '384' => 96, # secp384r1 '512' => 132 # secp521r1 note difference (not 128) due to using 521-bit integers }
Constants included from Common
Constants included from Format::Asn1
Class Method Summary collapse
Methods included from Common
digest_new, validate_key, validate_sha_bits
Methods included from Format::Asn1
der_to_signature, signature_to_der
Class Method Details
.signed(sha_bits, private_key, data) ⇒ Object
19 20 21 22 23 |
# File 'lib/json_web_token/algorithm/ecdsa.rb', line 19 def signed(sha_bits, private_key, data) validate_key(private_key, sha_bits) der = private_key.dsa_sign_asn1(ssl_digest_hash sha_bits, data) der_to_signature(der, sha_bits) end |
.verified?(signature, sha_bits, key, data) ⇒ Boolean
25 26 27 28 29 30 |
# File 'lib/json_web_token/algorithm/ecdsa.rb', line 25 def verified?(signature, sha_bits, key, data) validate_key(key, sha_bits) validate_signature_size(signature, sha_bits) der = signature_to_der(signature, sha_bits) key.dsa_verify_asn1(ssl_digest_hash(sha_bits, data), der) end |