• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #include "attest_utils_log.h"
17 #include "attest_error.h"
18 #include "attest_tls.h"
19 
20 const unsigned char GLOBALSIGN_ROOT_CA_R3_DER[] = {
21     0X30, 0X82, 0X03, 0X5F, 0X30, 0X82, 0X02, 0X47, 0XA0, 0X03, 0X02, 0X01,
22     0X02, 0X02, 0X0B, 0X04, 0X00, 0X00, 0X00, 0X00, 0X01, 0X21, 0X58, 0X53,
23     0X08, 0XA2, 0X30, 0X0D, 0X06, 0X09, 0X2A, 0X86, 0X48, 0X86, 0XF7, 0X0D,
24     0X01, 0X01, 0X0B, 0X05, 0X00, 0X30, 0X4C, 0X31, 0X20, 0X30, 0X1E, 0X06,
25     0X03, 0X55, 0X04, 0X0B, 0X13, 0X17, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C,
26     0X53, 0X69, 0X67, 0X6E, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X43, 0X41,
27     0X20, 0X2D, 0X20, 0X52, 0X33, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55,
28     0X04, 0X0A, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69,
29     0X67, 0X6E, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55, 0X04, 0X03, 0X13,
30     0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X30,
31     0X1E, 0X17, 0X0D, 0X30, 0X39, 0X30, 0X33, 0X31, 0X38, 0X31, 0X30, 0X30,
32     0X30, 0X30, 0X30, 0X5A, 0X17, 0X0D, 0X32, 0X39, 0X30, 0X33, 0X31, 0X38,
33     0X31, 0X30, 0X30, 0X30, 0X30, 0X30, 0X5A, 0X30, 0X4C, 0X31, 0X20, 0X30,
34     0X1E, 0X06, 0X03, 0X55, 0X04, 0X0B, 0X13, 0X17, 0X47, 0X6C, 0X6F, 0X62,
35     0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20,
36     0X43, 0X41, 0X20, 0X2D, 0X20, 0X52, 0X33, 0X31, 0X13, 0X30, 0X11, 0X06,
37     0X03, 0X55, 0X04, 0X0A, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C,
38     0X53, 0X69, 0X67, 0X6E, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55, 0X04,
39     0X03, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67,
40     0X6E, 0X30, 0X82, 0X01, 0X22, 0X30, 0X0D, 0X06, 0X09, 0X2A, 0X86, 0X48,
41     0X86, 0XF7, 0X0D, 0X01, 0X01, 0X01, 0X05, 0X00, 0X03, 0X82, 0X01, 0X0F,
42     0X00, 0X30, 0X82, 0X01, 0X0A, 0X02, 0X82, 0X01, 0X01, 0X00, 0XCC, 0X25,
43     0X76, 0X90, 0X79, 0X06, 0X78, 0X22, 0X16, 0XF5, 0XC0, 0X83, 0XB6, 0X84,
44     0XCA, 0X28, 0X9E, 0XFD, 0X05, 0X76, 0X11, 0XC5, 0XAD, 0X88, 0X72, 0XFC,
45     0X46, 0X02, 0X43, 0XC7, 0XB2, 0X8A, 0X9D, 0X04, 0X5F, 0X24, 0XCB, 0X2E,
46     0X4B, 0XE1, 0X60, 0X82, 0X46, 0XE1, 0X52, 0XAB, 0X0C, 0X81, 0X47, 0X70,
47     0X6C, 0XDD, 0X64, 0XD1, 0XEB, 0XF5, 0X2C, 0XA3, 0X0F, 0X82, 0X3D, 0X0C,
48     0X2B, 0XAE, 0X97, 0XD7, 0XB6, 0X14, 0X86, 0X10, 0X79, 0XBB, 0X3B, 0X13,
49     0X80, 0X77, 0X8C, 0X08, 0XE1, 0X49, 0XD2, 0X6A, 0X62, 0X2F, 0X1F, 0X5E,
50     0XFA, 0X96, 0X68, 0XDF, 0X89, 0X27, 0X95, 0X38, 0X9F, 0X06, 0XD7, 0X3E,
51     0XC9, 0XCB, 0X26, 0X59, 0X0D, 0X73, 0XDE, 0XB0, 0XC8, 0XE9, 0X26, 0X0E,
52     0X83, 0X15, 0XC6, 0XEF, 0X5B, 0X8B, 0XD2, 0X04, 0X60, 0XCA, 0X49, 0XA6,
53     0X28, 0XF6, 0X69, 0X3B, 0XF6, 0XCB, 0XC8, 0X28, 0X91, 0XE5, 0X9D, 0X8A,
54     0X61, 0X57, 0X37, 0XAC, 0X74, 0X14, 0XDC, 0X74, 0XE0, 0X3A, 0XEE, 0X72,
55     0X2F, 0X2E, 0X9C, 0XFB, 0XD0, 0XBB, 0XBF, 0XF5, 0X3D, 0X00, 0XE1, 0X06,
56     0X33, 0XE8, 0X82, 0X2B, 0XAE, 0X53, 0XA6, 0X3A, 0X16, 0X73, 0X8C, 0XDD,
57     0X41, 0X0E, 0X20, 0X3A, 0XC0, 0XB4, 0XA7, 0XA1, 0XE9, 0XB2, 0X4F, 0X90,
58     0X2E, 0X32, 0X60, 0XE9, 0X57, 0XCB, 0XB9, 0X04, 0X92, 0X68, 0X68, 0XE5,
59     0X38, 0X26, 0X60, 0X75, 0XB2, 0X9F, 0X77, 0XFF, 0X91, 0X14, 0XEF, 0XAE,
60     0X20, 0X49, 0XFC, 0XAD, 0X40, 0X15, 0X48, 0XD1, 0X02, 0X31, 0X61, 0X19,
61     0X5E, 0XB8, 0X97, 0XEF, 0XAD, 0X77, 0XB7, 0X64, 0X9A, 0X7A, 0XBF, 0X5F,
62     0XC1, 0X13, 0XEF, 0X9B, 0X62, 0XFB, 0X0D, 0X6C, 0XE0, 0X54, 0X69, 0X16,
63     0XA9, 0X03, 0XDA, 0X6E, 0XE9, 0X83, 0X93, 0X71, 0X76, 0XC6, 0X69, 0X85,
64     0X82, 0X17, 0X02, 0X03, 0X01, 0X00, 0X01, 0XA3, 0X42, 0X30, 0X40, 0X30,
65     0X0E, 0X06, 0X03, 0X55, 0X1D, 0X0F, 0X01, 0X01, 0XFF, 0X04, 0X04, 0X03,
66     0X02, 0X01, 0X06, 0X30, 0X0F, 0X06, 0X03, 0X55, 0X1D, 0X13, 0X01, 0X01,
67     0XFF, 0X04, 0X05, 0X30, 0X03, 0X01, 0X01, 0XFF, 0X30, 0X1D, 0X06, 0X03,
68     0X55, 0X1D, 0X0E, 0X04, 0X16, 0X04, 0X14, 0X8F, 0XF0, 0X4B, 0X7F, 0XA8,
69     0X2E, 0X45, 0X24, 0XAE, 0X4D, 0X50, 0XFA, 0X63, 0X9A, 0X8B, 0XDE, 0XE2,
70     0XDD, 0X1B, 0XBC, 0X30, 0X0D, 0X06, 0X09, 0X2A, 0X86, 0X48, 0X86, 0XF7,
71     0X0D, 0X01, 0X01, 0X0B, 0X05, 0X00, 0X03, 0X82, 0X01, 0X01, 0X00, 0X4B,
72     0X40, 0XDB, 0XC0, 0X50, 0XAA, 0XFE, 0XC8, 0X0C, 0XEF, 0XF7, 0X96, 0X54,
73     0X45, 0X49, 0XBB, 0X96, 0X00, 0X09, 0X41, 0XAC, 0XB3, 0X13, 0X86, 0X86,
74     0X28, 0X07, 0X33, 0XCA, 0X6B, 0XE6, 0X74, 0XB9, 0XBA, 0X00, 0X2D, 0XAE,
75     0XA4, 0X0A, 0XD3, 0XF5, 0XF1, 0XF1, 0X0F, 0X8A, 0XBF, 0X73, 0X67, 0X4A,
76     0X83, 0XC7, 0X44, 0X7B, 0X78, 0XE0, 0XAF, 0X6E, 0X6C, 0X6F, 0X03, 0X29,
77     0X8E, 0X33, 0X39, 0X45, 0XC3, 0X8E, 0XE4, 0XB9, 0X57, 0X6C, 0XAA, 0XFC,
78     0X12, 0X96, 0XEC, 0X53, 0XC6, 0X2D, 0XE4, 0X24, 0X6C, 0XB9, 0X94, 0X63,
79     0XFB, 0XDC, 0X53, 0X68, 0X67, 0X56, 0X3E, 0X83, 0XB8, 0XCF, 0X35, 0X21,
80     0XC3, 0XC9, 0X68, 0XFE, 0XCE, 0XDA, 0XC2, 0X53, 0XAA, 0XCC, 0X90, 0X8A,
81     0XE9, 0XF0, 0X5D, 0X46, 0X8C, 0X95, 0XDD, 0X7A, 0X58, 0X28, 0X1A, 0X2F,
82     0X1D, 0XDE, 0XCD, 0X00, 0X37, 0X41, 0X8F, 0XED, 0X44, 0X6D, 0XD7, 0X53,
83     0X28, 0X97, 0X7E, 0XF3, 0X67, 0X04, 0X1E, 0X15, 0XD7, 0X8A, 0X96, 0XB4,
84     0XD3, 0XDE, 0X4C, 0X27, 0XA4, 0X4C, 0X1B, 0X73, 0X73, 0X76, 0XF4, 0X17,
85     0X99, 0XC2, 0X1F, 0X7A, 0X0E, 0XE3, 0X2D, 0X08, 0XAD, 0X0A, 0X1C, 0X2C,
86     0XFF, 0X3C, 0XAB, 0X55, 0X0E, 0X0F, 0X91, 0X7E, 0X36, 0XEB, 0XC3, 0X57,
87     0X49, 0XBE, 0XE1, 0X2E, 0X2D, 0X7C, 0X60, 0X8B, 0XC3, 0X41, 0X51, 0X13,
88     0X23, 0X9D, 0XCE, 0XF7, 0X32, 0X6B, 0X94, 0X01, 0XA8, 0X99, 0XE7, 0X2C,
89     0X33, 0X1F, 0X3A, 0X3B, 0X25, 0XD2, 0X86, 0X40, 0XCE, 0X3B, 0X2C, 0X86,
90     0X78, 0XC9, 0X61, 0X2F, 0X14, 0XBA, 0XEE, 0XDB, 0X55, 0X6F, 0XDF, 0X84,
91     0XEE, 0X05, 0X09, 0X4D, 0XBD, 0X28, 0XD8, 0X72, 0XCE, 0XD3, 0X62, 0X50,
92     0X65, 0X1E, 0XEB, 0X92, 0X97, 0X83, 0X31, 0XD9, 0XB3, 0XB5, 0XCA, 0X47,
93     0X58, 0X3F, 0X5F
94 };
95 
96 const unsigned char GLOBALSIGN_ECC_ROOT_CA_DER[] = {
97     0X30, 0X82, 0X02, 0X1E, 0X30, 0X82, 0X01, 0XA4, 0XA0, 0X03, 0X02, 0X01,
98     0X02, 0X02, 0X11, 0X60, 0X59, 0X49, 0XE0, 0X26, 0X2E, 0XBB, 0X55, 0XF9,
99     0X0A, 0X77, 0X8A, 0X71, 0XF9, 0X4A, 0XD8, 0X6C, 0X30, 0X0A, 0X06, 0X08,
100     0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X30, 0X50, 0X31, 0X24,
101     0X30, 0X22, 0X06, 0X03, 0X55, 0X04, 0X0B, 0X13, 0X1B, 0X47, 0X6C, 0X6F,
102     0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X45, 0X43, 0X43, 0X20,
103     0X52, 0X6F, 0X6F, 0X74, 0X20, 0X43, 0X41, 0X20, 0X2D, 0X20, 0X52, 0X35,
104     0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X0A, 0X47,
105     0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X31, 0X13, 0X30,
106     0X11, 0X06, 0X03, 0X55, 0X04, 0X03, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62,
107     0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X30, 0X1E, 0X17, 0X0D, 0X31, 0X32,
108     0X31, 0X31, 0X31, 0X33, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30, 0X5A, 0X17,
109     0X0D, 0X33, 0X38, 0X30, 0X31, 0X31, 0X39, 0X30, 0X33, 0X31, 0X34, 0X30,
110     0X37, 0X5A, 0X30, 0X50, 0X31, 0X24, 0X30, 0X22, 0X06, 0X03, 0X55, 0X04,
111     0X0B, 0X13, 0X1B, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67,
112     0X6E, 0X20, 0X45, 0X43, 0X43, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X43,
113     0X41, 0X20, 0X2D, 0X20, 0X52, 0X35, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03,
114     0X55, 0X04, 0X0A, 0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53,
115     0X69, 0X67, 0X6E, 0X31, 0X13, 0X30, 0X11, 0X06, 0X03, 0X55, 0X04, 0X03,
116     0X13, 0X0A, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E,
117     0X30, 0X76, 0X30, 0X10, 0X06, 0X07, 0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X02,
118     0X01, 0X06, 0X05, 0X2B, 0X81, 0X04, 0X00, 0X22, 0X03, 0X62, 0X00, 0X04,
119     0X47, 0X45, 0X0E, 0X96, 0XFB, 0X7D, 0X5D, 0XBF, 0XE9, 0X39, 0XD1, 0X21,
120     0XF8, 0X9F, 0X0B, 0XB6, 0XD5, 0X7B, 0X1E, 0X92, 0X3A, 0X48, 0X59, 0X1C,
121     0XF0, 0X62, 0X31, 0X2D, 0XC0, 0X7A, 0X28, 0XFE, 0X1A, 0XA7, 0X5C, 0XB3,
122     0XB6, 0XCC, 0X97, 0XE7, 0X45, 0XD4, 0X58, 0XFA, 0XD1, 0X77, 0X6D, 0X43,
123     0XA2, 0XC0, 0X87, 0X65, 0X34, 0X0A, 0X1F, 0X7A, 0XDD, 0XEB, 0X3C, 0X33,
124     0XA1, 0XC5, 0X9D, 0X4D, 0XA4, 0X6F, 0X41, 0X95, 0X38, 0X7F, 0XC9, 0X1E,
125     0X84, 0XEB, 0XD1, 0X9E, 0X49, 0X92, 0X87, 0X94, 0X87, 0X0C, 0X3A, 0X85,
126     0X4A, 0X66, 0X9F, 0X9D, 0X59, 0X93, 0X4D, 0X97, 0X61, 0X06, 0X86, 0X4A,
127     0XA3, 0X42, 0X30, 0X40, 0X30, 0X0E, 0X06, 0X03, 0X55, 0X1D, 0X0F, 0X01,
128     0X01, 0XFF, 0X04, 0X04, 0X03, 0X02, 0X01, 0X06, 0X30, 0X0F, 0X06, 0X03,
129     0X55, 0X1D, 0X13, 0X01, 0X01, 0XFF, 0X04, 0X05, 0X30, 0X03, 0X01, 0X01,
130     0XFF, 0X30, 0X1D, 0X06, 0X03, 0X55, 0X1D, 0X0E, 0X04, 0X16, 0X04, 0X14,
131     0X3D, 0XE6, 0X29, 0X48, 0X9B, 0XEA, 0X07, 0XCA, 0X21, 0X44, 0X4A, 0X26,
132     0XDE, 0X6E, 0XDE, 0XD2, 0X83, 0XD0, 0X9F, 0X59, 0X30, 0X0A, 0X06, 0X08,
133     0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X03, 0X68, 0X00, 0X30,
134     0X65, 0X02, 0X31, 0X00, 0XE5, 0X69, 0X12, 0XC9, 0X6E, 0XDB, 0XC6, 0X31,
135     0XBA, 0X09, 0X41, 0XE1, 0X97, 0XF8, 0XFB, 0XFD, 0X9A, 0XE2, 0X7D, 0X12,
136     0XC9, 0XED, 0X7C, 0X64, 0XD3, 0XCB, 0X05, 0X25, 0X8B, 0X56, 0XD9, 0XA0,
137     0XE7, 0X5E, 0X5D, 0X4E, 0X0B, 0X83, 0X9C, 0X5B, 0X76, 0X29, 0XA0, 0X09,
138     0X26, 0X21, 0X6A, 0X62, 0X02, 0X30, 0X71, 0XD2, 0XB5, 0X8F, 0X5C, 0XEA,
139     0X3B, 0XE1, 0X78, 0X09, 0X85, 0XA8, 0X75, 0X92, 0X3B, 0XC8, 0X5C, 0XFD,
140     0X48, 0XEF, 0X0D, 0X74, 0X22, 0XA8, 0X08, 0XE2, 0X6E, 0XC5, 0X49, 0XCE,
141     0XC7, 0X0C, 0XBC, 0XA7, 0X61, 0X69, 0XF1, 0XF7, 0X3B, 0XE1, 0X2A, 0XCB,
142     0XF9, 0X2B, 0XF3, 0X66, 0X90, 0X37
143 };
144 
145 const unsigned char E46_GLOBALSIGN_ROOT_CA_DER[] = {
146     0X30, 0X82, 0X02, 0X0B, 0X30, 0X82, 0X01, 0X91, 0XA0, 0X03, 0X02, 0X01,
147     0X02, 0X02, 0X12, 0X11, 0XD2, 0XBB, 0XBA, 0X33, 0X6E, 0XD4, 0XBC, 0XE6,
148     0X24, 0X68, 0XC5, 0X0D, 0X84, 0X1D, 0X98, 0XE8, 0X43, 0X30, 0X0A, 0X06,
149     0X08, 0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X30, 0X46, 0X31,
150     0X0B, 0X30, 0X09, 0X06, 0X03, 0X55, 0X04, 0X06, 0X13, 0X02, 0X42, 0X45,
151     0X31, 0X19, 0X30, 0X17, 0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X10, 0X47,
152     0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X6E, 0X76,
153     0X2D, 0X73, 0X61, 0X31, 0X1C, 0X30, 0X1A, 0X06, 0X03, 0X55, 0X04, 0X03,
154     0X13, 0X13, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E,
155     0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X45, 0X34, 0X36, 0X30, 0X1E, 0X17,
156     0X0D, 0X31, 0X39, 0X30, 0X33, 0X32, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30,
157     0X30, 0X5A, 0X17, 0X0D, 0X34, 0X36, 0X30, 0X33, 0X32, 0X30, 0X30, 0X30,
158     0X30, 0X30, 0X30, 0X30, 0X5A, 0X30, 0X46, 0X31, 0X0B, 0X30, 0X09, 0X06,
159     0X03, 0X55, 0X04, 0X06, 0X13, 0X02, 0X42, 0X45, 0X31, 0X19, 0X30, 0X17,
160     0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X10, 0X47, 0X6C, 0X6F, 0X62, 0X61,
161     0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X6E, 0X76, 0X2D, 0X73, 0X61, 0X31,
162     0X1C, 0X30, 0X1A, 0X06, 0X03, 0X55, 0X04, 0X03, 0X13, 0X13, 0X47, 0X6C,
163     0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X52, 0X6F, 0X6F,
164     0X74, 0X20, 0X45, 0X34, 0X36, 0X30, 0X76, 0X30, 0X10, 0X06, 0X07, 0X2A,
165     0X86, 0X48, 0XCE, 0X3D, 0X02, 0X01, 0X06, 0X05, 0X2B, 0X81, 0X04, 0X00,
166     0X22, 0X03, 0X62, 0X00, 0X04, 0X9C, 0X0E, 0XB1, 0XCF, 0XB7, 0XE8, 0X9E,
167     0X52, 0X77, 0X75, 0X34, 0XFA, 0XA5, 0X46, 0XA7, 0XAD, 0X32, 0X19, 0X32,
168     0XB4, 0X07, 0XA9, 0X27, 0XCA, 0X94, 0XBB, 0X0C, 0XD2, 0X0A, 0X10, 0XC7,
169     0XDA, 0X89, 0XB0, 0X97, 0X0C, 0X70, 0X13, 0X09, 0X01, 0X8E, 0XD8, 0XEA,
170     0X47, 0XEA, 0XBE, 0XB2, 0X80, 0X2B, 0XCD, 0XFC, 0X28, 0X0D, 0XDB, 0XAC,
171     0XBC, 0XA4, 0X86, 0X37, 0XED, 0X70, 0X08, 0X00, 0X75, 0XEA, 0X93, 0X0B,
172     0X7B, 0X2E, 0X52, 0X9C, 0X23, 0X68, 0X23, 0X06, 0X43, 0XEC, 0X92, 0X2F,
173     0X53, 0X84, 0XDB, 0XFB, 0X47, 0X14, 0X07, 0XE8, 0X5F, 0X94, 0X67, 0X5D,
174     0XC9, 0X7A, 0X81, 0X3C, 0X20, 0XA3, 0X42, 0X30, 0X40, 0X30, 0X0E, 0X06,
175     0X03, 0X55, 0X1D, 0X0F, 0X01, 0X01, 0XFF, 0X04, 0X04, 0X03, 0X02, 0X01,
176     0X86, 0X30, 0X0F, 0X06, 0X03, 0X55, 0X1D, 0X13, 0X01, 0X01, 0XFF, 0X04,
177     0X05, 0X30, 0X03, 0X01, 0X01, 0XFF, 0X30, 0X1D, 0X06, 0X03, 0X55, 0X1D,
178     0X0E, 0X04, 0X16, 0X04, 0X14, 0X31, 0X0A, 0X90, 0X8F, 0XB6, 0XC6, 0X9D,
179     0XD2, 0X44, 0X4B, 0X80, 0XB5, 0XA2, 0XE6, 0X1F, 0XB1, 0X12, 0X4F, 0X1B,
180     0X95, 0X30, 0X0A, 0X06, 0X08, 0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03,
181     0X03, 0X03, 0X68, 0X00, 0X30, 0X65, 0X02, 0X31, 0X00, 0XDF, 0X54, 0X90,
182     0XED, 0X9B, 0XEF, 0X8B, 0X94, 0X02, 0X93, 0X17, 0X82, 0X99, 0XBE, 0XB3,
183     0X9E, 0X2C, 0XF6, 0X0B, 0X91, 0X8C, 0X9F, 0X4A, 0X14, 0XB1, 0XF6, 0X64,
184     0XBC, 0XBB, 0X68, 0X51, 0X13, 0X0C, 0X03, 0XF7, 0X15, 0X8B, 0X84, 0X60,
185     0XB9, 0X8B, 0XFF, 0X52, 0X8E, 0XE7, 0X8C, 0XBC, 0X1C, 0X02, 0X30, 0X3C,
186     0XF9, 0X11, 0XD4, 0X8C, 0X4E, 0XC0, 0XC1, 0X61, 0XC2, 0X15, 0X4C, 0XAA,
187     0XAB, 0X1D, 0X0B, 0X31, 0X5F, 0X3B, 0X1C, 0XE2, 0X00, 0X97, 0X44, 0X31,
188     0XE6, 0XFE, 0X73, 0X96, 0X2F, 0XDA, 0X96, 0XD3, 0XFE, 0X08, 0X07, 0XB3,
189     0X34, 0X89, 0XBC, 0X05, 0X9F, 0XF7, 0X1E, 0X86, 0XEE, 0X8B, 0X70
190 };
191 
192 const unsigned char GLOBALSIGN_IOT_ROOT_E60_DER[] = {
193     0X30, 0X82, 0X02, 0X13, 0X30, 0X82, 0X01, 0X99, 0XA0, 0X03, 0X02, 0X01,
194     0X02, 0X02, 0X10, 0X76, 0X53, 0XFE, 0XB5, 0X6A, 0XC8, 0XEE, 0X4E, 0X8A,
195     0XC6, 0XFE, 0X5E, 0X9E, 0X38, 0XF5, 0XEB, 0X30, 0X0A, 0X06, 0X08, 0X2A,
196     0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X30, 0X4A, 0X31, 0X0B, 0X30,
197     0X09, 0X06, 0X03, 0X55, 0X04, 0X06, 0X13, 0X02, 0X42, 0X45, 0X31, 0X19,
198     0X30, 0X17, 0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X10, 0X47, 0X6C, 0X6F,
199     0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X6E, 0X76, 0X2D, 0X73,
200     0X61, 0X31, 0X20, 0X30, 0X1E, 0X06, 0X03, 0X55, 0X04, 0X03, 0X13, 0X17,
201     0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X49,
202     0X6F, 0X54, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X45, 0X36, 0X30, 0X30,
203     0X20, 0X17, 0X0D, 0X32, 0X30, 0X30, 0X33, 0X31, 0X38, 0X30, 0X30, 0X30,
204     0X30, 0X30, 0X30, 0X5A, 0X18, 0X0F, 0X32, 0X30, 0X36, 0X30, 0X30, 0X33,
205     0X31, 0X38, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30, 0X5A, 0X30, 0X4A, 0X31,
206     0X0B, 0X30, 0X09, 0X06, 0X03, 0X55, 0X04, 0X06, 0X13, 0X02, 0X42, 0X45,
207     0X31, 0X19, 0X30, 0X17, 0X06, 0X03, 0X55, 0X04, 0X0A, 0X13, 0X10, 0X47,
208     0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E, 0X20, 0X6E, 0X76,
209     0X2D, 0X73, 0X61, 0X31, 0X20, 0X30, 0X1E, 0X06, 0X03, 0X55, 0X04, 0X03,
210     0X13, 0X17, 0X47, 0X6C, 0X6F, 0X62, 0X61, 0X6C, 0X53, 0X69, 0X67, 0X6E,
211     0X20, 0X49, 0X6F, 0X54, 0X20, 0X52, 0X6F, 0X6F, 0X74, 0X20, 0X45, 0X36,
212     0X30, 0X30, 0X76, 0X30, 0X10, 0X06, 0X07, 0X2A, 0X86, 0X48, 0XCE, 0X3D,
213     0X02, 0X01, 0X06, 0X05, 0X2B, 0X81, 0X04, 0X00, 0X22, 0X03, 0X62, 0X00,
214     0X04, 0XCA, 0X9E, 0X91, 0X00, 0X0F, 0X0D, 0XA0, 0XCE, 0X23, 0X36, 0XF7,
215     0X8F, 0X55, 0X8F, 0X8C, 0XAF, 0X26, 0X1B, 0X1A, 0X6B, 0XEF, 0XD1, 0X29,
216     0XE6, 0X14, 0X50, 0XD7, 0XC4, 0X00, 0XD2, 0X71, 0X99, 0X25, 0XF5, 0XF5,
217     0X0C, 0X1D, 0X0E, 0X70, 0X09, 0XC0, 0XAF, 0X13, 0XB4, 0X69, 0X03, 0X48,
218     0X04, 0XAC, 0XB4, 0X61, 0X6B, 0XB6, 0X95, 0XEF, 0XA8, 0X48, 0X6E, 0XEA,
219     0XBD, 0X50, 0XD4, 0X74, 0X12, 0XA9, 0XA2, 0X37, 0X9C, 0X1C, 0XBA, 0X59,
220     0X7C, 0X17, 0X6F, 0XFC, 0XDA, 0X7F, 0XC1, 0XE2, 0XA5, 0X1D, 0X66, 0X6E,
221     0X83, 0X6D, 0X4C, 0X68, 0XE9, 0X82, 0XCE, 0XC1, 0X70, 0X88, 0X24, 0X7D,
222     0X60, 0XA3, 0X42, 0X30, 0X40, 0X30, 0X0E, 0X06, 0X03, 0X55, 0X1D, 0X0F,
223     0X01, 0X01, 0XFF, 0X04, 0X04, 0X03, 0X02, 0X01, 0X86, 0X30, 0X0F, 0X06,
224     0X03, 0X55, 0X1D, 0X13, 0X01, 0X01, 0XFF, 0X04, 0X05, 0X30, 0X03, 0X01,
225     0X01, 0XFF, 0X30, 0X1D, 0X06, 0X03, 0X55, 0X1D, 0X0E, 0X04, 0X16, 0X04,
226     0X14, 0X8C, 0X93, 0XF0, 0X1E, 0X2C, 0XF5, 0XD4, 0X8C, 0X59, 0X1D, 0XBF,
227     0X6C, 0XCA, 0X15, 0X8F, 0X32, 0X64, 0X16, 0XF7, 0X86, 0X30, 0X0A, 0X06,
228     0X08, 0X2A, 0X86, 0X48, 0XCE, 0X3D, 0X04, 0X03, 0X03, 0X03, 0X68, 0X00,
229     0X30, 0X65, 0X02, 0X31, 0X00, 0XA9, 0X0A, 0X77, 0X06, 0XED, 0XE2, 0XAD,
230     0X94, 0X65, 0X5F, 0X2A, 0XB5, 0XE2, 0X49, 0XD1, 0XF7, 0XA8, 0X94, 0X86,
231     0X9B, 0X48, 0X8B, 0XDB, 0XE2, 0XF1, 0XF9, 0XD7, 0XE8, 0X75, 0X11, 0X99,
232     0X94, 0XBD, 0XD8, 0X9F, 0XC6, 0X4E, 0XC5, 0XE8, 0XEB, 0X7B, 0X4F, 0X78,
233     0XD8, 0XD3, 0X77, 0X55, 0X56, 0X02, 0X30, 0X37, 0X46, 0X36, 0X39, 0X4C,
234     0XED, 0X02, 0X9F, 0XF1, 0X9C, 0X17, 0X5F, 0XA7, 0XB2, 0XE9, 0XBA, 0X24,
235     0X56, 0XD5, 0XE3, 0XB1, 0XE3, 0XDE, 0X84, 0XAA, 0XD9, 0X02, 0X0D, 0X8F,
236     0X56, 0X64, 0X01, 0X61, 0X6E, 0X81, 0X34, 0X6D, 0X9F, 0X4C, 0XBD, 0X10,
237     0X4E, 0XEB, 0XE3, 0X57, 0XC0, 0X36, 0X55
238 };
239 
240 CertItem g_commonCerts = {
241     .certDer = GLOBALSIGN_ECC_ROOT_CA_DER,
242     .certLen = sizeof(GLOBALSIGN_ECC_ROOT_CA_DER)
243 };
244 
245 CertItem g_commonOtherCert[] = {
246     {
247         .certDer = GLOBALSIGN_ROOT_CA_R3_DER,
248         .certLen = sizeof(GLOBALSIGN_ROOT_CA_R3_DER)
249     }
250 };
251 
LoadCommonCert(mbedtls_x509_crt * chain)252 int32_t LoadCommonCert(mbedtls_x509_crt* chain)
253 {
254     if (chain == NULL) {
255         ATTEST_LOG_ERROR("[LoadCommonCert] Invalid parameter");
256         return ERR_NET_PARSE_CERT_FAIL;
257     }
258     int32_t ret = mbedtls_x509_crt_parse_der(chain, g_commonCerts.certDer, g_commonCerts.certLen);
259     if (ret < 0) {
260         ATTEST_LOG_ERROR("[LoadCommonCert] Parse x509 certificate failed, ret = -0x%x", -ret);
261         return ERR_NET_PARSE_CERT_FAIL;
262     }
263     return ATTEST_OK;
264 }
265 
LoadCommonOtherCert(mbedtls_x509_crt * chain,uint32_t cursor)266 int32_t LoadCommonOtherCert(mbedtls_x509_crt* chain, uint32_t cursor)
267 {
268     if (chain == NULL || cursor >= ATTEST_ARRAY_SIZE(g_commonOtherCert)) {
269         ATTEST_LOG_ERROR("[LoadCommonOtherCert] Invalid parameter");
270         return ERR_NET_PARSE_CERT_FAIL;
271     }
272     int32_t ret = mbedtls_x509_crt_parse_der(chain, g_commonOtherCert[cursor].certDer,
273                                              g_commonOtherCert[cursor].certLen);
274     if (ret < 0) {
275         ATTEST_LOG_ERROR("[LoadCommonOtherCert] Parse x509 certificate failed, ret = -0x%x", -ret);
276         return ERR_NET_PARSE_CERT_FAIL;
277     }
278     return ATTEST_OK;
279 }
280 
GetCommonCertSize(void)281 int32_t GetCommonCertSize(void)
282 {
283     return ATTEST_ARRAY_SIZE(g_commonOtherCert);
284 }