Class: Linzer::ECDSA::Key
- Inherits:
-
Key
- Object
- Key
- Linzer::ECDSA::Key
- Defined in:
- lib/linzer/ecdsa.rb
Overview
Note:
ECDSA signatures are converted between DER format (used by OpenSSL) and the concatenated r||s format required by RFC 9421.
ECDSA signing key implementation.
ECDSA keys provide a good balance of security and performance. Supported algorithm identifiers:
ecdsa-p256-sha256- NIST P-256 curve with SHA-256ecdsa-p384-sha384- NIST P-384 curve with SHA-384
Instance Method Summary collapse
-
#sign(data) ⇒ String
Signs data using the ECDSA private key.
- #validate ⇒ Object private
-
#verify(signature, data) ⇒ Boolean
Verifies a signature using the ECDSA public key.
Instance Method Details
#sign(data) ⇒ String
Signs data using the ECDSA private key.
The signature is returned in concatenated r||s format as required by RFC 9421, not in DER format.
44 45 46 47 |
# File 'lib/linzer/ecdsa.rb', line 44 def sign(data) validate_signing_key decode_der_signature(material.sign(@params[:digest], data)) end |
#validate ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 |
# File 'lib/linzer/ecdsa.rb', line 31 def validate super validate_digest end |
#verify(signature, data) ⇒ Boolean
Verifies a signature using the ECDSA public key.
Expects the signature in concatenated r||s format as specified by RFC 9421.
59 60 61 62 |
# File 'lib/linzer/ecdsa.rb', line 59 def verify(signature, data) validate_verify_key material.verify(@params[:digest], der_signature(signature), data) end |