Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | */ |
David Zeuthen | f2a2867 | 2020-01-30 16:20:07 -0500 | [diff] [blame] | 16 | |
| 17 | #include <keystore/keystore_attestation_id.h> |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 18 | |
| 19 | #define LOG_TAG "keystore_att_id" |
| 20 | |
Logan Chien | cdc813f | 2018-04-23 13:52:28 +0800 | [diff] [blame] | 21 | #include <log/log.h> |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 22 | |
| 23 | #include <memory> |
| 24 | #include <string> |
| 25 | #include <vector> |
| 26 | |
| 27 | #include <binder/IServiceManager.h> |
| 28 | #include <binder/Parcel.h> |
| 29 | #include <binder/Parcelable.h> |
| 30 | #include <binder/PersistableBundle.h> |
| 31 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 32 | #include <android/security/keystore/BpKeyAttestationApplicationIdProvider.h> |
| 33 | #include <android/security/keystore/IKeyAttestationApplicationIdProvider.h> |
| 34 | #include <android/security/keystore/KeyAttestationApplicationId.h> |
| 35 | #include <android/security/keystore/KeyAttestationPackageInfo.h> |
| 36 | #include <android/security/keystore/Signature.h> |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 37 | |
Eran Messeri | ea47d3f | 2017-12-06 12:01:42 +0000 | [diff] [blame] | 38 | #include <private/android_filesystem_config.h> /* for AID_SYSTEM */ |
| 39 | |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 40 | #include <openssl/asn1t.h> |
Eran Messeri | abaf4d8 | 2017-12-28 21:19:50 +0000 | [diff] [blame] | 41 | #include <openssl/bn.h> |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 42 | #include <openssl/sha.h> |
| 43 | |
| 44 | #include <utils/String8.h> |
| 45 | |
| 46 | namespace android { |
| 47 | |
| 48 | namespace { |
| 49 | |
Shawn Willden | 9e8edcf | 2017-12-18 15:11:46 -0700 | [diff] [blame] | 50 | constexpr const char* kAttestationSystemPackageName = "AndroidSystem"; |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 51 | constexpr const char* kUnknownPackageName = "UnknownPackage"; |
Shawn Willden | 9e8edcf | 2017-12-18 15:11:46 -0700 | [diff] [blame] | 52 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 53 | std::vector<uint8_t> signature2SHA256(const security::keystore::Signature& sig) { |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 54 | std::vector<uint8_t> digest_buffer(SHA256_DIGEST_LENGTH); |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 55 | SHA256(sig.data.data(), sig.data.size(), digest_buffer.data()); |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 56 | return digest_buffer; |
| 57 | } |
| 58 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 59 | using ::android::security::keystore::BpKeyAttestationApplicationIdProvider; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 60 | |
| 61 | class KeyAttestationApplicationIdProvider : public BpKeyAttestationApplicationIdProvider { |
| 62 | public: |
| 63 | KeyAttestationApplicationIdProvider(); |
| 64 | |
| 65 | static KeyAttestationApplicationIdProvider& get(); |
| 66 | |
| 67 | private: |
| 68 | android::sp<android::IServiceManager> service_manager_; |
| 69 | }; |
| 70 | |
| 71 | KeyAttestationApplicationIdProvider& KeyAttestationApplicationIdProvider::get() { |
| 72 | static KeyAttestationApplicationIdProvider mpm; |
| 73 | return mpm; |
| 74 | } |
| 75 | |
| 76 | KeyAttestationApplicationIdProvider::KeyAttestationApplicationIdProvider() |
Tri Vo | 8d08cd9 | 2023-07-18 14:53:39 -0400 | [diff] [blame] | 77 | : BpKeyAttestationApplicationIdProvider(android::defaultServiceManager()->waitForService( |
| 78 | String16("sec_key_att_app_id_provider"))) {} |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 79 | |
| 80 | DECLARE_STACK_OF(ASN1_OCTET_STRING); |
| 81 | |
| 82 | typedef struct km_attestation_package_info { |
| 83 | ASN1_OCTET_STRING* package_name; |
| 84 | ASN1_INTEGER* version; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 85 | } KM_ATTESTATION_PACKAGE_INFO; |
| 86 | |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 87 | // Estimated size: |
| 88 | // 4 bytes for the package name + package_name length |
| 89 | // 11 bytes for the version (2 bytes header and up to 9 bytes of data). |
| 90 | constexpr size_t AAID_PKG_INFO_OVERHEAD = 15; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 91 | ASN1_SEQUENCE(KM_ATTESTATION_PACKAGE_INFO) = { |
| 92 | ASN1_SIMPLE(KM_ATTESTATION_PACKAGE_INFO, package_name, ASN1_OCTET_STRING), |
| 93 | ASN1_SIMPLE(KM_ATTESTATION_PACKAGE_INFO, version, ASN1_INTEGER), |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 94 | } ASN1_SEQUENCE_END(KM_ATTESTATION_PACKAGE_INFO); |
| 95 | IMPLEMENT_ASN1_FUNCTIONS(KM_ATTESTATION_PACKAGE_INFO); |
| 96 | |
| 97 | DECLARE_STACK_OF(KM_ATTESTATION_PACKAGE_INFO); |
| 98 | |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 99 | // Estimated size: |
| 100 | // See estimate above for the stack of package infos. |
| 101 | // 34 (32 + 2) bytes for each signature digest. |
| 102 | constexpr size_t AAID_SIGNATURE_SIZE = 34; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 103 | typedef struct km_attestation_application_id { |
| 104 | STACK_OF(KM_ATTESTATION_PACKAGE_INFO) * package_infos; |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 105 | STACK_OF(ASN1_OCTET_STRING) * signature_digests; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 106 | } KM_ATTESTATION_APPLICATION_ID; |
| 107 | |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 108 | // Estimated overhead: |
| 109 | // 4 for the header of the octet string containing the fully-encoded data. |
| 110 | // 4 for the sequence header. |
| 111 | // 4 for the header of the package info set. |
| 112 | // 4 for the header of the signature set. |
| 113 | constexpr size_t AAID_GENERAL_OVERHEAD = 16; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 114 | ASN1_SEQUENCE(KM_ATTESTATION_APPLICATION_ID) = { |
| 115 | ASN1_SET_OF(KM_ATTESTATION_APPLICATION_ID, package_infos, KM_ATTESTATION_PACKAGE_INFO), |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 116 | ASN1_SET_OF(KM_ATTESTATION_APPLICATION_ID, signature_digests, ASN1_OCTET_STRING), |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 117 | } ASN1_SEQUENCE_END(KM_ATTESTATION_APPLICATION_ID); |
| 118 | IMPLEMENT_ASN1_FUNCTIONS(KM_ATTESTATION_APPLICATION_ID); |
Shawn Willden | 9e8edcf | 2017-12-18 15:11:46 -0700 | [diff] [blame] | 119 | |
| 120 | } // namespace |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 121 | |
| 122 | } // namespace android |
| 123 | |
| 124 | namespace std { |
| 125 | template <> struct default_delete<android::KM_ATTESTATION_PACKAGE_INFO> { |
| 126 | void operator()(android::KM_ATTESTATION_PACKAGE_INFO* p) { |
| 127 | android::KM_ATTESTATION_PACKAGE_INFO_free(p); |
| 128 | } |
| 129 | }; |
| 130 | template <> struct default_delete<ASN1_OCTET_STRING> { |
| 131 | void operator()(ASN1_OCTET_STRING* p) { ASN1_OCTET_STRING_free(p); } |
| 132 | }; |
| 133 | template <> struct default_delete<android::KM_ATTESTATION_APPLICATION_ID> { |
| 134 | void operator()(android::KM_ATTESTATION_APPLICATION_ID* p) { |
| 135 | android::KM_ATTESTATION_APPLICATION_ID_free(p); |
| 136 | } |
| 137 | }; |
| 138 | } // namespace std |
| 139 | |
| 140 | namespace android { |
| 141 | namespace security { |
| 142 | namespace { |
| 143 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 144 | using ::android::security::keystore::KeyAttestationApplicationId; |
| 145 | using ::android::security::keystore::KeyAttestationPackageInfo; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 146 | |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 147 | status_t build_attestation_package_info(const KeyAttestationPackageInfo& pinfo, |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 148 | std::unique_ptr<KM_ATTESTATION_PACKAGE_INFO>* attestation_package_info_ptr) { |
| 149 | |
| 150 | if (!attestation_package_info_ptr) return BAD_VALUE; |
| 151 | auto& attestation_package_info = *attestation_package_info_ptr; |
| 152 | |
| 153 | attestation_package_info.reset(KM_ATTESTATION_PACKAGE_INFO_new()); |
| 154 | if (!attestation_package_info.get()) return NO_MEMORY; |
| 155 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 156 | if (!pinfo.packageName) { |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 157 | ALOGE("Key attestation package info lacks package name"); |
| 158 | return BAD_VALUE; |
| 159 | } |
| 160 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 161 | std::string pkg_name(String8(pinfo.packageName).c_str()); |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 162 | if (!ASN1_OCTET_STRING_set(attestation_package_info->package_name, |
| 163 | reinterpret_cast<const unsigned char*>(pkg_name.data()), |
| 164 | pkg_name.size())) { |
| 165 | return UNKNOWN_ERROR; |
| 166 | } |
| 167 | |
Eran Messeri | abaf4d8 | 2017-12-28 21:19:50 +0000 | [diff] [blame] | 168 | BIGNUM* bn_version = BN_new(); |
| 169 | if (bn_version == nullptr) { |
| 170 | return NO_MEMORY; |
| 171 | } |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 172 | if (BN_set_u64(bn_version, static_cast<uint64_t>(pinfo.versionCode)) != 1) { |
Eran Messeri | abaf4d8 | 2017-12-28 21:19:50 +0000 | [diff] [blame] | 173 | BN_free(bn_version); |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 174 | return UNKNOWN_ERROR; |
| 175 | } |
Eran Messeri | abaf4d8 | 2017-12-28 21:19:50 +0000 | [diff] [blame] | 176 | status_t retval = NO_ERROR; |
| 177 | if (BN_to_ASN1_INTEGER(bn_version, attestation_package_info->version) == nullptr) { |
| 178 | retval = UNKNOWN_ERROR; |
| 179 | } |
| 180 | BN_free(bn_version); |
| 181 | return retval; |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 182 | } |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 183 | |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 184 | /* The following function are not used. They are mentioned here to silence |
| 185 | * warnings about them not being used. |
| 186 | */ |
| 187 | void unused_functions_silencer() __attribute__((unused)); |
| 188 | void unused_functions_silencer() { |
| 189 | i2d_KM_ATTESTATION_PACKAGE_INFO(nullptr, nullptr); |
| 190 | d2i_KM_ATTESTATION_APPLICATION_ID(nullptr, nullptr, 0); |
| 191 | d2i_KM_ATTESTATION_PACKAGE_INFO(nullptr, nullptr, 0); |
| 192 | } |
| 193 | |
| 194 | } // namespace |
| 195 | |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 196 | StatusOr<std::vector<uint8_t>> |
| 197 | build_attestation_application_id(const KeyAttestationApplicationId& key_attestation_id) { |
| 198 | auto attestation_id = |
| 199 | std::unique_ptr<KM_ATTESTATION_APPLICATION_ID>(KM_ATTESTATION_APPLICATION_ID_new()); |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 200 | size_t estimated_encoded_size = AAID_GENERAL_OVERHEAD; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 201 | |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 202 | auto attestation_pinfo_stack = reinterpret_cast<_STACK*>(attestation_id->package_infos); |
| 203 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 204 | if (key_attestation_id.packageInfos.begin() == key_attestation_id.packageInfos.end()) |
| 205 | return BAD_VALUE; |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 206 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 207 | for (auto pinfo = key_attestation_id.packageInfos.begin(); |
| 208 | pinfo != key_attestation_id.packageInfos.end(); ++pinfo) { |
| 209 | if (!pinfo->packageName) { |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 210 | ALOGE("Key attestation package info lacks package name"); |
| 211 | return BAD_VALUE; |
| 212 | } |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 213 | std::string package_name(String8(pinfo->packageName).c_str()); |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 214 | std::unique_ptr<KM_ATTESTATION_PACKAGE_INFO> attestation_package_info; |
| 215 | auto rc = build_attestation_package_info(*pinfo, &attestation_package_info); |
| 216 | if (rc != NO_ERROR) { |
| 217 | ALOGE("Building DER attestation package info failed %d", rc); |
| 218 | return rc; |
| 219 | } |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 220 | estimated_encoded_size += AAID_PKG_INFO_OVERHEAD + package_name.size(); |
| 221 | if (estimated_encoded_size > KEY_ATTESTATION_APPLICATION_ID_MAX_SIZE) { |
| 222 | break; |
| 223 | } |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 224 | if (!sk_push(attestation_pinfo_stack, attestation_package_info.get())) { |
| 225 | return NO_MEMORY; |
| 226 | } |
| 227 | // if push succeeded, the stack takes ownership |
| 228 | attestation_package_info.release(); |
| 229 | } |
| 230 | |
| 231 | /** Apps can only share a uid iff they were signed with the same certificate(s). Because the |
| 232 | * signature field actually holds the signing certificate, rather than a signature, we can |
| 233 | * simply use the set of signature digests of the first package info. |
| 234 | */ |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 235 | const auto& pinfo = *key_attestation_id.packageInfos.begin(); |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 236 | std::vector<std::vector<uint8_t>> signature_digests; |
| 237 | |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 238 | for (auto sig = pinfo.signatures.begin(); sig != pinfo.signatures.end(); ++sig) { |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 239 | signature_digests.push_back(signature2SHA256(*sig)); |
| 240 | } |
| 241 | |
| 242 | auto signature_digest_stack = reinterpret_cast<_STACK*>(attestation_id->signature_digests); |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 243 | for (auto si : signature_digests) { |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 244 | estimated_encoded_size += AAID_SIGNATURE_SIZE; |
| 245 | if (estimated_encoded_size > KEY_ATTESTATION_APPLICATION_ID_MAX_SIZE) { |
| 246 | break; |
| 247 | } |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 248 | auto asn1_item = std::unique_ptr<ASN1_OCTET_STRING>(ASN1_OCTET_STRING_new()); |
| 249 | if (!asn1_item) return NO_MEMORY; |
| 250 | if (!ASN1_OCTET_STRING_set(asn1_item.get(), si.data(), si.size())) { |
| 251 | return UNKNOWN_ERROR; |
| 252 | } |
| 253 | if (!sk_push(signature_digest_stack, asn1_item.get())) { |
| 254 | return NO_MEMORY; |
| 255 | } |
| 256 | asn1_item.release(); // if push succeeded, the stack takes ownership |
| 257 | } |
| 258 | |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 259 | int len = i2d_KM_ATTESTATION_APPLICATION_ID(attestation_id.get(), nullptr); |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 260 | if (len < 0) return UNKNOWN_ERROR; |
| 261 | |
| 262 | std::vector<uint8_t> result(len); |
| 263 | uint8_t* p = result.data(); |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 264 | len = i2d_KM_ATTESTATION_APPLICATION_ID(attestation_id.get(), &p); |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 265 | if (len < 0) return UNKNOWN_ERROR; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 266 | |
| 267 | return result; |
| 268 | } |
| 269 | |
Janis Danisevskis | 011675d | 2016-09-01 11:41:29 +0100 | [diff] [blame] | 270 | StatusOr<std::vector<uint8_t>> gather_attestation_application_id(uid_t uid) { |
Shawn Willden | 9e8edcf | 2017-12-18 15:11:46 -0700 | [diff] [blame] | 271 | KeyAttestationApplicationId key_attestation_id; |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 272 | |
Eran Messeri | ea47d3f | 2017-12-06 12:01:42 +0000 | [diff] [blame] | 273 | if (uid == AID_SYSTEM) { |
Shawn Willden | 9e8edcf | 2017-12-18 15:11:46 -0700 | [diff] [blame] | 274 | /* Use a fixed ID for system callers */ |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 275 | auto pinfo = KeyAttestationPackageInfo(); |
| 276 | pinfo.packageName = String16(kAttestationSystemPackageName); |
| 277 | pinfo.versionCode = 1; |
| 278 | key_attestation_id.packageInfos.push_back(std::move(pinfo)); |
Eran Messeri | ea47d3f | 2017-12-06 12:01:42 +0000 | [diff] [blame] | 279 | } else { |
Shawn Willden | 9e8edcf | 2017-12-18 15:11:46 -0700 | [diff] [blame] | 280 | /* Get the attestation application ID from package manager */ |
| 281 | auto& pm = KeyAttestationApplicationIdProvider::get(); |
| 282 | auto status = pm.getKeyAttestationApplicationId(uid, &key_attestation_id); |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 283 | // Package Manager call has failed, perform attestation but indicate that the |
| 284 | // caller is unknown. |
Eran Messeri | ea47d3f | 2017-12-06 12:01:42 +0000 | [diff] [blame] | 285 | if (!status.isOk()) { |
Eran Messeri | 03fc4c8 | 2018-08-16 18:53:15 +0100 | [diff] [blame] | 286 | ALOGW("package manager request for key attestation ID failed with: %s %d", |
Tomasz Wasilczyk | 102d33a | 2023-08-11 16:10:37 +0000 | [diff] [blame] | 287 | status.exceptionMessage().c_str(), status.exceptionCode()); |
Rajesh Nyamagoud | 3f6c15c | 2023-03-11 01:26:48 +0000 | [diff] [blame^] | 288 | |
| 289 | auto pinfo = KeyAttestationPackageInfo(); |
| 290 | pinfo.packageName = String16(kUnknownPackageName); |
| 291 | pinfo.versionCode = 1; |
| 292 | key_attestation_id.packageInfos.push_back(std::move(pinfo)); |
Eran Messeri | ea47d3f | 2017-12-06 12:01:42 +0000 | [diff] [blame] | 293 | } |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | /* DER encode the attestation application ID */ |
Shawn Willden | 9e8edcf | 2017-12-18 15:11:46 -0700 | [diff] [blame] | 297 | return build_attestation_application_id(key_attestation_id); |
Janis Danisevskis | 18f27ad | 2016-06-01 13:57:40 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | } // namespace security |
| 301 | } // namespace android |