Commit f67a8091 authored by Martin Kreichgauer's avatar Martin Kreichgauer Committed by Commit Bot

//device/fido/mac: fix a bug in MakeAuthenticatorData

AuthenticatorData was previously created with the hash of the
clientDataJSON, rather than the hash of the RP ID. See
https://www.w3.org/TR/webauthn/#authenticator-data for reference.

Bug: 678128
Change-Id: I1628172212fadedd02a8ccf5daa46237bccd12bd
Reviewed-on: https://chromium-review.googlesource.com/1066486
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: default avatarAdam Langley <agl@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561640}
parent 385e1736
...@@ -41,7 +41,7 @@ const std::string& GetAssertionOperation::RpId() const { ...@@ -41,7 +41,7 @@ const std::string& GetAssertionOperation::RpId() const {
void GetAssertionOperation::Run() { void GetAssertionOperation::Run() {
// Prompt the user for consent. // Prompt the user for consent.
// TODO(martinkr): Localize reason strings. // TODO(martinkr): Localize reason strings.
PromptTouchId("sign in to " + request().rp_id()); PromptTouchId("sign in to " + RpId());
} }
void GetAssertionOperation::PromptTouchIdDone(bool success, NSError* err) { void GetAssertionOperation::PromptTouchIdDone(bool success, NSError* err) {
...@@ -130,8 +130,8 @@ void GetAssertionOperation::PromptTouchIdDone(bool success, NSError* err) { ...@@ -130,8 +130,8 @@ void GetAssertionOperation::PromptTouchIdDone(bool success, NSError* err) {
return; return;
} }
base::Optional<AuthenticatorData> authenticator_data = MakeAuthenticatorData( base::Optional<AuthenticatorData> authenticator_data =
request().client_data_hash(), std::move(credential_id), public_key); MakeAuthenticatorData(RpId(), std::move(credential_id), public_key);
if (!authenticator_data) { if (!authenticator_data) {
DLOG(ERROR) << "MakeAuthenticatorData failed"; DLOG(ERROR) << "MakeAuthenticatorData failed";
std::move(callback()) std::move(callback())
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
#include "device/fido/fido_attestation_statement.h" #include "device/fido/fido_attestation_statement.h"
#include "device/fido/fido_constants.h" #include "device/fido/fido_constants.h"
#include "device/fido/fido_parsing_utils.h"
#include "device/fido/mac/keychain.h" #include "device/fido/mac/keychain.h"
#include "device/fido/mac/util.h" #include "device/fido/mac/util.h"
...@@ -59,7 +60,7 @@ void MakeCredentialOperation::Run() { ...@@ -59,7 +60,7 @@ void MakeCredentialOperation::Run() {
// Prompt the user for consent. // Prompt the user for consent.
// TODO(martinkr): Localize reason strings. // TODO(martinkr): Localize reason strings.
PromptTouchId("register with " + request().rp().rp_id()); PromptTouchId("register with " + RpId());
} }
void MakeCredentialOperation::PromptTouchIdDone(bool success, NSError* err) { void MakeCredentialOperation::PromptTouchIdDone(bool success, NSError* err) {
...@@ -101,8 +102,8 @@ void MakeCredentialOperation::PromptTouchIdDone(bool success, NSError* err) { ...@@ -101,8 +102,8 @@ void MakeCredentialOperation::PromptTouchIdDone(bool success, NSError* err) {
} }
// Delete the key pair for this RP + user handle if one already exists. // Delete the key pair for this RP + user handle if one already exists.
const std::vector<uint8_t> keychain_item_id = KeychainItemIdentifier( const std::vector<uint8_t> keychain_item_id =
request().rp().rp_id(), request().user().user_id()); KeychainItemIdentifier(RpId(), request().user().user_id());
{ {
ScopedCFTypeRef<CFMutableDictionaryRef> query = DefaultKeychainQuery(); ScopedCFTypeRef<CFMutableDictionaryRef> query = DefaultKeychainQuery();
CFDictionarySetValue(query, kSecAttrApplicationLabel, CFDictionarySetValue(query, kSecAttrApplicationLabel,
...@@ -160,8 +161,8 @@ void MakeCredentialOperation::PromptTouchIdDone(bool success, NSError* err) { ...@@ -160,8 +161,8 @@ void MakeCredentialOperation::PromptTouchIdDone(bool success, NSError* err) {
// Create attestation object. There is no separate attestation key pair, so // Create attestation object. There is no separate attestation key pair, so
// we perform self-attestation. // we perform self-attestation.
base::Optional<AuthenticatorData> authenticator_data = MakeAuthenticatorData( base::Optional<AuthenticatorData> authenticator_data =
request().client_data_hash(), keychain_item_id, public_key); MakeAuthenticatorData(RpId(), keychain_item_id, public_key);
if (!authenticator_data) { if (!authenticator_data) {
DLOG(ERROR) << "MakeAuthenticatorData failed"; DLOG(ERROR) << "MakeAuthenticatorData failed";
std::move(callback()) std::move(callback())
......
...@@ -26,10 +26,10 @@ std::vector<uint8_t> KeychainItemIdentifier(std::string rp_id, ...@@ -26,10 +26,10 @@ std::vector<uint8_t> KeychainItemIdentifier(std::string rp_id,
std::vector<uint8_t> user_id); std::vector<uint8_t> user_id);
// MakeAuthenticatorData returns an AuthenticatorData instance for the Touch ID // MakeAuthenticatorData returns an AuthenticatorData instance for the Touch ID
// authenticator with the given client data, credential id and public key. It // authenticator with the given Relying Party ID, credential ID and public key.
// returns |base::nullopt| on failure. // It returns |base::nullopt| on failure.
base::Optional<AuthenticatorData> MakeAuthenticatorData( base::Optional<AuthenticatorData> MakeAuthenticatorData(
std::vector<uint8_t> client_data_hash, const std::string& rp_id,
std::vector<uint8_t> credential_id, std::vector<uint8_t> credential_id,
SecKeyRef public_key) API_AVAILABLE(macosx(10.12.2)); SecKeyRef public_key) API_AVAILABLE(macosx(10.12.2));
......
...@@ -83,7 +83,7 @@ std::vector<uint8_t> KeychainItemIdentifier(std::string rp_id, ...@@ -83,7 +83,7 @@ std::vector<uint8_t> KeychainItemIdentifier(std::string rp_id,
} }
base::Optional<AuthenticatorData> MakeAuthenticatorData( base::Optional<AuthenticatorData> MakeAuthenticatorData(
std::vector<uint8_t> client_data_hash, const std::string& rp_id,
std::vector<uint8_t> credential_id, std::vector<uint8_t> credential_id,
SecKeyRef public_key) API_AVAILABLE(macosx(10.12.2)) { SecKeyRef public_key) API_AVAILABLE(macosx(10.12.2)) {
if (credential_id.size() > 255) { if (credential_id.size() > 255) {
...@@ -103,7 +103,7 @@ base::Optional<AuthenticatorData> MakeAuthenticatorData( ...@@ -103,7 +103,7 @@ base::Optional<AuthenticatorData> MakeAuthenticatorData(
return base::nullopt; return base::nullopt;
} }
return AuthenticatorData( return AuthenticatorData(
std::move(client_data_hash), flags, counter, fido_parsing_utils::CreateSHA256Hash(rp_id), flags, counter,
AttestedCredentialData(kAaguid, encoded_credential_id_length, AttestedCredentialData(kAaguid, encoded_credential_id_length,
std::move(credential_id), std::move(credential_id),
std::move(ec_public_key))); std::move(ec_public_key)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment