From aecb0333b03b6235f4c97d111bcc219f1adddfb1 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Mon, 12 Feb 2024 20:15:42 -0800 Subject: [PATCH 1/2] Replace std::basic_string with std::vector In newer versions of libc++, std::char_traits is no longer defined for non-character types, and a result, std::basic_string is also no longer defined. See https://discourse.llvm.org/t/deprecating-std-string-t-for-non-character-t/66779. Bug: 175635923 Test: make checkbuild Change-Id: Icb3937d8b1ff6dbe7e35e62f2e6cc1e2eb789121 --- keymaster/4.0/vts/functional/HmacKeySharingTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keymaster/4.0/vts/functional/HmacKeySharingTest.cpp b/keymaster/4.0/vts/functional/HmacKeySharingTest.cpp index 1bff076859..a076438000 100644 --- a/keymaster/4.0/vts/functional/HmacKeySharingTest.cpp +++ b/keymaster/4.0/vts/functional/HmacKeySharingTest.cpp @@ -51,7 +51,7 @@ class HmacKeySharingTest : public KeymasterHidlTest { }; using KeymasterVec = std::vector>; - using ByteString = std::basic_string; + using ByteString = std::vector; // using NonceVec = std::vector; GetParamsResult getHmacSharingParameters(IKeymasterDevice& keymaster) { @@ -98,7 +98,7 @@ class HmacKeySharingTest : public KeymasterHidlTest { std::vector copyNonces(const hidl_vec& paramsVec) { std::vector nonces; for (auto& param : paramsVec) { - nonces.emplace_back(param.nonce.data(), param.nonce.size()); + nonces.emplace_back(param.nonce.data(), param.nonce.data() + param.nonce.size()); } return nonces; } From 01cf20d711da2c9060d85945d25bb8ae99c6b7e0 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Mon, 12 Feb 2024 20:31:10 -0800 Subject: [PATCH 2/2] Replace std::basic_string_view with std::span In newer versions of libc++, std::char_traits is no longer defined for non-character types, and a result, std::basic_string_view 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 --- .../keymint/support/remote_prov_utils_test.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/security/keymint/support/remote_prov_utils_test.cpp b/security/keymint/support/remote_prov_utils_test.cpp index 630f7bba56..89469f11ad 100644 --- a/security/keymint/support/remote_prov_utils_test.cpp +++ b/security/keymint/support/remote_prov_utils_test.cpp @@ -14,20 +14,23 @@ * limitations under the License. */ -#include "cppbor.h" -#include "keymaster/cppcose/cppcose.h" #include #include +#include #include -#include #include #include #include +#include #include #include #include #include +#include +#include +#include + 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; +using byte_view = std::span; + +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); } };