Hasini Gunasinghe | 4e55c2f | 2020-05-26 01:28:17 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2018 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 KEY_CREATION_LOG_HANDLER_H_ |
| 18 | #define KEY_CREATION_LOG_HANDLER_H_ |
| 19 | |
| 20 | #include <keystore/keystore_hidl_support.h> |
| 21 | |
| 22 | namespace keystore { |
| 23 | |
| 24 | /** |
| 25 | * Following enums are defined as a part of the workaround to log the repeated |
| 26 | * values of ENUM_REP type. The workaround is to represent the repeated values |
| 27 | * of ENUM_REP type as a bitmap and the following enums define their positions |
| 28 | * in the bitmap. |
| 29 | */ |
| 30 | |
| 31 | enum PaddingModeBitPosition : int32_t { |
| 32 | RSA_OAEP_BIT_POS = 1, |
| 33 | RSA_PSS_BIT_POS = 2, |
| 34 | RSA_PKCS1_1_5_ENCRYPT_BIT_POS = 3, |
| 35 | RSA_PKCS1_1_5_SIGN_BIT_POS = 4, |
| 36 | PKCS7_BIT_POS = 5, |
| 37 | }; |
| 38 | |
| 39 | enum DigestBitPosition : int32_t { |
| 40 | MD5_BIT_POS = 1, |
| 41 | SHA1_BIT_POS = 2, |
| 42 | SHA_2_224_BIT_POS = 3, |
| 43 | SHA_2_256_BIT_POS = 4, |
| 44 | SHA_2_384_BIT_POS = 5, |
| 45 | SHA_2_512_BIT_POS = 6, |
| 46 | }; |
| 47 | |
| 48 | enum BlockModeBitPosition : int32_t { |
| 49 | ECB_BIT_POS = 1, |
| 50 | CBC_BIT_POS = 2, |
| 51 | CTR_BIT_POS = 3, |
| 52 | GCM_BIT_POS = 4, |
| 53 | }; |
| 54 | |
| 55 | enum KeyPurposeBitPosition : int32_t { |
| 56 | ENCRYPT_BIT_POS = 1, |
| 57 | DECRYPT_BIT_POS = 2, |
| 58 | SIGN_BIT_POS = 3, |
| 59 | VERIFY_BIT_POS = 4, |
| 60 | WRAP_KEY_BIT_POS = 5, |
| 61 | }; |
| 62 | |
| 63 | // None is an enum value for digest and a deprecated value for padding mode |
| 64 | const int32_t NONE_BIT_POS = 0; |
| 65 | |
| 66 | void logKeystoreKeyCreationEvent(const hidl_vec<KeyParameter>& keyParams, |
| 67 | bool wasCreationSuccessful, int32_t errorCode); |
| 68 | |
| 69 | } // namespace keystore |
| 70 | |
| 71 | #endif // KEY_CREATION_LOG_HANDLER_H_ |