• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025-2025 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  */
15 
16 #ifndef HM_ATTESTATION_CERT_EXT_TYPE_H
17 #define HM_ATTESTATION_CERT_EXT_TYPE_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include "cf_blob.h"
22 
23 typedef enum {
24     SECURITY_LEVEL_SOFTWARE = 0,
25     SECURITY_LEVEL_TRUSTED_ENVIRONMENT = 1,
26     SECURITY_LEVEL_STRONGBOX = 2
27 } LegacySecurityLevel;
28 
29 typedef enum {
30     // standard
31     DEVICE_ACTIVATION_DEVICE_ID1 = 0, // CfBlob
32     DEVICE_ACTIVATION_DEVICE_ID2 = 1, // CfBlob
33     ATTESTATION_KEY_PURPOSE = 2, // CfBlob
34     ATTESTATION_APP_ID_HAP_ID, // CfBlob
35     ATTESTATION_APP_ID_SA_ID, // CfBlob
36     ATTESTATION_APP_ID_UNIFIED_ID, // CfBlob
37     ATTESTATION_CHALLENGE, // CfBlob
38     ATTESTATION_KEY_FLAG, // CfBlob
39     ATTESTATION_DIGEST, // CfBlob
40     ATTESTATION_SIGN_PADDING, // CfBlob
41     ATTESTATION_ENC_PADDING, // CfBlob
42     ATTESTATION_SIGN_TYPE, // CfBlob
43     ATTESTATION_VERSION_INFO, // CfBlob
44     ATTESTATION_KEY_MANAGER_TA_ID, // CfBlob
45     ATTESTATION_PURPOSE, // int64_t
46     ATTESTATION_ID_PADDING_FLAG, // bool
47     ATTESTATION_NONCE, // CfBlob
48     ATTESTATION_IMEI, // CfBlob
49     ATTESTATION_MEID, // CfBlob
50     ATTESTATION_SERIAL, // CfBlob
51     ATTESTATION_MODEL, // CfBlob
52     ATTESTATION_SOCID, // CfBlob
53     ATTESTATION_UDID, // CfBlob
54     ATTESTATION_VERSION, // int64_t
55     ATTESTATION_CERT_EXT_TYPE_MAX,
56 
57     // legacy
58     LEGACY_VERSION = 1000, // int64_t
59     LEGACY_SECURITY_LEVEL = 1001, // int64_t, enum LegacySecurityLevel
60     LEGACY_KM_VERSION = 1002, // int64_t
61     LEGACY_KM_SECURITY_LEVEL = 1003, // int64_t, enum LegacySecurityLevel
62     LEGACY_CHALLENGE = 1004, // CfBlob
63     LEGACY_UNIQUE_ID = 1005, // CfBlob
64     KM_TAG_PURPOSE, // CfInt64Array, set of int64_t
65     KM_TAG_ALGORITHM, // int64_t
66     KM_TAG_KEY_SIZE, // int64_t
67     KM_TAG_KEY_DIGEST, // CfInt64Array, set of int64_t
68     KM_TAG_KEY_PADDING, // CfInt64Array, set of int64_t
69     KM_TAG_EC_CURVE, // int64_t
70     KM_TAG_RSA_PUBLIC_EXPONENT, // int64_t
71     KM_TAG_NO_AUTH_REQUIRED, // NULL
72     KM_TAG_USER_AUTH_TYPE, // int64_t
73     KM_TAG_CREATION_DATETIME, // int64_t
74     KM_TAG_ORIGIN, // int64_t
75     KM_TAG_OS_VERSION, // int64_t
76     KM_TAG_OS_PATCH_LEVEL, // int64_t
77     KM_TAG_ATTESTATION_ID_BRAND, // CfBlob
78     KM_TAG_ATTESTATION_ID_DEVICE, // CfBlob
79     KM_TAG_ATTESTATION_ID_PRODUCT, // CfBlob
80     KM_TAG_ATTESTATION_ID_SERIAL, // CfBlob
81     KM_TAG_ATTESTATION_ID_IMEI, // CfBlob
82     KM_TAG_ATTESTATION_ID_MEID, // CfBlob
83     KM_TAG_ATTESTATION_ID_MANUFACTURER, // CfBlob
84     KM_TAG_ATTESTATION_ID_MODEL, // CfBlob
85     KM_TAG_ATTESTATION_ID_SOCID, // CfBlob
86     KM_TAG_ATTESTATION_ID_UDID, // CfBlob
87     KM_TAG_TYPE_MAX,
88 } HmAttestationCertExtType;
89 
90 typedef struct {
91     union {
92         bool boolValue;
93         int64_t int64Value;
94         CfBlob blob;
95         CfInt64Array int64Array;
96     };
97 } HmAttestationCertExt;
98 
99 typedef struct {
100     char *cn;
101     char *ou;
102     char *o;
103     char *c;
104 } CertSnInfo;
105 
106 typedef struct {
107     uint32_t num;
108     CertSnInfo *certSnInfos;
109 } HmAttestationSnInfo;
110 
111 #endif