Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Send proper error code when SEP and laptop is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
btoews committed Jun 14, 2018
1 parent 9564745 commit d1be691
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion SoftU2FTool/KnownFacets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ let KnownFacets: [Data: String] = [
SHA256.digest("https://vault.bitwarden.com/app-id.json"): "https://vault.bitwarden.com",
SHA256.digest("https://keepersecurity.com"): "https://keepersecurity.com",
SHA256.digest("https://api-9dcf9b83.duosecurity.com"): "https://api-9dcf9b83.duosecurity.com",
SHA256.digest("https://dashboard.stripe.com"): "https://dashboard.stripe.com"
SHA256.digest("https://dashboard.stripe.com"): "https://dashboard.stripe.com",

// When we return an error during authentication, Chrome will send a registration request with
// a bogus AppID.
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA".data(using: .ascii)!: "bogus"
]
10 changes: 9 additions & 1 deletion SoftU2FTool/U2FAuthenticator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ class U2FAuthenticator {
let req = try APDU.RegisterRequest(raw: raw)

let facet = KnownFacets[req.applicationParameter]

// When we return an error during authentication, Chrome will send a registration request with
// a bogus AppID.
if facet == "bogus" {
self.sendError(status: .OtherError, cid: cid)
return
}

let notification = UserPresence.Notification.Register(facet: facet)

UserPresence.test(notification) { tupSuccess in
Expand Down Expand Up @@ -155,7 +163,7 @@ class U2FAuthenticator {

if reg.inSEP && !laptopIsOpen {
// Can't use SEP/TouchID if laptop is closed.
sendError(status: .OtherError, cid: cid)
sendError(status: .ConditionsNotSatisfied, cid: cid)
return
}

Expand Down

0 comments on commit d1be691

Please sign in to comment.