Class: Devicecheck::Data::AuthenticatorData

Inherits:
Object
  • Object
show all
Defined in:
lib/devicecheck/data/authenticator_data.rb

Overview

Unpacks authenticator data according to the webauthn specification.

Authenticator data layout:
-------------------------

rp_id_hash = 32 bytes
flags = 1 byte
sign-count = 4 bytes
aaguid = 16
attestedCredentialData (variable)
- aaguid = 16
  credentialIdLength(L) = 2
  credentialId = L
  credentialPublicKey = variable
extension (variable)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.unpackObject



39
# File 'lib/devicecheck/data/authenticator_data.rb', line 39

def self.unpack(...) = new.unpack(...)

Instance Method Details

#unpack(auth_data) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/devicecheck/data/authenticator_data.rb', line 41

def unpack(auth_data)
  (rp_id_hash, flags, sign_count, trailing_bytes) =
    auth_data.unpack('a32c1N1a*')

  (aaguid, credential_id_length, trailing_bytes) =
    trailing_bytes.unpack('a16na*')

  (credential_id, credential_public_key) =
    trailing_bytes.unpack("a#{credential_id_length}a*")

  [rp_id_hash, flags, sign_count, aaguid,
   credential_id, credential_public_key]
end