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

Commit d1be691

Browse files
committed
Send proper error code when SEP and laptop is closed
1 parent 9564745 commit d1be691

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

SoftU2FTool/KnownFacets.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ let KnownFacets: [Data: String] = [
1515
SHA256.digest("https://vault.bitwarden.com/app-id.json"): "https://vault.bitwarden.com",
1616
SHA256.digest("https://keepersecurity.com"): "https://keepersecurity.com",
1717
SHA256.digest("https://api-9dcf9b83.duosecurity.com"): "https://api-9dcf9b83.duosecurity.com",
18-
SHA256.digest("https://dashboard.stripe.com"): "https://dashboard.stripe.com"
18+
SHA256.digest("https://dashboard.stripe.com"): "https://dashboard.stripe.com",
19+
20+
// When we return an error during authentication, Chrome will send a registration request with
21+
// a bogus AppID.
22+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA".data(using: .ascii)!: "bogus"
1923
]

SoftU2FTool/U2FAuthenticator.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ class U2FAuthenticator {
9898
let req = try APDU.RegisterRequest(raw: raw)
9999

100100
let facet = KnownFacets[req.applicationParameter]
101+
102+
// When we return an error during authentication, Chrome will send a registration request with
103+
// a bogus AppID.
104+
if facet == "bogus" {
105+
self.sendError(status: .OtherError, cid: cid)
106+
return
107+
}
108+
101109
let notification = UserPresence.Notification.Register(facet: facet)
102110

103111
UserPresence.test(notification) { tupSuccess in
@@ -155,7 +163,7 @@ class U2FAuthenticator {
155163

156164
if reg.inSEP && !laptopIsOpen {
157165
// Can't use SEP/TouchID if laptop is closed.
158-
sendError(status: .OtherError, cid: cid)
166+
sendError(status: .ConditionsNotSatisfied, cid: cid)
159167
return
160168
}
161169

0 commit comments

Comments
 (0)