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.1/IKeymasterDevice.h> 20 #include <android/hardware/keymaster/4.1/types.h> 21 22 #include <keymasterV4_1/authorization_set.h> 23 #include <keymasterV4_1/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_1; 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 // It's more convenient to use the V4.0 error and tag types by default. 44 using ::android::hardware::keymaster::V4_0::ErrorCode; 45 using ::android::hardware::keymaster::V4_0::Tag; 46 47 using V4_1_ErrorCode = ::android::hardware::keymaster::V4_1::ErrorCode; 48 using V4_1_Tag = ::android::hardware::keymaster::V4_1::Tag; 49 50 using keymaster::Algorithm; 51 using keymaster::BlockMode; 52 using keymaster::Digest; 53 using keymaster::EcCurve; 54 using keymaster::HardwareAuthenticatorType; 55 using keymaster::HardwareAuthToken; 56 using keymaster::HmacSharingParameters; 57 using keymaster::KeyCharacteristics; 58 using keymaster::KeyFormat; 59 using keymaster::KeyParameter; 60 using keymaster::KeyPurpose; 61 using keymaster::OperationHandle; 62 using keymaster::PaddingMode; 63 using keymaster::SecurityLevel; 64 using keymaster::TagType; 65 using keymaster::VerificationToken; 66 67 using keymaster::TAG_ACTIVE_DATETIME; 68 using keymaster::TAG_ALGORITHM; 69 using keymaster::TAG_ALLOW_WHILE_ON_BODY; 70 using keymaster::TAG_APPLICATION_DATA; 71 using keymaster::TAG_APPLICATION_ID; 72 using keymaster::TAG_ATTESTATION_APPLICATION_ID; 73 using keymaster::TAG_AUTH_TIMEOUT; 74 using keymaster::TAG_BLOB_USAGE_REQUIREMENTS; 75 using keymaster::TAG_BLOCK_MODE; 76 using keymaster::TAG_DIGEST; 77 using keymaster::TAG_EC_CURVE; 78 using keymaster::TAG_KEY_SIZE; 79 using keymaster::TAG_MAC_LENGTH; 80 using keymaster::TAG_MAX_USES_PER_BOOT; 81 using keymaster::TAG_MIN_MAC_LENGTH; 82 using keymaster::TAG_MIN_SECONDS_BETWEEN_OPS; 83 using keymaster::TAG_NO_AUTH_REQUIRED; 84 using keymaster::TAG_NONCE; 85 using keymaster::TAG_ORIGIN; 86 using keymaster::TAG_ORIGINATION_EXPIRE_DATETIME; 87 using keymaster::TAG_PADDING; 88 using keymaster::TAG_PURPOSE; 89 using keymaster::TAG_RESET_SINCE_ID_ROTATION; 90 using keymaster::TAG_RSA_PUBLIC_EXPONENT; 91 using keymaster::TAG_USAGE_EXPIRE_DATETIME; 92 using keymaster::TAG_USER_AUTH_TYPE; 93 using keymaster::TAG_USER_ID; 94 using keymaster::TAG_USER_SECURE_ID; 95 96 using keymaster::NullOr; 97 98 using Km3HardwareAuthToken = ::android::hardware::keymaster::V3_0::HardwareAuthToken; 99 using Km3HardwareAuthenticatorType = 100 ::android::hardware::keymaster::V3_0::HardwareAuthenticatorType; 101 102 // The following create the numeric values that KM_TAG_PADDING and KM_TAG_DIGEST used to have. We 103 // need these old values to be able to support old keys that use them. 104 constexpr int32_t KM_TAG_DIGEST_OLD = static_cast<int32_t>(TagType::ENUM) | 5; 105 constexpr int32_t KM_TAG_PADDING_OLD = static_cast<int32_t>(TagType::ENUM) | 7; 106 107 } // namespace keystore 108 109 #endif // SYSTEM_SECURITY_KEYSTORE_KM4_AUTHORIZATION_SET_H_ 110