1 // Copyright 2017 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef SECURITY_KEYSTORE_INCLUDE_KEYSTORE_KEYMASTER_TYPES_H_ 16 #define SECURITY_KEYSTORE_INCLUDE_KEYSTORE_KEYMASTER_TYPES_H_ 17 18 #include <android/hardware/keymaster/3.0/types.h> 19 #include <android/hardware/keymaster/4.0/IKeymasterDevice.h> 20 #include <android/hardware/keymaster/4.0/types.h> 21 22 #include <keymasterV4_0/authorization_set.h> 23 #include <keymasterV4_0/keymaster_tags.h> 24 25 /** 26 * This header lifts the types from the current Keymaster version into the keystore namespace. 27 */ 28 29 namespace keystore { 30 31 // Changing this namespace alias will change the keymaster version. 32 namespace keymaster = ::android::hardware::keymaster::V4_0; 33 34 using android::hardware::hidl_vec; 35 using android::hardware::Return; 36 37 using keymaster::IKeymasterDevice; 38 using keymaster::SecurityLevel; 39 40 using keymaster::AuthorizationSet; 41 using keymaster::AuthorizationSetBuilder; 42 43 using keymaster::Algorithm; 44 using keymaster::BlockMode; 45 using keymaster::Digest; 46 using keymaster::EcCurve; 47 using keymaster::ErrorCode; 48 using keymaster::HardwareAuthenticatorType; 49 using keymaster::HardwareAuthToken; 50 using keymaster::HmacSharingParameters; 51 using keymaster::KeyCharacteristics; 52 using keymaster::KeyFormat; 53 using keymaster::KeyParameter; 54 using keymaster::KeyPurpose; 55 using keymaster::OperationHandle; 56 using keymaster::PaddingMode; 57 using keymaster::SecurityLevel; 58 using keymaster::Tag; 59 using keymaster::TagType; 60 using keymaster::VerificationToken; 61 62 using keymaster::TAG_ACTIVE_DATETIME; 63 using keymaster::TAG_ALGORITHM; 64 using keymaster::TAG_ALLOW_WHILE_ON_BODY; 65 using keymaster::TAG_APPLICATION_DATA; 66 using keymaster::TAG_APPLICATION_ID; 67 using keymaster::TAG_ATTESTATION_APPLICATION_ID; 68 using keymaster::TAG_AUTH_TIMEOUT; 69 using keymaster::TAG_BLOB_USAGE_REQUIREMENTS; 70 using keymaster::TAG_BLOCK_MODE; 71 using keymaster::TAG_DIGEST; 72 using keymaster::TAG_EC_CURVE; 73 using keymaster::TAG_KEY_SIZE; 74 using keymaster::TAG_MAC_LENGTH; 75 using keymaster::TAG_MAX_USES_PER_BOOT; 76 using keymaster::TAG_MIN_MAC_LENGTH; 77 using keymaster::TAG_MIN_SECONDS_BETWEEN_OPS; 78 using keymaster::TAG_NO_AUTH_REQUIRED; 79 using keymaster::TAG_NONCE; 80 using keymaster::TAG_ORIGIN; 81 using keymaster::TAG_ORIGINATION_EXPIRE_DATETIME; 82 using keymaster::TAG_PADDING; 83 using keymaster::TAG_PURPOSE; 84 using keymaster::TAG_RESET_SINCE_ID_ROTATION; 85 using keymaster::TAG_RSA_PUBLIC_EXPONENT; 86 using keymaster::TAG_USAGE_EXPIRE_DATETIME; 87 using keymaster::TAG_USER_AUTH_TYPE; 88 using keymaster::TAG_USER_ID; 89 using keymaster::TAG_USER_SECURE_ID; 90 91 using keymaster::NullOr; 92 93 using Km3HardwareAuthToken = ::android::hardware::keymaster::V3_0::HardwareAuthToken; 94 using Km3HardwareAuthenticatorType = 95 ::android::hardware::keymaster::V3_0::HardwareAuthenticatorType; 96 97 // The following create the numeric values that KM_TAG_PADDING and KM_TAG_DIGEST used to have. We 98 // need these old values to be able to support old keys that use them. 99 constexpr int32_t KM_TAG_DIGEST_OLD = static_cast<int32_t>(TagType::ENUM) | 5; 100 constexpr int32_t KM_TAG_PADDING_OLD = static_cast<int32_t>(TagType::ENUM) | 7; 101 102 } // namespace keystore 103 104 #endif // SYSTEM_SECURITY_KEYSTORE_KM4_AUTHORIZATION_SET_H_ 105