Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | |
| 17 | #define LOG_TAG "android.hardware.security.keymint-impl" |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 18 | #include <android-base/logging.h> |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 19 | |
| 20 | #include "AndroidKeyMintDevice.h" |
| 21 | |
| 22 | #include <aidl/android/hardware/security/keymint/ErrorCode.h> |
| 23 | |
| 24 | #include <keymaster/android_keymaster.h> |
| 25 | #include <keymaster/contexts/pure_soft_keymaster_context.h> |
| 26 | #include <keymaster/keymaster_configuration.h> |
| 27 | |
| 28 | #include "AndroidKeyMintOperation.h" |
| 29 | #include "KeyMintUtils.h" |
| 30 | |
| 31 | namespace aidl::android::hardware::security::keymint { |
| 32 | |
| 33 | using namespace ::keymaster; |
Shawn Willden | 96d4e8c | 2020-12-07 17:03:54 -0700 | [diff] [blame] | 34 | using namespace km_utils; |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 35 | |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 36 | namespace { |
| 37 | |
| 38 | vector<KeyCharacteristics> convertKeyCharacteristics(SecurityLevel keyMintSecurityLevel, |
| 39 | const AuthorizationSet& sw_enforced, |
| 40 | const AuthorizationSet& hw_enforced) { |
| 41 | KeyCharacteristics enforced; |
| 42 | |
| 43 | enforced.securityLevel = keyMintSecurityLevel; |
| 44 | if (keyMintSecurityLevel != SecurityLevel::SOFTWARE) { |
| 45 | // We're pretending to be TRUSTED_ENVIRONMENT or STRONGBOX. Only the entries in hw_enforced |
| 46 | // should be returned. |
| 47 | enforced.authorizations = kmParamSet2Aidl(hw_enforced); |
| 48 | KeyCharacteristics enforced{keyMintSecurityLevel, kmParamSet2Aidl(hw_enforced)}; |
| 49 | return {std::move(enforced)}; |
| 50 | } |
| 51 | |
| 52 | CHECK(hw_enforced.empty()) << "Hardware-enforced list is non-empty for pure SW KeyMint"; |
| 53 | |
| 54 | // This is a pure software implementation, so all tags are in sw_enforced. We need to walk |
| 55 | // through the SW-enforced list and figure out which tags to return and which not. |
| 56 | |
| 57 | for (auto& entry : sw_enforced) { |
| 58 | switch (entry.tag) { |
| 59 | /* Invalid and unused */ |
| 60 | case KM_TAG_ECIES_SINGLE_HASH_MODE: |
| 61 | case KM_TAG_INVALID: |
| 62 | case KM_TAG_KDF: |
| 63 | CHECK(false) << "We shouldn't see tag " << entry.tag; |
| 64 | break; |
| 65 | |
| 66 | /* Unimplemented */ |
| 67 | case KM_TAG_ALLOW_WHILE_ON_BODY: |
| 68 | case KM_TAG_APPLICATION_ID: |
| 69 | case KM_TAG_BOOTLOADER_ONLY: |
| 70 | case KM_TAG_EARLY_BOOT_ONLY: |
| 71 | case KM_TAG_ROLLBACK_RESISTANCE: |
| 72 | case KM_TAG_ROLLBACK_RESISTANT: |
| 73 | case KM_TAG_STORAGE_KEY: |
| 74 | break; |
| 75 | |
| 76 | /* Unenforceable */ |
| 77 | case KM_TAG_ACTIVE_DATETIME: |
| 78 | case KM_TAG_ALL_APPLICATIONS: |
| 79 | case KM_TAG_ALL_USERS: |
| 80 | case KM_TAG_CREATION_DATETIME: |
| 81 | case KM_TAG_ORIGINATION_EXPIRE_DATETIME: |
| 82 | case KM_TAG_TRUSTED_CONFIRMATION_REQUIRED: |
| 83 | case KM_TAG_TRUSTED_USER_PRESENCE_REQUIRED: |
| 84 | case KM_TAG_USAGE_EXPIRE_DATETIME: |
| 85 | case KM_TAG_USER_ID: |
| 86 | break; |
| 87 | |
| 88 | /* Disallowed in KeyCharacteristics */ |
| 89 | case KM_TAG_APPLICATION_DATA: |
| 90 | break; |
| 91 | |
| 92 | /* Not key characteristics */ |
| 93 | case KM_TAG_ASSOCIATED_DATA: |
| 94 | case KM_TAG_ATTESTATION_APPLICATION_ID: |
| 95 | case KM_TAG_ATTESTATION_CHALLENGE: |
| 96 | case KM_TAG_ATTESTATION_ID_BRAND: |
| 97 | case KM_TAG_ATTESTATION_ID_DEVICE: |
| 98 | case KM_TAG_ATTESTATION_ID_IMEI: |
| 99 | case KM_TAG_ATTESTATION_ID_MANUFACTURER: |
| 100 | case KM_TAG_ATTESTATION_ID_MEID: |
| 101 | case KM_TAG_ATTESTATION_ID_MODEL: |
| 102 | case KM_TAG_ATTESTATION_ID_PRODUCT: |
| 103 | case KM_TAG_ATTESTATION_ID_SERIAL: |
| 104 | case KM_TAG_AUTH_TOKEN: |
| 105 | case KM_TAG_CERTIFICATE_SERIAL: |
| 106 | case KM_TAG_CERTIFICATE_SUBJECT: |
| 107 | case KM_TAG_CONFIRMATION_TOKEN: |
| 108 | case KM_TAG_DEVICE_UNIQUE_ATTESTATION: |
| 109 | case KM_TAG_IDENTITY_CREDENTIAL_KEY: |
| 110 | case KM_TAG_MAC_LENGTH: |
| 111 | case KM_TAG_NONCE: |
| 112 | case KM_TAG_RESET_SINCE_ID_ROTATION: |
| 113 | case KM_TAG_ROOT_OF_TRUST: |
| 114 | case KM_TAG_UNIQUE_ID: |
| 115 | break; |
| 116 | |
| 117 | /* Enforced */ |
| 118 | case KM_TAG_ALGORITHM: |
| 119 | case KM_TAG_AUTH_TIMEOUT: |
| 120 | case KM_TAG_BLOB_USAGE_REQUIREMENTS: |
| 121 | case KM_TAG_BLOCK_MODE: |
| 122 | case KM_TAG_BOOT_PATCHLEVEL: |
| 123 | case KM_TAG_CALLER_NONCE: |
| 124 | case KM_TAG_DIGEST: |
| 125 | case KM_TAG_EC_CURVE: |
| 126 | case KM_TAG_EXPORTABLE: |
| 127 | case KM_TAG_INCLUDE_UNIQUE_ID: |
| 128 | case KM_TAG_KEY_SIZE: |
| 129 | case KM_TAG_MAX_USES_PER_BOOT: |
| 130 | case KM_TAG_MIN_MAC_LENGTH: |
| 131 | case KM_TAG_MIN_SECONDS_BETWEEN_OPS: |
| 132 | case KM_TAG_NO_AUTH_REQUIRED: |
| 133 | case KM_TAG_ORIGIN: |
| 134 | case KM_TAG_OS_PATCHLEVEL: |
| 135 | case KM_TAG_OS_VERSION: |
| 136 | case KM_TAG_PADDING: |
| 137 | case KM_TAG_PURPOSE: |
| 138 | case KM_TAG_RSA_OAEP_MGF_DIGEST: |
| 139 | case KM_TAG_RSA_PUBLIC_EXPONENT: |
| 140 | case KM_TAG_UNLOCKED_DEVICE_REQUIRED: |
Qi Wu | 5218bba | 2021-01-15 02:36:26 +0800 | [diff] [blame] | 141 | case KM_TAG_USAGE_COUNT_LIMIT: |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 142 | case KM_TAG_USER_AUTH_TYPE: |
| 143 | case KM_TAG_USER_SECURE_ID: |
| 144 | case KM_TAG_VENDOR_PATCHLEVEL: |
| 145 | enforced.authorizations.push_back(kmParam2Aidl(entry)); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | return {std::move(enforced)}; |
| 150 | } |
| 151 | |
Shawn Willden | d7d4f31 | 2020-12-21 08:31:01 -0700 | [diff] [blame] | 152 | Certificate convertCertificate(const keymaster_blob_t& cert) { |
| 153 | return {std::vector<uint8_t>(cert.data, cert.data + cert.data_length)}; |
| 154 | } |
| 155 | |
| 156 | vector<Certificate> convertCertificateChain(const CertificateChain& chain) { |
| 157 | vector<Certificate> retval; |
| 158 | retval.reserve(chain.entry_count); |
| 159 | std::transform(chain.begin(), chain.end(), std::back_inserter(retval), convertCertificate); |
| 160 | return retval; |
| 161 | } |
| 162 | |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 163 | } // namespace |
| 164 | |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 165 | constexpr size_t kOperationTableSize = 16; |
| 166 | |
| 167 | AndroidKeyMintDevice::AndroidKeyMintDevice(SecurityLevel securityLevel) |
| 168 | : impl_(new ::keymaster::AndroidKeymaster( |
| 169 | [&]() -> auto { |
| 170 | auto context = new PureSoftKeymasterContext( |
| 171 | KmVersion::KEYMINT_1, static_cast<keymaster_security_level_t>(securityLevel)); |
| 172 | context->SetSystemVersion(::keymaster::GetOsVersion(), |
| 173 | ::keymaster::GetOsPatchlevel()); |
| 174 | return context; |
| 175 | }(), |
| 176 | kOperationTableSize)), |
| 177 | securityLevel_(securityLevel) {} |
| 178 | |
| 179 | AndroidKeyMintDevice::~AndroidKeyMintDevice() {} |
| 180 | |
| 181 | ScopedAStatus AndroidKeyMintDevice::getHardwareInfo(KeyMintHardwareInfo* info) { |
| 182 | info->versionNumber = 1; |
| 183 | info->securityLevel = securityLevel_; |
| 184 | info->keyMintName = "FakeKeyMintDevice"; |
| 185 | info->keyMintAuthorName = "Google"; |
| 186 | |
| 187 | return ScopedAStatus::ok(); |
| 188 | } |
| 189 | |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 190 | ScopedAStatus AndroidKeyMintDevice::addRngEntropy(const vector<uint8_t>& data) { |
| 191 | if (data.size() == 0) { |
| 192 | return ScopedAStatus::ok(); |
| 193 | } |
| 194 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 195 | AddEntropyRequest request(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 196 | request.random_data.Reinitialize(data.data(), data.size()); |
| 197 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 198 | AddEntropyResponse response(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 199 | impl_->AddRngEntropy(request, &response); |
| 200 | |
| 201 | return kmError2ScopedAStatus(response.error); |
| 202 | } |
| 203 | |
| 204 | ScopedAStatus AndroidKeyMintDevice::generateKey(const vector<KeyParameter>& keyParams, |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 205 | KeyCreationResult* creationResult) { |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 206 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 207 | GenerateKeyRequest request(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 208 | request.key_description.Reinitialize(KmParamSet(keyParams)); |
| 209 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 210 | GenerateKeyResponse response(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 211 | impl_->GenerateKey(request, &response); |
| 212 | |
| 213 | if (response.error != KM_ERROR_OK) { |
| 214 | // Note a key difference between this current aidl and previous hal, is |
| 215 | // that hal returns void where as aidl returns the error status. If |
| 216 | // aidl returns error, then aidl will not return any change you may make |
| 217 | // to the out parameters. This is quite different from hal where all |
| 218 | // output variable can be modified due to hal returning void. |
| 219 | // |
| 220 | // So the caller need to be aware not to expect aidl functions to clear |
| 221 | // the output variables for you in case of error. If you left some |
| 222 | // wrong data set in the out parameters, they will stay there. |
| 223 | return kmError2ScopedAStatus(response.error); |
| 224 | } |
| 225 | |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 226 | creationResult->keyBlob = kmBlob2vector(response.key_blob); |
| 227 | creationResult->keyCharacteristics = |
| 228 | convertKeyCharacteristics(securityLevel_, response.unenforced, response.enforced); |
Shawn Willden | d7d4f31 | 2020-12-21 08:31:01 -0700 | [diff] [blame] | 229 | creationResult->certificateChain = convertCertificateChain(response.certificate_chain); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 230 | return ScopedAStatus::ok(); |
| 231 | } |
| 232 | |
| 233 | ScopedAStatus AndroidKeyMintDevice::importKey(const vector<KeyParameter>& keyParams, |
| 234 | KeyFormat keyFormat, const vector<uint8_t>& keyData, |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 235 | KeyCreationResult* creationResult) { |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 236 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 237 | ImportKeyRequest request(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 238 | request.key_description.Reinitialize(KmParamSet(keyParams)); |
| 239 | request.key_format = legacy_enum_conversion(keyFormat); |
Shawn Willden | 6e20ea4 | 2020-12-21 18:52:34 -0700 | [diff] [blame^] | 240 | request.key_data = KeymasterKeyBlob(keyData.data(), keyData.size()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 241 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 242 | ImportKeyResponse response(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 243 | impl_->ImportKey(request, &response); |
| 244 | |
| 245 | if (response.error != KM_ERROR_OK) { |
| 246 | return kmError2ScopedAStatus(response.error); |
| 247 | } |
| 248 | |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 249 | creationResult->keyBlob = kmBlob2vector(response.key_blob); |
| 250 | creationResult->keyCharacteristics = |
| 251 | convertKeyCharacteristics(securityLevel_, response.unenforced, response.enforced); |
Shawn Willden | d7d4f31 | 2020-12-21 08:31:01 -0700 | [diff] [blame] | 252 | creationResult->certificateChain = convertCertificateChain(response.certificate_chain); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 253 | |
| 254 | return ScopedAStatus::ok(); |
| 255 | } |
| 256 | |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 257 | ScopedAStatus AndroidKeyMintDevice::importWrappedKey(const vector<uint8_t>& wrappedKeyData, |
| 258 | const vector<uint8_t>& wrappingKeyBlob, |
| 259 | const vector<uint8_t>& maskingKey, |
| 260 | const vector<KeyParameter>& unwrappingParams, |
| 261 | int64_t passwordSid, int64_t biometricSid, |
| 262 | KeyCreationResult* creationResult) { |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 263 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 264 | ImportWrappedKeyRequest request(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 265 | request.SetWrappedMaterial(wrappedKeyData.data(), wrappedKeyData.size()); |
| 266 | request.SetWrappingMaterial(wrappingKeyBlob.data(), wrappingKeyBlob.size()); |
| 267 | request.SetMaskingKeyMaterial(maskingKey.data(), maskingKey.size()); |
| 268 | request.additional_params.Reinitialize(KmParamSet(unwrappingParams)); |
| 269 | request.password_sid = static_cast<uint64_t>(passwordSid); |
| 270 | request.biometric_sid = static_cast<uint64_t>(biometricSid); |
| 271 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 272 | ImportWrappedKeyResponse response(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 273 | impl_->ImportWrappedKey(request, &response); |
| 274 | |
| 275 | if (response.error != KM_ERROR_OK) { |
| 276 | return kmError2ScopedAStatus(response.error); |
| 277 | } |
| 278 | |
Shawn Willden | 763166c | 2021-01-10 19:45:01 -0700 | [diff] [blame] | 279 | creationResult->keyBlob = kmBlob2vector(response.key_blob); |
| 280 | creationResult->keyCharacteristics = |
| 281 | convertKeyCharacteristics(securityLevel_, response.unenforced, response.enforced); |
Shawn Willden | d7d4f31 | 2020-12-21 08:31:01 -0700 | [diff] [blame] | 282 | creationResult->certificateChain = convertCertificateChain(response.certificate_chain); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 283 | |
| 284 | return ScopedAStatus::ok(); |
| 285 | } |
| 286 | |
| 287 | ScopedAStatus AndroidKeyMintDevice::upgradeKey(const vector<uint8_t>& keyBlobToUpgrade, |
| 288 | const vector<KeyParameter>& upgradeParams, |
| 289 | vector<uint8_t>* keyBlob) { |
| 290 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 291 | UpgradeKeyRequest request(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 292 | request.SetKeyMaterial(keyBlobToUpgrade.data(), keyBlobToUpgrade.size()); |
| 293 | request.upgrade_params.Reinitialize(KmParamSet(upgradeParams)); |
| 294 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 295 | UpgradeKeyResponse response(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 296 | impl_->UpgradeKey(request, &response); |
| 297 | |
| 298 | if (response.error != KM_ERROR_OK) { |
| 299 | return kmError2ScopedAStatus(response.error); |
| 300 | } |
| 301 | |
| 302 | *keyBlob = kmBlob2vector(response.upgraded_key); |
| 303 | return ScopedAStatus::ok(); |
| 304 | } |
| 305 | |
| 306 | ScopedAStatus AndroidKeyMintDevice::deleteKey(const vector<uint8_t>& keyBlob) { |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 307 | DeleteKeyRequest request(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 308 | request.SetKeyMaterial(keyBlob.data(), keyBlob.size()); |
| 309 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 310 | DeleteKeyResponse response(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 311 | impl_->DeleteKey(request, &response); |
| 312 | |
| 313 | return kmError2ScopedAStatus(response.error); |
| 314 | } |
| 315 | |
| 316 | ScopedAStatus AndroidKeyMintDevice::deleteAllKeys() { |
| 317 | // There's nothing to be done to delete software key blobs. |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 318 | DeleteAllKeysRequest request(impl_->message_version()); |
| 319 | DeleteAllKeysResponse response(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 320 | impl_->DeleteAllKeys(request, &response); |
| 321 | |
| 322 | return kmError2ScopedAStatus(response.error); |
| 323 | } |
| 324 | |
| 325 | ScopedAStatus AndroidKeyMintDevice::destroyAttestationIds() { |
| 326 | return kmError2ScopedAStatus(KM_ERROR_UNIMPLEMENTED); |
| 327 | } |
| 328 | |
| 329 | ScopedAStatus AndroidKeyMintDevice::begin(KeyPurpose purpose, const vector<uint8_t>& keyBlob, |
| 330 | const vector<KeyParameter>& params, |
| 331 | const HardwareAuthToken& authToken, BeginResult* result) { |
| 332 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 333 | BeginOperationRequest request(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 334 | request.purpose = legacy_enum_conversion(purpose); |
| 335 | request.SetKeyMaterial(keyBlob.data(), keyBlob.size()); |
| 336 | request.additional_params.Reinitialize(KmParamSet(params)); |
| 337 | |
| 338 | vector<uint8_t> vector_token = authToken2AidlVec(authToken); |
| 339 | request.additional_params.push_back( |
| 340 | TAG_AUTH_TOKEN, reinterpret_cast<uint8_t*>(vector_token.data()), vector_token.size()); |
| 341 | |
Shawn Willden | 950eb0b | 2021-01-06 19:15:29 +0000 | [diff] [blame] | 342 | BeginOperationResponse response(impl_->message_version()); |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 343 | impl_->BeginOperation(request, &response); |
| 344 | |
| 345 | if (response.error != KM_ERROR_OK) { |
| 346 | return kmError2ScopedAStatus(response.error); |
| 347 | } |
| 348 | |
| 349 | result->params = kmParamSet2Aidl(response.output_params); |
| 350 | result->challenge = response.op_handle; |
| 351 | result->operation = |
| 352 | ndk::SharedRefBase::make<AndroidKeyMintOperation>(impl_, response.op_handle); |
| 353 | return ScopedAStatus::ok(); |
| 354 | } |
| 355 | |
| 356 | IKeyMintDevice* CreateKeyMintDevice(SecurityLevel securityLevel) { |
| 357 | |
| 358 | return ::new AndroidKeyMintDevice(securityLevel); |
| 359 | } |
| 360 | |
| 361 | } // namespace aidl::android::hardware::security::keymint |