• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
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 */
15let HksKeyAlg = {
16  HKS_ALG_ECDH: 100,
17  HKS_ALG_ECC: 2,
18  HKS_ALG_DH: 103,
19  HKS_ALG_AES: 20,
20  HKS_ALG_HMAC: 50,
21  HKS_ALG_X25519: 101,
22  HKS_ALG_RSA: 1,
23  HKS_ALG_PBKDF2: 52,
24  HKS_ALG_HKDF: 51,
25  HKS_ALG_DSA: 3,
26  HKS_ALG_ED25519: 102,
27  HKS_ALG_SM2: 150,
28  HKS_ALG_SM3: 151,
29  HKS_ALG_SM4: 152,
30};
31let HksKeyPurpose = {
32  HKS_KEY_PURPOSE_AGREE: 256,
33  HKS_KEY_PURPOSE_DERIVE: 16,
34  HKS_KEY_PURPOSE_ENCRYPT: 1,
35  HKS_KEY_PURPOSE_DECRYPT: 2,
36  HKS_KEY_PURPOSE_MAC: 128,
37  HKS_KEY_PURPOSE_SIGN: 4,
38  HKS_KEY_PURPOSE_VERIFY: 8,
39};
40let HksKeySize = {
41  HKS_ED25519_KEY_SIZE_512: 512,
42  HKS_RSA_KEY_SIZE_512: 512,
43  HKS_DH_KEY_SIZE_128: 128,
44  HKS_DH_KEY_SIZE_192: 192,
45  HKS_DH_KEY_SIZE_256: 256,
46  HKS_DH_KEY_SIZE_512: 512,
47  HKS_DH_KEY_SIZE_2048: 2048,
48  HKS_DH_KEY_SIZE_3072: 3072,
49  HKS_DH_KEY_SIZE_4096: 4096,
50  HKS_ECC_KEY_SIZE_128: 128,
51  HKS_ECC_KEY_SIZE_192: 192,
52  HKS_ECC_KEY_SIZE_224: 224,
53  HKS_ECC_KEY_SIZE_256: 256,
54  HKS_ECC_KEY_SIZE_384: 384,
55  HKS_ECC_KEY_SIZE_521: 521,
56  HKS_CURVE25519_KEY_SIZE_256: 256,
57  HKS_AES_KEY_SIZE_128: 128,
58  HKS_AES_KEY_SIZE_192: 192,
59  HKS_AES_KEY_SIZE_256: 256,
60  HKS_AES_KEY_SIZE_512: 512,
61  DERIVE_KEY_SIZE_32: 32,
62  HKS_RSA_KEY_SIZE_768: 768,
63  HKS_RSA_KEY_SIZE_1024: 1024,
64  HKS_RSA_KEY_SIZE_2048: 2048,
65  HKS_RSA_KEY_SIZE_3072: 3072,
66  HKS_RSA_KEY_SIZE_4096: 4096,
67  HKS_DSA_KEY_SIZE_512: 512,
68  HKS_DSA_KEY_SIZE_768: 768,
69  HKS_DSA_KEY_SIZE_1024: 1024,
70  HKS_DSA_KEY_SIZE_2048: 2048,
71  HKS_DSA_KEY_SIZE_3072: 3072,
72  HKS_DSA_KEY_SIZE_4096: 4096,
73  HKS_SM2_KEY_SIZE_256: 256,
74  HKS_SM4_KEY_SIZE_128: 128,
75};
76let HksKeyStorageType = {
77  HKS_STORAGE_TEMP: 0,
78  HKS_STORAGE_PERSISTENT: 1,
79};
80let HksTagType = {
81  HKS_TAG_TYPE_UINT: 2 << 28,
82  HKS_TAG_TYPE_BOOL: 4 << 28,
83  HKS_TAG_TYPE_BYTES: 5 << 28,
84};
85let HksKeyDigest = {
86  HKS_DIGEST_NONE: 0,
87  HKS_DIGEST_MD5: 1,
88  HKS_DIGEST_SHA1: 10,
89  HKS_DIGEST_SHA224: 11,
90  HKS_DIGEST_SHA256: 12,
91  HKS_DIGEST_SHA384: 13,
92  HKS_DIGEST_SHA512: 14,
93  HKS_DIGEST_SM3: 2,
94};
95let HksKeyPadding = {
96  HKS_PADDING_NONE: 0,
97  HKS_PADDING_OAEP: 1,
98  HKS_PADDING_PSS: 2,
99  HKS_PADDING_PKCS1_V1_5: 3,
100  HKS_PADDING_PKCS5: 4,
101  HKS_PADDING_PKCS7: 5,
102};
103let HksCipherMode = {
104  HKS_MODE_ECB: 1,
105  HKS_MODE_CBC: 2,
106  HKS_MODE_CTR: 3,
107  HKS_MODE_OFB: 4,
108  HKS_MODE_CCM: 31,
109  HKS_MODE_GCM: 32,
110};
111let HksTag = {
112  HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1,
113  HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2,
114  HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3,
115  HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4,
116  HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5,
117  HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6,
118  HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002,
119  HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001,
120  HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23,
121  HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8,
122  HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9,
123  HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10,
124  HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22,
125  HKS_TAG_AE_TAG: HksTagType.HKS_TAG_TYPE_BYTES | 10009,
126  HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24,
127};
128export {
129  HksKeyPurpose,
130  HksKeyAlg,
131  HksTagType,
132  HksTag,
133  HksKeySize,
134  HksKeyDigest,
135  HksKeyStorageType,
136  HksCipherMode,
137  HksKeyPadding,
138};
139