class WebAuthn::AttestationStatement::FidoU2f::PublicKey

Constants

COORDINATE_LENGTH
UNCOMPRESSED_FORM_INDICATOR

Attributes

data[R]

Public Class Methods

new(data) click to toggle source
# File lib/webauthn/attestation_statement/fido_u2f/public_key.rb, line 20
def initialize(data)
  @data = data
end
uncompressed_point?(data) click to toggle source
# 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

Public Instance Methods

to_uncompressed_point() click to toggle source
# 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?() click to toggle source
# 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

Private Instance Methods

cose_key() click to toggle source
# File lib/webauthn/attestation_statement/fido_u2f/public_key.rb, line 39
def cose_key
  @cose_key ||= COSE::Key::EC2.deserialize(data)
end