Class: WebAuthn::PublicKey
- Inherits:
-
Object
- Object
- WebAuthn::PublicKey
- Defined in:
- lib/webauthn/public_key.rb
Instance Attribute Summary collapse
-
#cose_key ⇒ Object
readonly
Returns the value of attribute cose_key.
Class Method Summary collapse
Instance Method Summary collapse
- #alg ⇒ Object
-
#initialize(cose_key:) ⇒ PublicKey
constructor
A new instance of PublicKey.
- #pkey ⇒ Object
Constructor Details
#initialize(cose_key:) ⇒ PublicKey
Returns a new instance of PublicKey.
37 38 39 |
# File 'lib/webauthn/public_key.rb', line 37 def initialize(cose_key:) @cose_key = cose_key end |
Instance Attribute Details
#cose_key ⇒ Object (readonly)
Returns the value of attribute cose_key.
35 36 37 |
# File 'lib/webauthn/public_key.rb', line 35 def cose_key @cose_key end |
Class Method Details
.deserialize(public_key) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/webauthn/public_key.rb', line 9 def self.deserialize(public_key) cose_key = if WebAuthn::AttestationStatement::FidoU2f::PublicKey.uncompressed_point?(public_key) # Gem version v1.11.0 and lower, used to behave so that Credential#public_key # returned an EC P-256 uncompressed point. # # Because of https://github.com/cedarcode/webauthn-ruby/issues/137 this was changed # and Credential#public_key started returning the unchanged COSE_Key formatted # credentialPublicKey (as in https://www.w3.org/TR/webauthn/#credentialpublickey). # # Given that the credential public key is expected to be stored long-term by the gem # user and later be passed as the public_key argument in the # AuthenticatorAssertionResponse.verify call, we then need to support the two formats. COSE::Key::EC2.new( alg: COSE::Algorithm.by_name("ES256").id, crv: 1, x: public_key[1..32], y: public_key[33..-1] ) else COSE::Key.deserialize(public_key) end new(cose_key: cose_key) end |
Instance Method Details
#alg ⇒ Object
45 46 47 |
# File 'lib/webauthn/public_key.rb', line 45 def alg @cose_key.alg end |
#pkey ⇒ Object
41 42 43 |
# File 'lib/webauthn/public_key.rb', line 41 def pkey @cose_key.to_pkey end |