Class: WebAuthn::U2fMigrator

Inherits:
Object
  • Object
show all
Defined in:
lib/webauthn/u2f_migrator.rb

Instance Method Summary collapse

Constructor Details

#initialize(app_id:, certificate:, key_handle:, public_key:, counter:) ⇒ U2fMigrator

Returns a new instance of U2fMigrator.



8
9
10
11
12
13
14
# File 'lib/webauthn/u2f_migrator.rb', line 8

def initialize(app_id:, certificate:, key_handle:, public_key:, counter:)
  @app_id = app_id
  @certificate = certificate
  @key_handle = key_handle
  @public_key = public_key
  @counter = counter
end

Instance Method Details

#attestation_trust_pathObject



45
46
47
# File 'lib/webauthn/u2f_migrator.rb', line 45

def attestation_trust_path
  @attestation_trust_path ||= [OpenSSL::X509::Certificate.new(Base64.strict_decode64(@certificate))]
end

#attestation_typeObject



41
42
43
# File 'lib/webauthn/u2f_migrator.rb', line 41

def attestation_type
  WebAuthn::AttestationStatement::ATTESTATION_TYPE_BASIC_OR_ATTCA
end

#authenticator_dataObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/webauthn/u2f_migrator.rb', line 16

def authenticator_data
  @authenticator_data ||= WebAuthn::FakeAuthenticator::AuthenticatorData.new(
    rp_id_hash: OpenSSL::Digest::SHA256.digest(@app_id.to_s),
    credential: {
      id: credential_id,
      public_key: credential_cose_key
    },
    sign_count: @counter,
    user_present: true,
    user_verified: false,
    aaguid: WebAuthn::AuthenticatorData::AttestedCredentialData::ZEROED_AAGUID
  )
end

#credentialObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/webauthn/u2f_migrator.rb', line 30

def credential
  @credential ||=
    begin
      hash = authenticator_data.send(:credential)
      WebAuthn::AuthenticatorData::AttestedCredentialData::Credential.new(
        id: hash[:id],
        public_key: hash[:public_key].serialize
      )
    end
end