Class: WebAuthn::PublicKey
- Inherits:
-
Object
- Object
- WebAuthn::PublicKey
show all
- Defined in:
- lib/webauthn/public_key.rb
Defined Under Namespace
Classes: UnsupportedAlgorithm
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(cose_key:) ⇒ PublicKey
Returns a new instance of PublicKey.
41
42
43
|
# File 'lib/webauthn/public_key.rb', line 41
def initialize(cose_key:)
@cose_key = cose_key
end
|
Instance Attribute Details
#cose_key ⇒ Object
Returns the value of attribute cose_key.
39
40
41
|
# File 'lib/webauthn/public_key.rb', line 39
def cose_key
@cose_key
end
|
Class Method Details
.deserialize(public_key) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/webauthn/public_key.rb', line 13
def self.deserialize(public_key)
cose_key =
if WebAuthn::AttestationStatement::FidoU2f::PublicKey.uncompressed_point?(public_key)
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
49
50
51
|
# File 'lib/webauthn/public_key.rb', line 49
def alg
@cose_key.alg
end
|
#pkey ⇒ Object
45
46
47
|
# File 'lib/webauthn/public_key.rb', line 45
def pkey
@cose_key.to_pkey
end
|
#verify(signature, verification_data) ⇒ Object
53
54
55
56
57
|
# File 'lib/webauthn/public_key.rb', line 53
def verify(signature, verification_data)
cose_algorithm.verify(pkey, signature, verification_data)
rescue COSE::Error
false
end
|