Class: WebAuthn::AttestationStatement::FidoU2f::PublicKey
- Inherits:
-
Object
- Object
- WebAuthn::AttestationStatement::FidoU2f::PublicKey
- Defined in:
- lib/webauthn/attestation_statement/fido_u2f/public_key.rb
Constant Summary collapse
- COORDINATE_LENGTH =
32
- UNCOMPRESSED_FORM_INDICATOR =
"\x04"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ PublicKey
constructor
A new instance of PublicKey.
- #to_uncompressed_point ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ PublicKey
Returns a new instance of PublicKey.
20 21 22 |
# File 'lib/webauthn/attestation_statement/fido_u2f/public_key.rb', line 20 def initialize(data) @data = data end |
Class Method Details
.uncompressed_point?(data) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/webauthn/attestation_statement/fido_u2f/public_key.rb', line 14 def self.uncompressed_point?(data) data.size && data.length == UNCOMPRESSED_FORM_INDICATOR.length + COORDINATE_LENGTH * 2 && data[0] == UNCOMPRESSED_FORM_INDICATOR end |
Instance Method Details
#to_uncompressed_point ⇒ Object
31 32 33 |
# File 'lib/webauthn/attestation_statement/fido_u2f/public_key.rb', line 31 def to_uncompressed_point UNCOMPRESSED_FORM_INDICATOR + cose_key.x + cose_key.y end |
#valid? ⇒ Boolean
24 25 26 27 28 29 |
# File 'lib/webauthn/attestation_statement/fido_u2f/public_key.rb', line 24 def valid? data.size >= COORDINATE_LENGTH * 2 && cose_key.x.length == COORDINATE_LENGTH && cose_key.y.length == COORDINATE_LENGTH && cose_key.alg == COSE::Algorithm.by_name("ES256").id end |