Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 17 | #pragma once |
| 18 | |
| 19 | #include <aidl/Gtest.h> |
| 20 | #include <aidl/Vintf.h> |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 21 | #include <binder/IServiceManager.h> |
| 22 | #include <binder/ProcessState.h> |
| 23 | #include <gtest/gtest.h> |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 24 | #include <openssl/x509.h> |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 25 | |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 26 | #include <aidl/android/hardware/security/keymint/ErrorCode.h> |
| 27 | #include <aidl/android/hardware/security/keymint/IKeyMintDevice.h> |
David Drysdale | 4dc0107 | 2021-04-01 12:17:35 +0100 | [diff] [blame] | 28 | #include <aidl/android/hardware/security/keymint/MacedPublicKey.h> |
Shawn Willden | 1d3f85e | 2020-12-09 14:18:44 -0700 | [diff] [blame] | 29 | |
Shawn Willden | 08a7e43 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 30 | #include <keymint_support/authorization_set.h> |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 31 | #include <keymint_support/openssl_utils.h> |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 32 | |
Shawn Willden | 0e80b5d | 2020-12-17 09:07:27 -0700 | [diff] [blame] | 33 | namespace aidl::android::hardware::security::keymint { |
| 34 | |
| 35 | ::std::ostream& operator<<(::std::ostream& os, const AuthorizationSet& set); |
| 36 | |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 37 | inline bool operator==(const keymint::AuthorizationSet& a, const keymint::AuthorizationSet& b) { |
| 38 | return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin()); |
| 39 | } |
| 40 | |
Shawn Willden | 0e80b5d | 2020-12-17 09:07:27 -0700 | [diff] [blame] | 41 | namespace test { |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 42 | |
| 43 | using ::android::sp; |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 44 | using Status = ::ndk::ScopedAStatus; |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 45 | using ::std::optional; |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 46 | using ::std::shared_ptr; |
| 47 | using ::std::string; |
| 48 | using ::std::vector; |
| 49 | |
| 50 | constexpr uint64_t kOpHandleSentinel = 0xFFFFFFFFFFFFFFFF; |
| 51 | |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 52 | class KeyMintAidlTestBase : public ::testing::TestWithParam<string> { |
| 53 | public: |
Chirag Pathak | 9ea6a0a | 2021-02-01 23:54:27 +0000 | [diff] [blame] | 54 | struct KeyData { |
| 55 | vector<uint8_t> blob; |
| 56 | vector<KeyCharacteristics> characteristics; |
| 57 | }; |
| 58 | |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 59 | static bool arm_deleteAllKeys; |
| 60 | static bool dump_Attestations; |
| 61 | |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 62 | void SetUp() override; |
| 63 | void TearDown() override { |
| 64 | if (key_blob_.size()) { |
| 65 | CheckedDeleteKey(); |
| 66 | } |
| 67 | AbortIfNeeded(); |
| 68 | } |
| 69 | |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 70 | void InitializeKeyMint(std::shared_ptr<IKeyMintDevice> keyMint); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 71 | IKeyMintDevice& keyMint() { return *keymint_; } |
| 72 | uint32_t os_version() { return os_version_; } |
| 73 | uint32_t os_patch_level() { return os_patch_level_; } |
David Drysdale | bb3d85e | 2021-04-13 11:15:51 +0100 | [diff] [blame] | 74 | uint32_t vendor_patch_level() { return vendor_patch_level_; } |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 75 | |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 76 | ErrorCode GetReturnErrorCode(const Status& result); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 77 | |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 78 | ErrorCode GenerateKey(const AuthorizationSet& key_desc, vector<uint8_t>* key_blob, |
| 79 | vector<KeyCharacteristics>* key_characteristics) { |
| 80 | return GenerateKey(key_desc, std::nullopt /* attest_key */, key_blob, key_characteristics, |
| 81 | &cert_chain_); |
| 82 | } |
| 83 | ErrorCode GenerateKey(const AuthorizationSet& key_desc, |
| 84 | const optional<AttestationKey>& attest_key, vector<uint8_t>* key_blob, |
| 85 | vector<KeyCharacteristics>* key_characteristics, |
| 86 | vector<Certificate>* cert_chain); |
| 87 | ErrorCode GenerateKey(const AuthorizationSet& key_desc, |
| 88 | const optional<AttestationKey>& attest_key = std::nullopt); |
| 89 | |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 90 | ErrorCode ImportKey(const AuthorizationSet& key_desc, KeyFormat format, |
| 91 | const string& key_material, vector<uint8_t>* key_blob, |
Shawn Willden | 7f42437 | 2021-01-10 18:06:50 -0700 | [diff] [blame] | 92 | vector<KeyCharacteristics>* key_characteristics); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 93 | ErrorCode ImportKey(const AuthorizationSet& key_desc, KeyFormat format, |
| 94 | const string& key_material); |
| 95 | |
| 96 | ErrorCode ImportWrappedKey(string wrapped_key, string wrapping_key, |
| 97 | const AuthorizationSet& wrapping_key_desc, string masking_key, |
David Drysdale | d2cc8c2 | 2021-04-15 13:29:45 +0100 | [diff] [blame^] | 98 | const AuthorizationSet& unwrapping_params, int64_t password_sid, |
| 99 | int64_t biometric_sid); |
| 100 | ErrorCode ImportWrappedKey(string wrapped_key, string wrapping_key, |
| 101 | const AuthorizationSet& wrapping_key_desc, string masking_key, |
| 102 | const AuthorizationSet& unwrapping_params) { |
| 103 | return ImportWrappedKey(wrapped_key, wrapping_key, wrapping_key_desc, masking_key, |
| 104 | unwrapping_params, 0 /* password_sid */, 0 /* biometric_sid */); |
| 105 | } |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 106 | |
| 107 | ErrorCode DeleteKey(vector<uint8_t>* key_blob, bool keep_key_blob = false); |
| 108 | ErrorCode DeleteKey(bool keep_key_blob = false); |
| 109 | |
| 110 | ErrorCode DeleteAllKeys(); |
| 111 | |
David Drysdale | d2cc8c2 | 2021-04-15 13:29:45 +0100 | [diff] [blame^] | 112 | ErrorCode DestroyAttestationIds(); |
| 113 | |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 114 | void CheckedDeleteKey(vector<uint8_t>* key_blob, bool keep_key_blob = false); |
| 115 | void CheckedDeleteKey(); |
| 116 | |
| 117 | ErrorCode Begin(KeyPurpose purpose, const vector<uint8_t>& key_blob, |
| 118 | const AuthorizationSet& in_params, AuthorizationSet* out_params, |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 119 | std::shared_ptr<IKeyMintOperation>& op); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 120 | ErrorCode Begin(KeyPurpose purpose, const vector<uint8_t>& key_blob, |
| 121 | const AuthorizationSet& in_params, AuthorizationSet* out_params); |
| 122 | ErrorCode Begin(KeyPurpose purpose, const AuthorizationSet& in_params, |
| 123 | AuthorizationSet* out_params); |
| 124 | ErrorCode Begin(KeyPurpose purpose, const AuthorizationSet& in_params); |
| 125 | |
Shawn Willden | 92d79c0 | 2021-02-19 07:31:55 -0700 | [diff] [blame] | 126 | ErrorCode UpdateAad(const string& input); |
| 127 | ErrorCode Update(const string& input, string* output); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 128 | |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 129 | ErrorCode Finish(const string& message, const string& signature, string* output); |
Shawn Willden | 92d79c0 | 2021-02-19 07:31:55 -0700 | [diff] [blame] | 130 | ErrorCode Finish(const string& message, string* output) { |
| 131 | return Finish(message, {} /* signature */, output); |
| 132 | } |
| 133 | ErrorCode Finish(string* output) { return Finish({} /* message */, output); } |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 134 | |
| 135 | ErrorCode Abort(); |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 136 | ErrorCode Abort(const shared_ptr<IKeyMintOperation>& op); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 137 | void AbortIfNeeded(); |
| 138 | |
| 139 | string ProcessMessage(const vector<uint8_t>& key_blob, KeyPurpose operation, |
| 140 | const string& message, const AuthorizationSet& in_params, |
| 141 | AuthorizationSet* out_params); |
Shawn Willden | 92d79c0 | 2021-02-19 07:31:55 -0700 | [diff] [blame] | 142 | std::tuple<ErrorCode, std::string /* processedMessage */> ProcessMessage( |
| 143 | const vector<uint8_t>& key_blob, KeyPurpose operation, const std::string& message, |
| 144 | const AuthorizationSet& in_params); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 145 | string SignMessage(const vector<uint8_t>& key_blob, const string& message, |
| 146 | const AuthorizationSet& params); |
| 147 | string SignMessage(const string& message, const AuthorizationSet& params); |
| 148 | |
| 149 | string MacMessage(const string& message, Digest digest, size_t mac_length); |
| 150 | |
| 151 | void CheckHmacTestVector(const string& key, const string& message, Digest digest, |
| 152 | const string& expected_mac); |
| 153 | |
| 154 | void CheckAesCtrTestVector(const string& key, const string& nonce, const string& message, |
| 155 | const string& expected_ciphertext); |
| 156 | |
| 157 | void CheckTripleDesTestVector(KeyPurpose purpose, BlockMode block_mode, |
| 158 | PaddingMode padding_mode, const string& key, const string& iv, |
| 159 | const string& input, const string& expected_output); |
| 160 | |
| 161 | void VerifyMessage(const vector<uint8_t>& key_blob, const string& message, |
| 162 | const string& signature, const AuthorizationSet& params); |
| 163 | void VerifyMessage(const string& message, const string& signature, |
| 164 | const AuthorizationSet& params); |
| 165 | |
| 166 | string EncryptMessage(const vector<uint8_t>& key_blob, const string& message, |
| 167 | const AuthorizationSet& in_params, AuthorizationSet* out_params); |
| 168 | string EncryptMessage(const string& message, const AuthorizationSet& params, |
| 169 | AuthorizationSet* out_params); |
| 170 | string EncryptMessage(const string& message, const AuthorizationSet& params); |
| 171 | string EncryptMessage(const string& message, BlockMode block_mode, PaddingMode padding); |
| 172 | string EncryptMessage(const string& message, BlockMode block_mode, PaddingMode padding, |
| 173 | vector<uint8_t>* iv_out); |
| 174 | string EncryptMessage(const string& message, BlockMode block_mode, PaddingMode padding, |
| 175 | const vector<uint8_t>& iv_in); |
| 176 | string EncryptMessage(const string& message, BlockMode block_mode, PaddingMode padding, |
| 177 | uint8_t mac_length_bits, const vector<uint8_t>& iv_in); |
David Drysdale | d2cc8c2 | 2021-04-15 13:29:45 +0100 | [diff] [blame^] | 178 | string EncryptMessage(const string& message, BlockMode block_mode, PaddingMode padding, |
| 179 | uint8_t mac_length_bits); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 180 | |
| 181 | string DecryptMessage(const vector<uint8_t>& key_blob, const string& ciphertext, |
| 182 | const AuthorizationSet& params); |
| 183 | string DecryptMessage(const string& ciphertext, const AuthorizationSet& params); |
| 184 | string DecryptMessage(const string& ciphertext, BlockMode block_mode, PaddingMode padding_mode, |
| 185 | const vector<uint8_t>& iv); |
| 186 | |
| 187 | std::pair<ErrorCode, vector<uint8_t>> UpgradeKey(const vector<uint8_t>& key_blob); |
| 188 | |
Chirag Pathak | 9ea6a0a | 2021-02-01 23:54:27 +0000 | [diff] [blame] | 189 | template <typename TagType> |
| 190 | std::tuple<KeyData /* aesKey */, KeyData /* hmacKey */, KeyData /* rsaKey */, |
| 191 | KeyData /* ecdsaKey */> |
| 192 | CreateTestKeys(TagType tagToTest, ErrorCode expectedReturn) { |
| 193 | /* AES */ |
| 194 | KeyData aesKeyData; |
| 195 | ErrorCode errorCode = GenerateKey(AuthorizationSetBuilder() |
| 196 | .AesEncryptionKey(128) |
| 197 | .Authorization(tagToTest) |
| 198 | .BlockMode(BlockMode::ECB) |
| 199 | .Padding(PaddingMode::NONE) |
| 200 | .Authorization(TAG_NO_AUTH_REQUIRED), |
| 201 | &aesKeyData.blob, &aesKeyData.characteristics); |
| 202 | EXPECT_EQ(expectedReturn, errorCode); |
| 203 | |
| 204 | /* HMAC */ |
| 205 | KeyData hmacKeyData; |
| 206 | errorCode = GenerateKey(AuthorizationSetBuilder() |
| 207 | .HmacKey(128) |
| 208 | .Authorization(tagToTest) |
| 209 | .Digest(Digest::SHA_2_256) |
| 210 | .Authorization(TAG_MIN_MAC_LENGTH, 128) |
| 211 | .Authorization(TAG_NO_AUTH_REQUIRED), |
| 212 | &hmacKeyData.blob, &hmacKeyData.characteristics); |
| 213 | EXPECT_EQ(expectedReturn, errorCode); |
| 214 | |
| 215 | /* RSA */ |
| 216 | KeyData rsaKeyData; |
| 217 | errorCode = GenerateKey(AuthorizationSetBuilder() |
| 218 | .RsaSigningKey(2048, 65537) |
| 219 | .Authorization(tagToTest) |
| 220 | .Digest(Digest::NONE) |
| 221 | .Padding(PaddingMode::NONE) |
| 222 | .Authorization(TAG_NO_AUTH_REQUIRED) |
| 223 | .SetDefaultValidity(), |
| 224 | &rsaKeyData.blob, &rsaKeyData.characteristics); |
| 225 | EXPECT_EQ(expectedReturn, errorCode); |
| 226 | |
| 227 | /* ECDSA */ |
| 228 | KeyData ecdsaKeyData; |
| 229 | errorCode = GenerateKey(AuthorizationSetBuilder() |
| 230 | .EcdsaSigningKey(256) |
| 231 | .Authorization(tagToTest) |
| 232 | .Digest(Digest::SHA_2_256) |
| 233 | .Authorization(TAG_NO_AUTH_REQUIRED) |
| 234 | .SetDefaultValidity(), |
| 235 | &ecdsaKeyData.blob, &ecdsaKeyData.characteristics); |
| 236 | EXPECT_EQ(expectedReturn, errorCode); |
| 237 | return {aesKeyData, hmacKeyData, rsaKeyData, ecdsaKeyData}; |
| 238 | } |
Shawn Willden | 7f42437 | 2021-01-10 18:06:50 -0700 | [diff] [blame] | 239 | bool IsSecure() const { return securityLevel_ != SecurityLevel::SOFTWARE; } |
| 240 | SecurityLevel SecLevel() const { return securityLevel_; } |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 241 | |
| 242 | vector<uint32_t> ValidKeySizes(Algorithm algorithm); |
| 243 | vector<uint32_t> InvalidKeySizes(Algorithm algorithm); |
| 244 | |
David Drysdale | 7de9feb | 2021-03-05 14:56:19 +0000 | [diff] [blame] | 245 | vector<BlockMode> ValidBlockModes(Algorithm algorithm); |
| 246 | vector<PaddingMode> ValidPaddingModes(Algorithm algorithm, BlockMode blockMode); |
| 247 | vector<PaddingMode> InvalidPaddingModes(Algorithm algorithm, BlockMode blockMode); |
| 248 | |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 249 | vector<EcCurve> ValidCurves(); |
| 250 | vector<EcCurve> InvalidCurves(); |
| 251 | |
| 252 | vector<Digest> ValidDigests(bool withNone, bool withMD5); |
| 253 | |
| 254 | static vector<string> build_params() { |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 255 | auto params = ::android::getAidlHalInstanceNames(IKeyMintDevice::descriptor); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 256 | return params; |
| 257 | } |
| 258 | |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 259 | std::shared_ptr<IKeyMintOperation> op_; |
Shawn Willden | 7f42437 | 2021-01-10 18:06:50 -0700 | [diff] [blame] | 260 | vector<Certificate> cert_chain_; |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 261 | vector<uint8_t> key_blob_; |
Shawn Willden | 7f42437 | 2021-01-10 18:06:50 -0700 | [diff] [blame] | 262 | vector<KeyCharacteristics> key_characteristics_; |
| 263 | |
| 264 | const vector<KeyParameter>& SecLevelAuthorizations( |
| 265 | const vector<KeyCharacteristics>& key_characteristics); |
| 266 | inline const vector<KeyParameter>& SecLevelAuthorizations() { |
| 267 | return SecLevelAuthorizations(key_characteristics_); |
| 268 | } |
Qi Wu | beefae4 | 2021-01-28 23:16:37 +0800 | [diff] [blame] | 269 | const vector<KeyParameter>& SecLevelAuthorizations( |
| 270 | const vector<KeyCharacteristics>& key_characteristics, SecurityLevel securityLevel); |
| 271 | |
Chirag Pathak | 9ea6a0a | 2021-02-01 23:54:27 +0000 | [diff] [blame] | 272 | ErrorCode UseAesKey(const vector<uint8_t>& aesKeyBlob); |
| 273 | ErrorCode UseHmacKey(const vector<uint8_t>& hmacKeyBlob); |
| 274 | ErrorCode UseRsaKey(const vector<uint8_t>& rsaKeyBlob); |
| 275 | ErrorCode UseEcdsaKey(const vector<uint8_t>& ecdsaKeyBlob); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 276 | |
Shawn Willden | d659c7c | 2021-02-19 14:51:51 -0700 | [diff] [blame] | 277 | protected: |
Janis Danisevskis | 24c0470 | 2020-12-16 18:28:39 -0800 | [diff] [blame] | 278 | std::shared_ptr<IKeyMintDevice> keymint_; |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 279 | uint32_t os_version_; |
| 280 | uint32_t os_patch_level_; |
David Drysdale | bb3d85e | 2021-04-13 11:15:51 +0100 | [diff] [blame] | 281 | uint32_t vendor_patch_level_; |
David Drysdale | d2cc8c2 | 2021-04-15 13:29:45 +0100 | [diff] [blame^] | 282 | bool timestamp_token_required_; |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 283 | |
| 284 | SecurityLevel securityLevel_; |
| 285 | string name_; |
| 286 | string author_; |
| 287 | long challenge_; |
| 288 | }; |
| 289 | |
Selene Huang | 6e46f14 | 2021-04-20 19:20:11 -0700 | [diff] [blame] | 290 | vector<uint8_t> build_serial_blob(const uint64_t serial_int); |
| 291 | void verify_subject(const X509* cert, const string& subject, bool self_signed); |
| 292 | void verify_serial(X509* cert, const uint64_t expected_serial); |
| 293 | void verify_subject_and_serial(const Certificate& certificate, // |
| 294 | const uint64_t expected_serial, // |
| 295 | const string& subject, bool self_signed); |
| 296 | |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 297 | bool verify_attestation_record(const string& challenge, // |
| 298 | const string& app_id, // |
| 299 | AuthorizationSet expected_sw_enforced, // |
| 300 | AuthorizationSet expected_hw_enforced, // |
| 301 | SecurityLevel security_level, |
| 302 | const vector<uint8_t>& attestation_cert); |
Selene Huang | 6e46f14 | 2021-04-20 19:20:11 -0700 | [diff] [blame] | 303 | |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 304 | string bin2hex(const vector<uint8_t>& data); |
| 305 | X509_Ptr parse_cert_blob(const vector<uint8_t>& blob); |
David Drysdale | f0d516d | 2021-03-22 07:51:43 +0000 | [diff] [blame] | 306 | vector<uint8_t> make_name_from_str(const string& name); |
David Drysdale | 4dc0107 | 2021-04-01 12:17:35 +0100 | [diff] [blame] | 307 | void check_maced_pubkey(const MacedPublicKey& macedPubKey, bool testMode, |
| 308 | vector<uint8_t>* payload_value); |
| 309 | void p256_pub_key(const vector<uint8_t>& coseKeyData, EVP_PKEY_Ptr* signingKey); |
| 310 | |
David Drysdale | f0d516d | 2021-03-22 07:51:43 +0000 | [diff] [blame] | 311 | AuthorizationSet HwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics); |
| 312 | AuthorizationSet SwEnforcedAuthorizations(const vector<KeyCharacteristics>& key_characteristics); |
Shawn Willden | 7c13039 | 2020-12-21 09:58:22 -0700 | [diff] [blame] | 313 | ::testing::AssertionResult ChainSignaturesAreValid(const vector<Certificate>& chain); |
| 314 | |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 315 | #define INSTANTIATE_KEYMINT_AIDL_TEST(name) \ |
| 316 | INSTANTIATE_TEST_SUITE_P(PerInstance, name, \ |
| 317 | testing::ValuesIn(KeyMintAidlTestBase::build_params()), \ |
Shawn Willden | 7e71f1e | 2021-04-01 16:44:22 -0600 | [diff] [blame] | 318 | ::android::PrintInstanceNameToString); \ |
| 319 | GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(name); |
Selene Huang | 31ab404 | 2020-04-29 04:22:39 -0700 | [diff] [blame] | 320 | |
Shawn Willden | 0e80b5d | 2020-12-17 09:07:27 -0700 | [diff] [blame] | 321 | } // namespace test |
| 322 | |
| 323 | } // namespace aidl::android::hardware::security::keymint |