1 /* 2 * Copyright 2019, 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 #ifndef ANDROID_HARDWARE_IDENTITY_UTIL_H 18 #define ANDROID_HARDWARE_IDENTITY_UTIL_H 19 20 #include <aidl/android/hardware/identity/BnIdentityCredential.h> 21 #include <android/hardware/identity/support/IdentityCredentialSupport.h> 22 23 #include <map> 24 #include <optional> 25 #include <set> 26 #include <string> 27 #include <vector> 28 29 #include <cppbor/cppbor.h> 30 31 namespace aidl::android::hardware::identity { 32 33 using ::std::optional; 34 using ::std::string; 35 using ::std::vector; 36 37 // Returns the hardware-bound AES-128 key. 38 const vector<uint8_t>& getHardwareBoundKey(); 39 40 // Calculates the MAC for |profile| using |storageKey|. 41 optional<vector<uint8_t>> secureAccessControlProfileCalcMac( 42 const SecureAccessControlProfile& profile, const vector<uint8_t>& storageKey); 43 44 // Checks authenticity of the MAC in |profile| using |storageKey|. 45 bool secureAccessControlProfileCheckMac(const SecureAccessControlProfile& profile, 46 const vector<uint8_t>& storageKey); 47 48 // Creates the AdditionalData CBOR used in the addEntryValue() HIDL method. 49 vector<uint8_t> entryCreateAdditionalData(const string& nameSpace, const string& name, 50 const vector<int32_t> accessControlProfileIds); 51 52 } // namespace aidl::android::hardware::identity 53 54 #endif // ANDROID_HARDWARE_IDENTITY_UTIL_H 55