Class: WebAuthn::AuthenticatorData::AttestedCredentialData

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/webauthn/authenticator_data/attested_credential_data.rb

Defined Under Namespace

Classes: Credential

Constant Summary collapse

AAGUID_LENGTH =
16
ZEROED_AAGUID =
0.chr * AAGUID_LENGTH
ID_LENGTH_LENGTH =
2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deserialize(data) ⇒ Object



32
33
34
35
36
# File 'lib/webauthn/authenticator_data/attested_credential_data.rb', line 32

def self.deserialize(data)
  read(data)
rescue EOFError
  raise AttestedCredentialDataFormatError
end

Instance Method Details

#aaguidObject



42
43
44
# File 'lib/webauthn/authenticator_data/attested_credential_data.rb', line 42

def aaguid
  raw_aaguid.unpack("H8H4H4H4H12").join("-")
end

#credentialObject



46
47
48
49
50
51
# File 'lib/webauthn/authenticator_data/attested_credential_data.rb', line 46

def credential
  @credential ||=
    if valid?
      Credential.new(id: id, public_key: public_key, algorithm: algorithm)
    end
end

#lengthObject



53
54
55
56
57
# File 'lib/webauthn/authenticator_data/attested_credential_data.rb', line 53

def length
  if valid?
    AAGUID_LENGTH + ID_LENGTH_LENGTH + id_length + public_key_length
  end
end

#valid?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/webauthn/authenticator_data/attested_credential_data.rb', line 38

def valid?
  valid_credential_public_key?
end