Replace std::basic_string_view<uint8_t> with std::span

In newer versions of libc++, std::char_traits<T> is no longer defined
for non-character types, and a result, std::basic_string_view<uint8_t>
is also no longer defined. See
https://discourse.llvm.org/t/deprecating-std-string-t-for-non-character-t/66779.

Bug: 175635923
Test: libkeymint_remote_prov_support_test
Change-Id: Ic373e0a3c081b996d4c81a9783103ae6406833f7
This commit is contained in:
Ryan Prichard
2024-02-12 20:31:10 -08:00
parent aecb0333b0
commit 01cf20d711

View File

@@ -14,20 +14,23 @@
* limitations under the License.
*/
#include "cppbor.h"
#include "keymaster/cppcose/cppcose.h"
#include <aidl/android/hardware/security/keymint/RpcHardwareInfo.h>
#include <android-base/properties.h>
#include <cppbor.h>
#include <cppbor_parse.h>
#include <cstdint>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <keymaster/android_keymaster_utils.h>
#include <keymaster/cppcose/cppcose.h>
#include <keymaster/logger.h>
#include <keymaster/remote_provisioning_utils.h>
#include <openssl/curve25519.h>
#include <remote_prov/remote_prov_utils.h>
#include <algorithm>
#include <cstdint>
#include <span>
namespace aidl::android::hardware::security::keymint::remote_prov {
namespace {
@@ -36,7 +39,11 @@ using ::keymaster::kStatusFailed;
using ::keymaster::kStatusInvalidEek;
using ::keymaster::StatusOr;
using ::testing::ElementsAreArray;
using byte_view = std::basic_string_view<uint8_t>;
using byte_view = std::span<const uint8_t>;
inline bool equal_byte_views(const byte_view& view1, const byte_view& view2) {
return std::equal(view1.begin(), view1.end(), view2.begin(), view2.end());
}
struct KeyInfoEcdsa {
CoseKeyCurve curve;
@@ -44,7 +51,8 @@ struct KeyInfoEcdsa {
byte_view pubKeyY;
bool operator==(const KeyInfoEcdsa& other) const {
return curve == other.curve && pubKeyX == other.pubKeyX && pubKeyY == other.pubKeyY;
return curve == other.curve && equal_byte_views(pubKeyX, other.pubKeyX) &&
equal_byte_views(pubKeyY, other.pubKeyY);
}
};