blob: a314eb11703a109a15a8be2074fbb62ac2e18590 [file] [log] [blame]
Hasini Gunasinghe4e55c2f2020-05-26 01:28:17 +00001/*
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
22namespace 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
31enum 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
39enum 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
48enum 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
55enum 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
64const int32_t NONE_BIT_POS = 0;
65
66void logKeystoreKeyCreationEvent(const hidl_vec<KeyParameter>& keyParams,
67 bool wasCreationSuccessful, int32_t errorCode);
68
69} // namespace keystore
70
71#endif // KEY_CREATION_LOG_HANDLER_H_