Commit 55d9942d authored by Martin Kreichgauer's avatar Martin Kreichgauer Committed by Commit Bot

fido: fix a logic bug in VirtualCtap2Authenticator

AreGetAssertionRequestMapKeysCorrect() contained a tautological
comparison. Also clean up the surrounding code a little.

Bug: 995867
Change-Id: Ib585f08a9727d604dfc8af07cc0cb67d8e524fca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762579
Auto-Submit: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Cr-Commit-Position: refs/heads/master@{#688724}
parent b1ba6a3a
...@@ -249,50 +249,40 @@ bool IsMakeCredentialOptionMapFormatCorrect( ...@@ -249,50 +249,40 @@ bool IsMakeCredentialOptionMapFormatCorrect(
const cbor::Value::MapValue& option_map) { const cbor::Value::MapValue& option_map) {
return std::all_of( return std::all_of(
option_map.begin(), option_map.end(), [](const auto& param) { option_map.begin(), option_map.end(), [](const auto& param) {
if (!param.first.is_string()) return param.first.is_string() &&
return false; (param.first.GetString() == kResidentKeyMapKey ||
param.first.GetString() == kUserVerificationMapKey) &&
const auto& key = param.first.GetString(); param.second.is_bool();
return ((key == kResidentKeyMapKey || key == kUserVerificationMapKey) &&
param.second.is_bool());
}); });
} }
bool AreMakeCredentialRequestMapKeysCorrect( bool AreMakeCredentialRequestMapKeysCorrect(
const cbor::Value::MapValue& request_map) { const cbor::Value::MapValue& request_map) {
return std::all_of(request_map.begin(), request_map.end(), return std::all_of(
[](const auto& param) { request_map.begin(), request_map.end(), [](const auto& param) {
if (!param.first.is_integer()) return (param.first.is_integer() && 1u <= param.first.GetInteger() &&
return false; param.first.GetInteger() <= 9u);
});
const auto& key = param.first.GetInteger();
return (key <= 9u && key >= 1u);
});
} }
bool IsGetAssertionOptionMapFormatCorrect( bool IsGetAssertionOptionMapFormatCorrect(
const cbor::Value::MapValue& option_map) { const cbor::Value::MapValue& option_map) {
return std::all_of( return std::all_of(
option_map.begin(), option_map.end(), [](const auto& param) { option_map.begin(), option_map.end(), [](const auto& param) {
if (!param.first.is_string()) return param.first.is_string() &&
return false; (param.first.GetString() == kUserPresenceMapKey ||
param.first.GetString() == kUserVerificationMapKey) &&
const auto& key = param.first.GetString();
return (key == kUserPresenceMapKey || key == kUserVerificationMapKey) &&
param.second.is_bool(); param.second.is_bool();
}); });
} }
bool AreGetAssertionRequestMapKeysCorrect( bool AreGetAssertionRequestMapKeysCorrect(
const cbor::Value::MapValue& request_map) { const cbor::Value::MapValue& request_map) {
return std::all_of(request_map.begin(), request_map.end(), return std::all_of(
[](const auto& param) { request_map.begin(), request_map.end(), [](const auto& param) {
if (!param.first.is_integer()) return (param.first.is_integer() && 1u <= param.first.GetInteger() &&
return false; param.first.GetInteger() <= 7u);
});
const auto& key = param.first.GetInteger();
return (key <= 7u || key >= 1u);
});
} }
base::Optional<std::vector<uint8_t>> GetPINBytestring( base::Optional<std::vector<uint8_t>> GetPINBytestring(
......
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