Merge changes I487000cc,I9310a851
* changes: Update Keymaster 4.0 VTS to use parameterized tests. Remove dependency on libsoftkeymaster.
This commit is contained in:
commit
a15f40bd0c
9 changed files with 208 additions and 129 deletions
|
@ -52,6 +52,9 @@ inline static hidl_vec<uint8_t> blob2hidlVec(const std::vector<uint8_t>& blob) {
|
|||
HardwareAuthToken hidlVec2AuthToken(const hidl_vec<uint8_t>& buffer);
|
||||
hidl_vec<uint8_t> authToken2HidlVec(const HardwareAuthToken& token);
|
||||
|
||||
uint32_t getOsVersion();
|
||||
uint32_t getOsPatchlevel();
|
||||
|
||||
} // namespace support
|
||||
} // namespace V4_0
|
||||
} // namespace keymaster
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#include <android-base/properties.h>
|
||||
#include <hardware/hw_auth_token.h>
|
||||
#include <keymasterV4_0/keymaster_utils.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace android::hardware {
|
||||
|
||||
inline static bool operator<(const hidl_vec<uint8_t>& a, const hidl_vec<uint8_t>& b) {
|
||||
auto result = memcmp(a.data(), b.data(), std::min(a.size(), b.size()));
|
||||
|
@ -32,8 +34,7 @@ inline static bool operator<(const hidl_array<uint8_t, SIZE>& a,
|
|||
return memcmp(a.data(), b.data(), SIZE) == -1;
|
||||
}
|
||||
|
||||
namespace keymaster {
|
||||
namespace V4_0 {
|
||||
namespace keymaster::V4_0 {
|
||||
|
||||
bool operator<(const HmacSharingParameters& a, const HmacSharingParameters& b) {
|
||||
return std::tie(a.seed, a.nonce) < std::tie(b.seed, b.nonce);
|
||||
|
@ -58,9 +59,9 @@ constexpr size_t kHmacSize = 32;
|
|||
|
||||
hidl_vec<uint8_t> authToken2HidlVec(const HardwareAuthToken& token) {
|
||||
static_assert(1 /* version size */ + sizeof(token.challenge) + sizeof(token.userId) +
|
||||
sizeof(token.authenticatorId) + sizeof(token.authenticatorType) +
|
||||
sizeof(token.timestamp) + kHmacSize ==
|
||||
sizeof(hw_auth_token_t),
|
||||
sizeof(token.authenticatorId) + sizeof(token.authenticatorType) +
|
||||
sizeof(token.timestamp) + kHmacSize ==
|
||||
sizeof(hw_auth_token_t),
|
||||
"HardwareAuthToken content size does not match hw_auth_token_t size");
|
||||
|
||||
hidl_vec<uint8_t> result;
|
||||
|
@ -86,9 +87,9 @@ hidl_vec<uint8_t> authToken2HidlVec(const HardwareAuthToken& token) {
|
|||
HardwareAuthToken hidlVec2AuthToken(const hidl_vec<uint8_t>& buffer) {
|
||||
HardwareAuthToken token;
|
||||
static_assert(1 /* version size */ + sizeof(token.challenge) + sizeof(token.userId) +
|
||||
sizeof(token.authenticatorId) + sizeof(token.authenticatorType) +
|
||||
sizeof(token.timestamp) + kHmacSize ==
|
||||
sizeof(hw_auth_token_t),
|
||||
sizeof(token.authenticatorId) + sizeof(token.authenticatorType) +
|
||||
sizeof(token.timestamp) + kHmacSize ==
|
||||
sizeof(hw_auth_token_t),
|
||||
"HardwareAuthToken content size does not match hw_auth_token_t size");
|
||||
|
||||
if (buffer.size() != sizeof(hw_auth_token_t)) return {};
|
||||
|
@ -100,7 +101,7 @@ HardwareAuthToken hidlVec2AuthToken(const hidl_vec<uint8_t>& buffer) {
|
|||
pos = copy_bytes_from_iterator(&token.authenticatorId, pos);
|
||||
pos = copy_bytes_from_iterator(&token.authenticatorType, pos);
|
||||
token.authenticatorType = static_cast<HardwareAuthenticatorType>(
|
||||
ntohl(static_cast<uint32_t>(token.authenticatorType)));
|
||||
ntohl(static_cast<uint32_t>(token.authenticatorType)));
|
||||
pos = copy_bytes_from_iterator(&token.timestamp, pos);
|
||||
token.timestamp = ntohq(token.timestamp);
|
||||
token.mac.resize(kHmacSize);
|
||||
|
@ -109,8 +110,93 @@ HardwareAuthToken hidlVec2AuthToken(const hidl_vec<uint8_t>& buffer) {
|
|||
return token;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kPlatformVersionProp[] = "ro.build.version.release";
|
||||
constexpr char kPlatformVersionRegex[] = "^([0-9]{1,2})(\\.([0-9]{1,2}))?(\\.([0-9]{1,2}))?";
|
||||
constexpr size_t kMajorVersionMatch = 1;
|
||||
constexpr size_t kMinorVersionMatch = 3;
|
||||
constexpr size_t kSubminorVersionMatch = 5;
|
||||
constexpr size_t kPlatformVersionMatchCount = kSubminorVersionMatch + 1;
|
||||
|
||||
constexpr char kPlatformPatchlevelProp[] = "ro.build.version.security_patch";
|
||||
constexpr char kPlatformPatchlevelRegex[] = "^([0-9]{4})-([0-9]{2})-[0-9]{2}$";
|
||||
constexpr size_t kYearMatch = 1;
|
||||
constexpr size_t kMonthMatch = 2;
|
||||
constexpr size_t kPlatformPatchlevelMatchCount = kMonthMatch + 1;
|
||||
|
||||
uint32_t match_to_uint32(const char* expression, const regmatch_t& match) {
|
||||
if (match.rm_so == -1) return 0;
|
||||
|
||||
size_t len = match.rm_eo - match.rm_so;
|
||||
std::string s(expression + match.rm_so, len);
|
||||
return std::stoul(s);
|
||||
}
|
||||
|
||||
std::string wait_and_get_property(const char* prop) {
|
||||
std::string prop_value;
|
||||
while (!android::base::WaitForPropertyCreation(prop))
|
||||
;
|
||||
prop_value = android::base::GetProperty(prop, "" /* default */);
|
||||
return prop_value;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
uint32_t getOsVersion(const char* version_str) {
|
||||
regex_t regex;
|
||||
if (regcomp(®ex, kPlatformVersionRegex, REG_EXTENDED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
regmatch_t matches[kPlatformVersionMatchCount];
|
||||
int not_match =
|
||||
regexec(®ex, version_str, kPlatformVersionMatchCount, matches, 0 /* flags */);
|
||||
regfree(®ex);
|
||||
if (not_match) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t major = match_to_uint32(version_str, matches[kMajorVersionMatch]);
|
||||
uint32_t minor = match_to_uint32(version_str, matches[kMinorVersionMatch]);
|
||||
uint32_t subminor = match_to_uint32(version_str, matches[kSubminorVersionMatch]);
|
||||
|
||||
return (major * 100 + minor) * 100 + subminor;
|
||||
}
|
||||
|
||||
uint32_t getOsVersion() {
|
||||
std::string version = wait_and_get_property(kPlatformVersionProp);
|
||||
return getOsVersion(version.c_str());
|
||||
}
|
||||
|
||||
uint32_t getOsPatchlevel(const char* patchlevel_str) {
|
||||
regex_t regex;
|
||||
if (regcomp(®ex, kPlatformPatchlevelRegex, REG_EXTENDED) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
regmatch_t matches[kPlatformPatchlevelMatchCount];
|
||||
int not_match =
|
||||
regexec(®ex, patchlevel_str, kPlatformPatchlevelMatchCount, matches, 0 /* flags */);
|
||||
regfree(®ex);
|
||||
if (not_match) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t year = match_to_uint32(patchlevel_str, matches[kYearMatch]);
|
||||
uint32_t month = match_to_uint32(patchlevel_str, matches[kMonthMatch]);
|
||||
|
||||
if (month < 1 || month > 12) {
|
||||
return 0;
|
||||
}
|
||||
return year * 100 + month;
|
||||
}
|
||||
|
||||
uint32_t getOsPatchlevel() {
|
||||
std::string patchlevel = wait_and_get_property(kPlatformPatchlevelProp);
|
||||
return getOsPatchlevel(patchlevel.c_str());
|
||||
}
|
||||
|
||||
} // namespace support
|
||||
} // namespace V4_0
|
||||
} // namespace keymaster
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace keymaster::V4_0
|
||||
} // namespace android::hardware
|
||||
|
|
|
@ -27,7 +27,9 @@ cc_test {
|
|||
"android.hardware.keymaster@4.0",
|
||||
"libcrypto_static",
|
||||
"libkeymaster4support",
|
||||
"libsoftkeymasterdevice",
|
||||
],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts-core",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -28,6 +28,16 @@ namespace test {
|
|||
*/
|
||||
class HmacKeySharingTest : public KeymasterHidlTest {
|
||||
protected:
|
||||
const std::vector<sp<IKeymasterDevice>>& allKeymasters() {
|
||||
if (all_keymasters_.empty()) {
|
||||
auto names = android::hardware::getAllHalInstanceNames(IKeymasterDevice::descriptor);
|
||||
for (const auto& name : names) {
|
||||
all_keymasters_.push_back(IKeymasterDevice::getService(name));
|
||||
}
|
||||
}
|
||||
return all_keymasters_;
|
||||
}
|
||||
|
||||
struct GetParamsResult {
|
||||
ErrorCode error;
|
||||
HmacSharingParameters params;
|
||||
|
@ -99,8 +109,13 @@ class HmacKeySharingTest : public KeymasterHidlTest {
|
|||
EXPECT_EQ(expected, response.sharing_check) << "Sharing check values should match.";
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static std::vector<sp<IKeymasterDevice>> all_keymasters_;
|
||||
};
|
||||
|
||||
std::vector<sp<IKeymasterDevice>> HmacKeySharingTest::all_keymasters_;
|
||||
|
||||
TEST_P(HmacKeySharingTest, GetParameters) {
|
||||
auto result1 = getHmacSharingParameters(keymaster());
|
||||
EXPECT_EQ(ErrorCode::OK, result1.error);
|
||||
|
@ -115,26 +130,26 @@ TEST_P(HmacKeySharingTest, GetParameters) {
|
|||
}
|
||||
|
||||
TEST_P(HmacKeySharingTest, ComputeSharedHmac) {
|
||||
auto params = getHmacSharingParameters(all_keymasters());
|
||||
ASSERT_EQ(all_keymasters().size(), params.size())
|
||||
<< "One or more keymasters failed to provide parameters.";
|
||||
auto params = getHmacSharingParameters(allKeymasters());
|
||||
ASSERT_EQ(allKeymasters().size(), params.size())
|
||||
<< "One or more keymasters failed to provide parameters.";
|
||||
|
||||
auto nonces = copyNonces(params);
|
||||
EXPECT_EQ(all_keymasters().size(), nonces.size());
|
||||
EXPECT_EQ(allKeymasters().size(), nonces.size());
|
||||
std::sort(nonces.begin(), nonces.end());
|
||||
std::unique(nonces.begin(), nonces.end());
|
||||
EXPECT_EQ(all_keymasters().size(), nonces.size());
|
||||
EXPECT_EQ(allKeymasters().size(), nonces.size());
|
||||
|
||||
auto responses = computeSharedHmac(all_keymasters(), params);
|
||||
auto responses = computeSharedHmac(allKeymasters(), params);
|
||||
ASSERT_GT(responses.size(), 0U);
|
||||
verifyResponses(responses[0].sharing_check, responses);
|
||||
|
||||
// Do it a second time. Should get the same answers.
|
||||
params = getHmacSharingParameters(all_keymasters());
|
||||
ASSERT_EQ(all_keymasters().size(), params.size())
|
||||
<< "One or more keymasters failed to provide parameters.";
|
||||
params = getHmacSharingParameters(allKeymasters());
|
||||
ASSERT_EQ(allKeymasters().size(), params.size())
|
||||
<< "One or more keymasters failed to provide parameters.";
|
||||
|
||||
responses = computeSharedHmac(all_keymasters(), params);
|
||||
responses = computeSharedHmac(allKeymasters(), params);
|
||||
ASSERT_GT(responses.size(), 0U);
|
||||
ASSERT_EQ(32U, responses[0].sharing_check.size());
|
||||
verifyResponses(responses[0].sharing_check, responses);
|
||||
|
@ -160,15 +175,16 @@ TEST_P(HmacKeySharingTest, ComputeSharedHmacCorruptNonce) {
|
|||
// sync with respect to the HMAC key. Granted that VTS tests aren't run on in-use production
|
||||
// devices, this still has the potential to cause confusion. To mitigate that, we always
|
||||
// (barring crashes :-/) re-run the unmodified agreement process on our way out.
|
||||
auto fixup_hmac = finally(
|
||||
[&]() { computeSharedHmac(all_keymasters(), getHmacSharingParameters(all_keymasters())); });
|
||||
auto fixup_hmac = finally([&]() {
|
||||
computeSharedHmac(allKeymasters(), getHmacSharingParameters(allKeymasters()));
|
||||
});
|
||||
|
||||
auto params = getHmacSharingParameters(all_keymasters());
|
||||
ASSERT_EQ(all_keymasters().size(), params.size())
|
||||
<< "One or more keymasters failed to provide parameters.";
|
||||
auto params = getHmacSharingParameters(allKeymasters());
|
||||
ASSERT_EQ(allKeymasters().size(), params.size())
|
||||
<< "One or more keymasters failed to provide parameters.";
|
||||
|
||||
// All should be well in the normal case
|
||||
auto responses = computeSharedHmac(all_keymasters(), params);
|
||||
auto responses = computeSharedHmac(allKeymasters(), params);
|
||||
|
||||
ASSERT_GT(responses.size(), 0U);
|
||||
HidlBuf correct_response = responses[0].sharing_check;
|
||||
|
@ -181,7 +197,7 @@ TEST_P(HmacKeySharingTest, ComputeSharedHmacCorruptNonce) {
|
|||
uint8_t bit_to_tweak = rand() % 8;
|
||||
params[param_to_tweak].nonce[byte_to_tweak] ^= (1 << bit_to_tweak);
|
||||
|
||||
responses = computeSharedHmac(all_keymasters(), params);
|
||||
responses = computeSharedHmac(allKeymasters(), params);
|
||||
for (size_t i = 0; i < responses.size(); ++i) {
|
||||
if (i == param_to_tweak) {
|
||||
EXPECT_EQ(ErrorCode::INVALID_ARGUMENT, responses[i].error)
|
||||
|
@ -199,15 +215,16 @@ TEST_P(HmacKeySharingTest, ComputeSharedHmacCorruptSeed) {
|
|||
// sync with respect to the HMAC key. Granted that VTS tests aren't run on in-use production
|
||||
// devices, this still has the potential to cause confusion. To mitigate that, we always
|
||||
// (barring crashes :-/) re-run the unmodified agreement process on our way out.
|
||||
auto fixup_hmac = finally(
|
||||
[&]() { computeSharedHmac(all_keymasters(), getHmacSharingParameters(all_keymasters())); });
|
||||
auto fixup_hmac = finally([&]() {
|
||||
computeSharedHmac(allKeymasters(), getHmacSharingParameters(allKeymasters()));
|
||||
});
|
||||
|
||||
auto params = getHmacSharingParameters(all_keymasters());
|
||||
ASSERT_EQ(all_keymasters().size(), params.size())
|
||||
<< "One or more keymasters failed to provide parameters.";
|
||||
auto params = getHmacSharingParameters(allKeymasters());
|
||||
ASSERT_EQ(allKeymasters().size(), params.size())
|
||||
<< "One or more keymasters failed to provide parameters.";
|
||||
|
||||
// All should be well in the normal case
|
||||
auto responses = computeSharedHmac(all_keymasters(), params);
|
||||
auto responses = computeSharedHmac(allKeymasters(), params);
|
||||
|
||||
ASSERT_GT(responses.size(), 0U);
|
||||
HidlBuf correct_response = responses[0].sharing_check;
|
||||
|
@ -223,7 +240,7 @@ TEST_P(HmacKeySharingTest, ComputeSharedHmacCorruptSeed) {
|
|||
}
|
||||
to_tweak[0]++;
|
||||
|
||||
responses = computeSharedHmac(all_keymasters(), params);
|
||||
responses = computeSharedHmac(allKeymasters(), params);
|
||||
for (size_t i = 0; i < responses.size(); ++i) {
|
||||
if (i == param_to_tweak) {
|
||||
EXPECT_EQ(ErrorCode::INVALID_ARGUMENT, responses[i].error)
|
||||
|
@ -236,10 +253,7 @@ TEST_P(HmacKeySharingTest, ComputeSharedHmacCorruptSeed) {
|
|||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, HmacKeySharingTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IKeymasterDevice::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(HmacKeySharingTest);
|
||||
|
||||
} // namespace test
|
||||
} // namespace V4_0
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <android/hidl/manager/1.0/IServiceManager.h>
|
||||
|
||||
#include <keymasterV4_0/key_param_output.h>
|
||||
#include <keymasterV4_0/keymaster_utils.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
|
@ -41,39 +42,27 @@ namespace V4_0 {
|
|||
|
||||
namespace test {
|
||||
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
void KeymasterHidlTest::InitializeKeymaster() {
|
||||
service_name_ = GetParam();
|
||||
keymaster_ = IKeymasterDevice::getService(service_name_);
|
||||
keymaster_ = IKeymasterDevice::getService(GetParam());
|
||||
ASSERT_NE(keymaster_, nullptr);
|
||||
|
||||
ASSERT_TRUE(keymaster_
|
||||
->getHardwareInfo([&](SecurityLevel securityLevel, const hidl_string& name,
|
||||
const hidl_string& author) {
|
||||
securityLevel_ = securityLevel;
|
||||
name_ = name;
|
||||
author_ = author;
|
||||
})
|
||||
.isOk());
|
||||
->getHardwareInfo([&](SecurityLevel securityLevel, const hidl_string& name,
|
||||
const hidl_string& author) {
|
||||
securityLevel_ = securityLevel;
|
||||
name_ = name;
|
||||
author_ = author;
|
||||
})
|
||||
.isOk());
|
||||
}
|
||||
|
||||
void KeymasterHidlTest::SetUp() {
|
||||
InitializeKeymaster();
|
||||
|
||||
os_version_ = ::keymaster::GetOsVersion();
|
||||
os_patch_level_ = ::keymaster::GetOsPatchlevel();
|
||||
|
||||
auto service_manager = android::hidl::manager::V1_0::IServiceManager::getService();
|
||||
ASSERT_NE(nullptr, service_manager.get());
|
||||
all_keymasters_.push_back(keymaster_);
|
||||
service_manager->listByInterface(
|
||||
IKeymasterDevice::descriptor, [&](const hidl_vec<hidl_string>& names) {
|
||||
for (auto& name : names) {
|
||||
if (name == service_name_) continue;
|
||||
auto keymaster = IKeymasterDevice::getService(name);
|
||||
ASSERT_NE(keymaster, nullptr);
|
||||
all_keymasters_.push_back(keymaster);
|
||||
}
|
||||
});
|
||||
os_version_ = support::getOsVersion();
|
||||
os_patch_level_ = support::getOsPatchlevel();
|
||||
}
|
||||
|
||||
ErrorCode KeymasterHidlTest::GenerateKey(const AuthorizationSet& key_desc, HidlBuf* key_blob,
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <keymaster/keymaster_configuration.h>
|
||||
|
||||
#include <keymasterV4_0/authorization_set.h>
|
||||
|
||||
|
@ -35,13 +34,13 @@ namespace V4_0 {
|
|||
namespace test {
|
||||
|
||||
using ::android::sp;
|
||||
using ::std::string;
|
||||
using hidl::base::V1_0::DebugInfo;
|
||||
using ::std::string;
|
||||
|
||||
class HidlBuf : public hidl_vec<uint8_t> {
|
||||
typedef hidl_vec<uint8_t> super;
|
||||
|
||||
public:
|
||||
public:
|
||||
HidlBuf() {}
|
||||
HidlBuf(const super& other) : super(other) {}
|
||||
HidlBuf(super&& other) : super(std::move(other)) {}
|
||||
|
@ -70,20 +69,16 @@ constexpr uint64_t kOpHandleSentinel = 0xFFFFFFFFFFFFFFFF;
|
|||
|
||||
class KeymasterHidlTest : public ::testing::TestWithParam<std::string> {
|
||||
public:
|
||||
void SetUp();
|
||||
void SetUp() override;
|
||||
void TearDown() override {
|
||||
if (key_blob_.size()) {
|
||||
CheckedDeleteKey();
|
||||
}
|
||||
AbortIfNeeded();
|
||||
keymaster_.clear();
|
||||
all_keymasters_.clear();
|
||||
}
|
||||
|
||||
void InitializeKeymaster();
|
||||
|
||||
IKeymasterDevice& keymaster() { return *keymaster_; }
|
||||
const std::vector<sp<IKeymasterDevice>>& all_keymasters() { return all_keymasters_; }
|
||||
uint32_t os_version() { return os_version_; }
|
||||
uint32_t os_patch_level() { return os_patch_level_; }
|
||||
|
||||
|
@ -209,18 +204,22 @@ class KeymasterHidlTest : public ::testing::TestWithParam<std::string> {
|
|||
KeyCharacteristics key_characteristics_;
|
||||
OperationHandle op_handle_ = kOpHandleSentinel;
|
||||
|
||||
private:
|
||||
sp<IKeymasterDevice> keymaster_;
|
||||
std::vector<sp<IKeymasterDevice>> all_keymasters_;
|
||||
uint32_t os_version_;
|
||||
uint32_t os_patch_level_;
|
||||
private:
|
||||
sp<IKeymasterDevice> keymaster_;
|
||||
uint32_t os_version_;
|
||||
uint32_t os_patch_level_;
|
||||
|
||||
SecurityLevel securityLevel_;
|
||||
hidl_string name_;
|
||||
hidl_string author_;
|
||||
string service_name_;
|
||||
SecurityLevel securityLevel_;
|
||||
hidl_string name_;
|
||||
hidl_string author_;
|
||||
};
|
||||
|
||||
#define INSTANTIATE_KEYMASTER_HIDL_TEST(name) \
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, name, \
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames( \
|
||||
IKeymasterDevice::descriptor)), \
|
||||
android::hardware::PrintInstanceNameToString)
|
||||
|
||||
} // namespace test
|
||||
} // namespace V4_0
|
||||
} // namespace keymaster
|
||||
|
|
|
@ -185,10 +185,7 @@ TEST_P(VerificationTokenTest, MacChangesOnChangingTimestamp) {
|
|||
memcmp(result1.token.mac.data(), result2.token.mac.data(), result1.token.mac.size()));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, VerificationTokenTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IKeymasterDevice::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(VerificationTokenTest);
|
||||
|
||||
} // namespace test
|
||||
} // namespace V4_0
|
||||
|
|
|
@ -840,6 +840,8 @@ TEST_P(NewKeyGenerationTest, HmacDigestNone) {
|
|||
.Authorization(TAG_MIN_MAC_LENGTH, 128)));
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(NewKeyGenerationTest);
|
||||
|
||||
typedef KeymasterHidlTest SigningOperationsTest;
|
||||
|
||||
/*
|
||||
|
@ -1509,6 +1511,8 @@ TEST_P(SigningOperationsTest, HmacRfc4231TestCase5) {
|
|||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(SigningOperationsTest);
|
||||
|
||||
typedef KeymasterHidlTest VerificationOperationsTest;
|
||||
|
||||
/*
|
||||
|
@ -1749,6 +1753,8 @@ TEST_P(VerificationOperationsTest, HmacSigningKeyCannotVerify) {
|
|||
CheckedDeleteKey(&verification_key);
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(VerificationOperationsTest);
|
||||
|
||||
typedef KeymasterHidlTest ExportKeyTest;
|
||||
|
||||
/*
|
||||
|
@ -1828,6 +1834,8 @@ TEST_P(ExportKeyTest, AesKeyUnexportable) {
|
|||
EXPECT_EQ(ErrorCode::UNSUPPORTED_KEY_FORMAT, ExportKey(KeyFormat::RAW, &export_data));
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(ExportKeyTest);
|
||||
|
||||
class ImportKeyTest : public KeymasterHidlTest {
|
||||
public:
|
||||
template <TagType tag_type, Tag tag, typename ValueT>
|
||||
|
@ -2093,6 +2101,8 @@ TEST_P(ImportKeyTest, HmacKeySuccess) {
|
|||
VerifyMessage(message, signature, AuthorizationSetBuilder().Digest(Digest::SHA_2_256));
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(ImportKeyTest);
|
||||
|
||||
auto wrapped_key = hex2str(
|
||||
"3082017902010004820100934bf94e2aa28a3f83c9f79297250262fbe3276b5a1c91159bbfa3ef8957aac84b59b30b"
|
||||
"455a79c2973480823d8b3863c3deef4a8e243590268d80e18751a0e130f67ce6a1ace9f79b95e097474febc981195b"
|
||||
|
@ -2214,6 +2224,8 @@ TEST_P(ImportWrappedKeyTest, WrongPurpose) {
|
|||
.Padding(PaddingMode::RSA_OAEP)));
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(ImportWrappedKeyTest);
|
||||
|
||||
typedef KeymasterHidlTest EncryptionOperationsTest;
|
||||
|
||||
/*
|
||||
|
@ -4111,6 +4123,8 @@ TEST_P(EncryptionOperationsTest, TripleDesCbcIncrementalNoPadding) {
|
|||
EXPECT_EQ(message, plaintext);
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(EncryptionOperationsTest);
|
||||
|
||||
typedef KeymasterHidlTest MaxOperationsTest;
|
||||
|
||||
/*
|
||||
|
@ -4166,6 +4180,8 @@ TEST_P(MaxOperationsTest, TestLimitRsa) {
|
|||
EXPECT_EQ(ErrorCode::KEY_MAX_OPS_EXCEEDED, Begin(KeyPurpose::SIGN, params));
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(MaxOperationsTest);
|
||||
|
||||
typedef KeymasterHidlTest AddEntropyTest;
|
||||
|
||||
/*
|
||||
|
@ -4196,6 +4212,8 @@ TEST_P(AddEntropyTest, AddLargeEntropy) {
|
|||
EXPECT_EQ(ErrorCode::OK, keymaster().addRngEntropy(HidlBuf(string(2 * 1024, 'a'))));
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(AddEntropyTest);
|
||||
|
||||
typedef KeymasterHidlTest AttestationTest;
|
||||
|
||||
/*
|
||||
|
@ -4373,6 +4391,8 @@ TEST_P(AttestationTest, HmacAttestation) {
|
|||
&cert_chain));
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(AttestationTest);
|
||||
|
||||
typedef KeymasterHidlTest KeyDeletionTest;
|
||||
|
||||
/**
|
||||
|
@ -4478,6 +4498,8 @@ TEST_P(KeyDeletionTest, DeleteAllKeys) {
|
|||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(KeyDeletionTest);
|
||||
|
||||
using UpgradeKeyTest = KeymasterHidlTest;
|
||||
|
||||
/*
|
||||
|
@ -4497,6 +4519,8 @@ TEST_P(UpgradeKeyTest, UpgradeKey) {
|
|||
EXPECT_EQ(result, std::make_pair(ErrorCode::OK, HidlBuf()));
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(UpgradeKeyTest);
|
||||
|
||||
using ClearOperationsTest = KeymasterHidlTest;
|
||||
|
||||
/*
|
||||
|
@ -4572,6 +4596,8 @@ TEST_P(ClearOperationsTest, ServiceDeath) {
|
|||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(ClearOperationsTest);
|
||||
|
||||
typedef KeymasterHidlTest TransportLimitTest;
|
||||
|
||||
/*
|
||||
|
@ -4624,44 +4650,7 @@ TEST_P(TransportLimitTest, LargeFinishInput) {
|
|||
CheckedDeleteKey();
|
||||
}
|
||||
|
||||
static const auto kKeymasterDeviceChoices =
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IKeymasterDevice::descriptor));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, NewKeyGenerationTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, ImportKeyTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, ImportWrappedKeyTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, SigningOperationsTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, VerificationOperationsTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, ExportKeyTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, EncryptionOperationsTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, MaxOperationsTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, AddEntropyTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, AttestationTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, KeyDeletionTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, TransportLimitTest, kKeymasterDeviceChoices,
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
INSTANTIATE_KEYMASTER_HIDL_TEST(TransportLimitTest);
|
||||
|
||||
} // namespace test
|
||||
} // namespace V4_0
|
||||
|
|
|
@ -16,6 +16,6 @@
|
|||
|
||||
namespace android::hardware::keymaster::V4_1::test {
|
||||
|
||||
// TODO(swillden): Put tests here.
|
||||
|
||||
|
||||
} // namespace android::hardware::keymaster::V4_1::test
|
||||
|
|
Loading…
Reference in a new issue