send counter value prior to having incremented it

This commit is contained in:
Ben Toews 2017-02-02 17:17:56 -07:00
Родитель de42213a09
Коммит 007eee7e98
2 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -45,12 +45,15 @@ class Keychain {
let err = SecItemDelete(queryDict)
if err != errSecSuccess {
switch err {
case errSecSuccess:
return true
case errSecItemNotFound:
return false
default:
print("Error from keychain: \(err)")
return false
}
return true
}
// Get the given attribute for the given SecKey.

Просмотреть файл

@ -152,10 +152,12 @@ class U2FAuthenticator {
return
}
let counter = reg.counter
let sigPayload = DataWriter()
sigPayload.writeData(req.applicationParameter)
sigPayload.write(UInt8(0x01)) // user present
sigPayload.write(reg.counter)
sigPayload.write(counter)
sigPayload.writeData(req.challengeParameter)
guard let sig = reg.sign(sigPayload.buffer) else {
@ -163,7 +165,7 @@ class U2FAuthenticator {
return
}
let resp = AuthenticationResponse(userPresence: 0x01, counter: reg.counter, signature: sig)
let resp = AuthenticationResponse(userPresence: 0x01, counter: counter, signature: sig)
self.sendMsg(msg: resp, cid: cid)
return
}