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 <gtest/gtest.h>
17 #include "cm_test_log.h"
18 #include "cm_test_common.h"
19 #include "cert_manager_api.h"
20 #include "cm_log.h"
21 #include "cm_mem.h"
22
23 using namespace testing::ext;
24 using namespace CertmanagerTest;
25 namespace {
26 constexpr uint32_t MAX_URI_LEN = 256;
27
28 static const uint8_t g_certData01[] = { /* 40dc992e.0 */
29 0x30, 0x82, 0x04, 0x31, 0x30, 0x82, 0x03, 0x19, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x01, 0x00,
30 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30,
31 0x81, 0x95, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x47, 0x52, 0x31,
32 0x44, 0x30, 0x42, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x3b, 0x48, 0x65, 0x6c, 0x6c, 0x65, 0x6e,
33 0x69, 0x63, 0x20, 0x41, 0x63, 0x61, 0x64, 0x65, 0x6d, 0x69, 0x63, 0x20, 0x61, 0x6e, 0x64, 0x20,
34 0x52, 0x65, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x20, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75,
35 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x43, 0x65, 0x72, 0x74, 0x2e, 0x20, 0x41, 0x75, 0x74, 0x68,
36 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x40, 0x30, 0x3e, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x37,
37 0x48, 0x65, 0x6c, 0x6c, 0x65, 0x6e, 0x69, 0x63, 0x20, 0x41, 0x63, 0x61, 0x64, 0x65, 0x6d, 0x69,
38 0x63, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x52, 0x65, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x20, 0x49,
39 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x52, 0x6f, 0x6f, 0x74,
40 0x43, 0x41, 0x20, 0x32, 0x30, 0x31, 0x31, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x31, 0x31, 0x32, 0x30,
41 0x36, 0x31, 0x33, 0x34, 0x39, 0x35, 0x32, 0x5a, 0x17, 0x0d, 0x33, 0x31, 0x31, 0x32, 0x30, 0x31,
42 0x31, 0x33, 0x34, 0x39, 0x35, 0x32, 0x5a, 0x30, 0x81, 0x95, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
43 0x55, 0x04, 0x06, 0x13, 0x02, 0x47, 0x52, 0x31, 0x44, 0x30, 0x42, 0x06, 0x03, 0x55, 0x04, 0x0a,
44 0x13, 0x3b, 0x48, 0x65, 0x6c, 0x6c, 0x65, 0x6e, 0x69, 0x63, 0x20, 0x41, 0x63, 0x61, 0x64, 0x65,
45 0x6d, 0x69, 0x63, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x52, 0x65, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68,
46 0x20, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x43, 0x65,
47 0x72, 0x74, 0x2e, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x40, 0x30,
48 0x3e, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x37, 0x48, 0x65, 0x6c, 0x6c, 0x65, 0x6e, 0x69, 0x63,
49 0x20, 0x41, 0x63, 0x61, 0x64, 0x65, 0x6d, 0x69, 0x63, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x52, 0x65,
50 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x20, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74, 0x75, 0x74, 0x69,
51 0x6f, 0x6e, 0x73, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x43, 0x41, 0x20, 0x32, 0x30, 0x31, 0x31, 0x30,
52 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01,
53 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00,
54 0xa9, 0x53, 0x00, 0xe3, 0x2e, 0xa6, 0xf6, 0x8e, 0xfa, 0x60, 0xd8, 0x2d, 0x95, 0x3e, 0xf8, 0x2c,
55 0x2a, 0x54, 0x4e, 0xcd, 0xb9, 0x84, 0x61, 0x94, 0x58, 0x4f, 0x8f, 0x3d, 0x8b, 0xe4, 0x43, 0xf3,
56 0x75, 0x89, 0x8d, 0x51, 0xe4, 0xc3, 0x37, 0xd2, 0x8a, 0x88, 0x4d, 0x79, 0x1e, 0xb7, 0x12, 0xdd,
57 0x43, 0x78, 0x4a, 0x8a, 0x92, 0xe6, 0xd7, 0x48, 0xd5, 0x0f, 0xa4, 0x3a, 0x29, 0x44, 0x35, 0xb8,
58 0x07, 0xf6, 0x68, 0x1d, 0x55, 0xcd, 0x38, 0x51, 0xf0, 0x8c, 0x24, 0x31, 0x85, 0xaf, 0x83, 0xc9,
59 0x7d, 0xe9, 0x77, 0xaf, 0xed, 0x1a, 0x7b, 0x9d, 0x17, 0xf9, 0xb3, 0x9d, 0x38, 0x50, 0x0f, 0xa6,
60 0x5a, 0x79, 0x91, 0x80, 0xaf, 0x37, 0xae, 0xa6, 0xd3, 0x31, 0xfb, 0xb5, 0x26, 0x09, 0x9d, 0x3c,
61 0x5a, 0xef, 0x51, 0xc5, 0x2b, 0xdf, 0x96, 0x5d, 0xeb, 0x32, 0x1e, 0x02, 0xda, 0x70, 0x49, 0xec,
62 0x6e, 0x0c, 0xc8, 0x9a, 0x37, 0x8d, 0xf7, 0xf1, 0x36, 0x60, 0x4b, 0x26, 0x2c, 0x82, 0x9e, 0xd0,
63 0x78, 0xf3, 0x0d, 0x0f, 0x63, 0xa4, 0x51, 0x30, 0xe1, 0xf9, 0x2b, 0x27, 0x12, 0x07, 0xd8, 0xea,
64 0xbd, 0x18, 0x62, 0x98, 0xb0, 0x59, 0x37, 0x7d, 0xbe, 0xee, 0xf3, 0x20, 0x51, 0x42, 0x5a, 0x83,
65 0xef, 0x93, 0xba, 0x69, 0x15, 0xf1, 0x62, 0x9d, 0x9f, 0x99, 0x39, 0x82, 0xa1, 0xb7, 0x74, 0x2e,
66 0x8b, 0xd4, 0xc5, 0x0b, 0x7b, 0x2f, 0xf0, 0xc8, 0x0a, 0xda, 0x3d, 0x79, 0x0a, 0x9a, 0x93, 0x1c,
67 0xa5, 0x28, 0x72, 0x73, 0x91, 0x43, 0x9a, 0xa7, 0xd1, 0x4d, 0x85, 0x84, 0xb9, 0xa9, 0x74, 0x8f,
68 0x14, 0x40, 0xc7, 0xdc, 0xde, 0xac, 0x41, 0x64, 0x6c, 0xb4, 0x19, 0x9b, 0x02, 0x63, 0x6d, 0x24,
69 0x64, 0x8f, 0x44, 0xb2, 0x25, 0xea, 0xce, 0x5d, 0x74, 0x0c, 0x63, 0x32, 0x5c, 0x8d, 0x87, 0xe5,
70 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x81, 0x89, 0x30, 0x81, 0x86, 0x30, 0x0f, 0x06, 0x03, 0x55,
71 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0b, 0x06, 0x03,
72 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e,
73 0x04, 0x16, 0x04, 0x14, 0xa6, 0x91, 0x42, 0xfd, 0x13, 0x61, 0x4a, 0x23, 0x9e, 0x08, 0xa4, 0x29,
74 0xe5, 0xd8, 0x13, 0x04, 0x23, 0xee, 0x41, 0x25, 0x30, 0x47, 0x06, 0x03, 0x55, 0x1d, 0x1e, 0x04,
75 0x40, 0x30, 0x3e, 0xa0, 0x3c, 0x30, 0x05, 0x82, 0x03, 0x2e, 0x67, 0x72, 0x30, 0x05, 0x82, 0x03,
76 0x2e, 0x65, 0x75, 0x30, 0x06, 0x82, 0x04, 0x2e, 0x65, 0x64, 0x75, 0x30, 0x06, 0x82, 0x04, 0x2e,
77 0x6f, 0x72, 0x67, 0x30, 0x05, 0x81, 0x03, 0x2e, 0x67, 0x72, 0x30, 0x05, 0x81, 0x03, 0x2e, 0x65,
78 0x75, 0x30, 0x06, 0x81, 0x04, 0x2e, 0x65, 0x64, 0x75, 0x30, 0x06, 0x81, 0x04, 0x2e, 0x6f, 0x72,
79 0x67, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00,
80 0x03, 0x82, 0x01, 0x01, 0x00, 0x1f, 0xef, 0x79, 0x41, 0xe1, 0x7b, 0x6e, 0x3f, 0xb2, 0x8c, 0x86,
81 0x37, 0x42, 0x4a, 0x4e, 0x1c, 0x37, 0x1e, 0x8d, 0x66, 0xba, 0x24, 0x81, 0xc9, 0x4f, 0x12, 0x0f,
82 0x21, 0xc0, 0x03, 0x97, 0x86, 0x25, 0x6d, 0x5d, 0xd3, 0x22, 0x29, 0xa8, 0x6c, 0xa2, 0x0d, 0xa9,
83 0xeb, 0x3d, 0x06, 0x5b, 0x99, 0x3a, 0xc7, 0xcc, 0xc3, 0x9a, 0x34, 0x7f, 0xab, 0x0e, 0xc8, 0x4e,
84 0x1c, 0xe1, 0xfa, 0xe4, 0xdc, 0xcd, 0x0d, 0xbe, 0xbf, 0x24, 0xfe, 0x6c, 0xe7, 0x6b, 0xc2, 0x0d,
85 0xc8, 0x06, 0x9e, 0x4e, 0x8d, 0x61, 0x28, 0xa6, 0x6a, 0xfd, 0xe5, 0xf6, 0x62, 0xea, 0x18, 0x3c,
86 0x4e, 0xa0, 0x53, 0x9d, 0xb2, 0x3a, 0x9c, 0xeb, 0xa5, 0x9c, 0x91, 0x16, 0xb6, 0x4d, 0x82, 0xe0,
87 0x0c, 0x05, 0x48, 0xa9, 0x6c, 0xf5, 0xcc, 0xf8, 0xcb, 0x9d, 0x49, 0xb4, 0xf0, 0x02, 0xa5, 0xfd,
88 0x70, 0x03, 0xed, 0x8a, 0x21, 0xa5, 0xae, 0x13, 0x86, 0x49, 0xc3, 0x33, 0x73, 0xbe, 0x87, 0x3b,
89 0x74, 0x8b, 0x17, 0x45, 0x26, 0x4c, 0x16, 0x91, 0x83, 0xfe, 0x67, 0x7d, 0xcd, 0x4d, 0x63, 0x67,
90 0xfa, 0xf3, 0x03, 0x12, 0x96, 0x78, 0x06, 0x8d, 0xb1, 0x67, 0xed, 0x8e, 0x3f, 0xbe, 0x9f, 0x4f,
91 0x02, 0xf5, 0xb3, 0x09, 0x2f, 0xf3, 0x4c, 0x87, 0xdf, 0x2a, 0xcb, 0x95, 0x7c, 0x01, 0xcc, 0xac,
92 0x36, 0x7a, 0xbf, 0xa2, 0x73, 0x7a, 0xf7, 0x8f, 0xc1, 0xb5, 0x9a, 0xa1, 0x14, 0xb2, 0x8f, 0x33,
93 0x9f, 0x0d, 0xef, 0x22, 0xdc, 0x66, 0x7b, 0x84, 0xbd, 0x45, 0x17, 0x06, 0x3d, 0x3c, 0xca, 0xb9,
94 0x77, 0x34, 0x8f, 0xca, 0xea, 0xcf, 0x3f, 0x31, 0x3e, 0xe3, 0x88, 0xe3, 0x80, 0x49, 0x25, 0xc8,
95 0x97, 0xb5, 0x9d, 0x9a, 0x99, 0x4d, 0xb0, 0x3c, 0xf8, 0x4a, 0x00, 0x9b, 0x64, 0xdd, 0x9f, 0x39,
96 0x4b, 0xd1, 0x27, 0xd7, 0xb8
97 };
98
99 static const uint8_t g_certData02[] = { /* 985c1f52.0 */
100 0x30, 0x82, 0x05, 0x83, 0x30, 0x82, 0x03, 0x6b, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x0e, 0x45,
101 0xe6, 0xbb, 0x03, 0x83, 0x33, 0xc3, 0x85, 0x65, 0x48, 0xe6, 0xff, 0x45, 0x51, 0x30, 0x0d, 0x06,
102 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0c, 0x05, 0x00, 0x30, 0x4c, 0x31, 0x20,
103 0x30, 0x1e, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x17, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53,
104 0x69, 0x67, 0x6e, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x20, 0x2d, 0x20, 0x52, 0x36,
105 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0a, 0x47, 0x6c, 0x6f, 0x62, 0x61,
106 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a,
107 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x34,
108 0x31, 0x32, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x33, 0x34, 0x31,
109 0x32, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x4c, 0x31, 0x20, 0x30, 0x1e,
110 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x17, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69, 0x67,
111 0x6e, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x20, 0x2d, 0x20, 0x52, 0x36, 0x31, 0x13,
112 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0a, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53,
113 0x69, 0x67, 0x6e, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x47, 0x6c,
114 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, 0x09,
115 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00,
116 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, 0x01, 0x00, 0x95, 0x07, 0xe8, 0x73, 0xca, 0x66, 0xf9,
117 0xec, 0x14, 0xca, 0x7b, 0x3c, 0xf7, 0x0d, 0x08, 0xf1, 0xb4, 0x45, 0x0b, 0x2c, 0x82, 0xb4, 0x48,
118 0xc6, 0xeb, 0x5b, 0x3c, 0xae, 0x83, 0xb8, 0x41, 0x92, 0x33, 0x14, 0xa4, 0x6f, 0x7f, 0xe9, 0x2a,
119 0xcc, 0xc6, 0xb0, 0x88, 0x6b, 0xc5, 0xb6, 0x89, 0xd1, 0xc6, 0xb2, 0xff, 0x14, 0xce, 0x51, 0x14,
120 0x21, 0xec, 0x4a, 0xdd, 0x1b, 0x5a, 0xc6, 0xd6, 0x87, 0xee, 0x4d, 0x3a, 0x15, 0x06, 0xed, 0x64,
121 0x66, 0x0b, 0x92, 0x80, 0xca, 0x44, 0xde, 0x73, 0x94, 0x4e, 0xf3, 0xa7, 0x89, 0x7f, 0x4f, 0x78,
122 0x63, 0x08, 0xc8, 0x12, 0x50, 0x6d, 0x42, 0x66, 0x2f, 0x4d, 0xb9, 0x79, 0x28, 0x4d, 0x52, 0x1a,
123 0x8a, 0x1a, 0x80, 0xb7, 0x19, 0x81, 0x0e, 0x7e, 0xc4, 0x8a, 0xbc, 0x64, 0x4c, 0x21, 0x1c, 0x43,
124 0x68, 0xd7, 0x3d, 0x3c, 0x8a, 0xc5, 0xb2, 0x66, 0xd5, 0x90, 0x9a, 0xb7, 0x31, 0x06, 0xc5, 0xbe,
125 0xe2, 0x6d, 0x32, 0x06, 0xa6, 0x1e, 0xf9, 0xb9, 0xeb, 0xaa, 0xa3, 0xb8, 0xbf, 0xbe, 0x82, 0x63,
126 0x50, 0xd0, 0xf0, 0x18, 0x89, 0xdf, 0xe4, 0x0f, 0x79, 0xf5, 0xea, 0xa2, 0x1f, 0x2a, 0xd2, 0x70,
127 0x2e, 0x7b, 0xe7, 0xbc, 0x93, 0xbb, 0x6d, 0x53, 0xe2, 0x48, 0x7c, 0x8c, 0x10, 0x07, 0x38, 0xff,
128 0x66, 0xb2, 0x77, 0x61, 0x7e, 0xe0, 0xea, 0x8c, 0x3c, 0xaa, 0xb4, 0xa4, 0xf6, 0xf3, 0x95, 0x4a,
129 0x12, 0x07, 0x6d, 0xfd, 0x8c, 0xb2, 0x89, 0xcf, 0xd0, 0xa0, 0x61, 0x77, 0xc8, 0x58, 0x74, 0xb0,
130 0xd4, 0x23, 0x3a, 0xf7, 0x5d, 0x3a, 0xca, 0xa2, 0xdb, 0x9d, 0x09, 0xde, 0x5d, 0x44, 0x2d, 0x90,
131 0xf1, 0x81, 0xcd, 0x57, 0x92, 0xfa, 0x7e, 0xbc, 0x50, 0x04, 0x63, 0x34, 0xdf, 0x6b, 0x93, 0x18,
132 0xbe, 0x6b, 0x36, 0xb2, 0x39, 0xe4, 0xac, 0x24, 0x36, 0xb7, 0xf0, 0xef, 0xb6, 0x1c, 0x13, 0x57,
133 0x93, 0xb6, 0xde, 0xb2, 0xf8, 0xe2, 0x85, 0xb7, 0x73, 0xa2, 0xb8, 0x35, 0xaa, 0x45, 0xf2, 0xe0,
134 0x9d, 0x36, 0xa1, 0x6f, 0x54, 0x8a, 0xf1, 0x72, 0x56, 0x6e, 0x2e, 0x88, 0xc5, 0x51, 0x42, 0x44,
135 0x15, 0x94, 0xee, 0xa3, 0xc5, 0x38, 0x96, 0x9b, 0x4e, 0x4e, 0x5a, 0x0b, 0x47, 0xf3, 0x06, 0x36,
136 0x49, 0x77, 0x30, 0xbc, 0x71, 0x37, 0xe5, 0xa6, 0xec, 0x21, 0x08, 0x75, 0xfc, 0xe6, 0x61, 0x16,
137 0x3f, 0x77, 0xd5, 0xd9, 0x91, 0x97, 0x84, 0x0a, 0x6c, 0xd4, 0x02, 0x4d, 0x74, 0xc0, 0x14, 0xed,
138 0xfd, 0x39, 0xfb, 0x83, 0xf2, 0x5e, 0x14, 0xa1, 0x04, 0xb0, 0x0b, 0xe9, 0xfe, 0xee, 0x8f, 0xe1,
139 0x6e, 0x0b, 0xb2, 0x08, 0xb3, 0x61, 0x66, 0x09, 0x6a, 0xb1, 0x06, 0x3a, 0x65, 0x96, 0x59, 0xc0,
140 0xf0, 0x35, 0xfd, 0xc9, 0xda, 0x28, 0x8d, 0x1a, 0x11, 0x87, 0x70, 0x81, 0x0a, 0xa8, 0x9a, 0x75,
141 0x1d, 0x9e, 0x3a, 0x86, 0x05, 0x00, 0x9e, 0xdb, 0x80, 0xd6, 0x25, 0xf9, 0xdc, 0x05, 0x9e, 0x27,
142 0x59, 0x4c, 0x76, 0x39, 0x5b, 0xea, 0xf9, 0xa5, 0xa1, 0xd8, 0x83, 0x0f, 0xd1, 0xff, 0xdf, 0x30,
143 0x11, 0xf9, 0x85, 0xcf, 0x33, 0x48, 0xf5, 0xca, 0x6d, 0x64, 0x14, 0x2c, 0x7a, 0x58, 0x4f, 0xd3,
144 0x4b, 0x08, 0x49, 0xc5, 0x95, 0x64, 0x1a, 0x63, 0x0e, 0x79, 0x3d, 0xf5, 0xb3, 0x8c, 0xca, 0x58,
145 0xad, 0x9c, 0x42, 0x45, 0x79, 0x6e, 0x0e, 0x87, 0x19, 0x5c, 0x54, 0xb1, 0x65, 0xb6, 0xbf, 0x8c,
146 0x9b, 0xdc, 0x13, 0xe9, 0x0d, 0x6f, 0xb8, 0x2e, 0xdc, 0x67, 0x6e, 0xc9, 0x8b, 0x11, 0xb5, 0x84,
147 0x14, 0x8a, 0x00, 0x19, 0x70, 0x83, 0x79, 0x91, 0x97, 0x91, 0xd4, 0x1a, 0x27, 0xbf, 0x37, 0x1e,
148 0x32, 0x07, 0xd8, 0x14, 0x63, 0x3c, 0x28, 0x4c, 0xaf, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x63,
149 0x30, 0x61, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02,
150 0x01, 0x06, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03,
151 0x01, 0x01, 0xff, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xae, 0x6c,
152 0x05, 0xa3, 0x93, 0x13, 0xe2, 0xa2, 0xe7, 0xe2, 0xd7, 0x1c, 0xd6, 0xc7, 0xf0, 0x7f, 0xc8, 0x67,
153 0x53, 0xa0, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xae,
154 0x6c, 0x05, 0xa3, 0x93, 0x13, 0xe2, 0xa2, 0xe7, 0xe2, 0xd7, 0x1c, 0xd6, 0xc7, 0xf0, 0x7f, 0xc8,
155 0x67, 0x53, 0xa0, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0c,
156 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x83, 0x25, 0xed, 0xe8, 0xd1, 0xfd, 0x95, 0x52, 0xcd,
157 0x9e, 0xc0, 0x04, 0xa0, 0x91, 0x69, 0xe6, 0x5c, 0xd0, 0x84, 0xde, 0xdc, 0xad, 0xa2, 0x4f, 0xe8,
158 0x47, 0x78, 0xd6, 0x65, 0x98, 0xa9, 0x5b, 0xa8, 0x3c, 0x87, 0x7c, 0x02, 0x8a, 0xd1, 0x6e, 0xb7,
159 0x16, 0x73, 0xe6, 0x5f, 0xc0, 0x54, 0x98, 0xd5, 0x74, 0xbe, 0xc1, 0xcd, 0xe2, 0x11, 0x91, 0xad,
160 0x23, 0x18, 0x3d, 0xdd, 0xe1, 0x72, 0x44, 0x96, 0xb4, 0x95, 0x5e, 0xc0, 0x7b, 0x8e, 0x99, 0x78,
161 0x16, 0x43, 0x13, 0x56, 0x57, 0xb3, 0xa2, 0xb3, 0x3b, 0xb5, 0x77, 0xdc, 0x40, 0x72, 0xac, 0xa3,
162 0xeb, 0x9b, 0x35, 0x3e, 0xb1, 0x08, 0x21, 0xa1, 0xe7, 0xc4, 0x43, 0x37, 0x79, 0x32, 0xbe, 0xb5,
163 0xe7, 0x9c, 0x2c, 0x4c, 0xbc, 0x43, 0x29, 0x99, 0x8e, 0x30, 0xd3, 0xac, 0x21, 0xe0, 0xe3, 0x1d,
164 0xfa, 0xd8, 0x07, 0x33, 0x76, 0x54, 0x00, 0x22, 0x2a, 0xb9, 0x4d, 0x20, 0x2e, 0x70, 0x68, 0xda,
165 0xe5, 0x53, 0xfc, 0x83, 0x5c, 0xd3, 0x9d, 0xf2, 0xff, 0x44, 0x0c, 0x44, 0x66, 0xf2, 0xd2, 0xe3,
166 0xbd, 0x46, 0x00, 0x1a, 0x6d, 0x02, 0xba, 0x25, 0x5d, 0x8d, 0xa1, 0x31, 0x51, 0xdd, 0x54, 0x46,
167 0x1c, 0x4d, 0xdb, 0x99, 0x96, 0xef, 0x1a, 0x1c, 0x04, 0x5c, 0xa6, 0x15, 0xef, 0x78, 0xe0, 0x79,
168 0xfe, 0x5d, 0xdb, 0x3e, 0xaa, 0x4c, 0x55, 0xfd, 0x9a, 0x15, 0xa9, 0x6f, 0xe1, 0xa6, 0xfb, 0xdf,
169 0x70, 0x30, 0xe9, 0xc3, 0xee, 0x42, 0x46, 0xed, 0xc2, 0x93, 0x05, 0x89, 0xfa, 0x7d, 0x63, 0x7b,
170 0x3f, 0xd0, 0x71, 0x81, 0x7c, 0x00, 0xe8, 0x98, 0xae, 0x0e, 0x78, 0x34, 0xc3, 0x25, 0xfb, 0xaf,
171 0x0a, 0x9f, 0x20, 0x6b, 0xdd, 0x3b, 0x13, 0x8f, 0x12, 0x8c, 0xe2, 0x41, 0x1a, 0x48, 0x7a, 0x73,
172 0xa0, 0x77, 0x69, 0xc7, 0xb6, 0x5c, 0x7f, 0x82, 0xc8, 0x1e, 0xfe, 0x58, 0x1b, 0x28, 0x2b, 0xa8,
173 0x6c, 0xad, 0x5e, 0x6d, 0xc0, 0x05, 0xd2, 0x7b, 0xb7, 0xeb, 0x80, 0xfe, 0x25, 0x37, 0xfe, 0x02,
174 0x9b, 0x68, 0xac, 0x42, 0x5d, 0xc3, 0xee, 0xf5, 0xcc, 0xdc, 0xf0, 0x50, 0x75, 0xd2, 0x36, 0x69,
175 0x9c, 0xe6, 0x7b, 0x04, 0xdf, 0x6e, 0x06, 0x69, 0xb6, 0xde, 0x0a, 0x09, 0x48, 0x59, 0x87, 0xeb,
176 0x7b, 0x14, 0x60, 0x7a, 0x64, 0xaa, 0x69, 0x43, 0xef, 0x91, 0xc7, 0x4c, 0xec, 0x18, 0xdd, 0x6c,
177 0xef, 0x53, 0x2d, 0x8c, 0x99, 0xe1, 0x5e, 0xf2, 0x72, 0x3e, 0xcf, 0x54, 0xc8, 0xbd, 0x67, 0xec,
178 0xa4, 0x0f, 0x4c, 0x45, 0xff, 0xd3, 0xb9, 0x30, 0x23, 0x07, 0x4c, 0x8f, 0x10, 0xbf, 0x86, 0x96,
179 0xd9, 0x99, 0x5a, 0xb4, 0x99, 0x57, 0x1c, 0xa4, 0xcc, 0xbb, 0x15, 0x89, 0x53, 0xba, 0x2c, 0x05,
180 0x0f, 0xe4, 0xc4, 0x9e, 0x19, 0xb1, 0x18, 0x34, 0xd5, 0x4c, 0x9d, 0xba, 0xed, 0xf7, 0x1f, 0xaf,
181 0x24, 0x95, 0x04, 0x78, 0xa8, 0x03, 0xbb, 0xee, 0x81, 0xe5, 0xda, 0x5f, 0x7c, 0x8b, 0x4a, 0xa1,
182 0x90, 0x74, 0x25, 0xa7, 0xb3, 0x3e, 0x4b, 0xc8, 0x2c, 0x56, 0xbd, 0xc7, 0xc8, 0xef, 0x38, 0xe2,
183 0x5c, 0x92, 0xf0, 0x79, 0xf7, 0x9c, 0x84, 0xba, 0x74, 0x2d, 0x61, 0x01, 0x20, 0x7e, 0x7e, 0xd1,
184 0xf2, 0x4f, 0x07, 0x59, 0x5f, 0x8b, 0x2d, 0x43, 0x52, 0xeb, 0x46, 0x0c, 0x94, 0xe1, 0xf5, 0x66,
185 0x47, 0x79, 0x77, 0xd5, 0x54, 0x5b, 0x1f, 0xad, 0x24, 0x37, 0xcb, 0x45, 0x5a, 0x4e, 0xa0, 0x44,
186 0x48, 0xc8, 0xd8, 0xb0, 0x99, 0xc5, 0x15, 0x84, 0x09, 0xf6, 0xd6, 0x49, 0x49, 0xc0, 0x65, 0xb8,
187 0xe6, 0x1a, 0x71, 0x6e, 0xa0, 0xa8, 0xf1, 0x82, 0xe8, 0x45, 0x3e, 0x6c, 0xd6, 0x02, 0xd7, 0x0a,
188 0x67, 0x83, 0x05, 0x5a, 0xc9, 0xa4, 0x10
189 };
190
191 static const uint8_t g_certData03[] = { /* 1df5a75f.0 */
192 0x30, 0x82, 0x04, 0x33, 0x30, 0x82, 0x03, 0x1b, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x03, 0x09,
193 0x83, 0xf3, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05,
194 0x00, 0x30, 0x4d, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x44, 0x45,
195 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0c, 0x44, 0x2d, 0x54, 0x72, 0x75,
196 0x73, 0x74, 0x20, 0x47, 0x6d, 0x62, 0x48, 0x31, 0x27, 0x30, 0x25, 0x06, 0x03, 0x55, 0x04, 0x03,
197 0x0c, 0x1e, 0x44, 0x2d, 0x54, 0x52, 0x55, 0x53, 0x54, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43,
198 0x6c, 0x61, 0x73, 0x73, 0x20, 0x33, 0x20, 0x43, 0x41, 0x20, 0x32, 0x20, 0x32, 0x30, 0x30, 0x39,
199 0x30, 0x1e, 0x17, 0x0d, 0x30, 0x39, 0x31, 0x31, 0x30, 0x35, 0x30, 0x38, 0x33, 0x35, 0x35, 0x38,
200 0x5a, 0x17, 0x0d, 0x32, 0x39, 0x31, 0x31, 0x30, 0x35, 0x30, 0x38, 0x33, 0x35, 0x35, 0x38, 0x5a,
201 0x30, 0x4d, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x44, 0x45, 0x31,
202 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0c, 0x44, 0x2d, 0x54, 0x72, 0x75, 0x73,
203 0x74, 0x20, 0x47, 0x6d, 0x62, 0x48, 0x31, 0x27, 0x30, 0x25, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
204 0x1e, 0x44, 0x2d, 0x54, 0x52, 0x55, 0x53, 0x54, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x6c,
205 0x61, 0x73, 0x73, 0x20, 0x33, 0x20, 0x43, 0x41, 0x20, 0x32, 0x20, 0x32, 0x30, 0x30, 0x39, 0x30,
206 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01,
207 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00,
208 0xd3, 0xb2, 0x4a, 0xcf, 0x7a, 0x47, 0xef, 0x75, 0x9b, 0x23, 0xfa, 0x3a, 0x2f, 0xd6, 0x50, 0x45,
209 0x89, 0x35, 0x3a, 0xc6, 0x6b, 0xdb, 0xfe, 0xdb, 0x00, 0x68, 0xa8, 0xe0, 0x03, 0x11, 0x1d, 0x37,
210 0x50, 0x08, 0x9f, 0x4d, 0x4a, 0x68, 0x94, 0x35, 0xb3, 0x53, 0xd1, 0x94, 0x63, 0xa7, 0x20, 0x56,
211 0xaf, 0xde, 0x51, 0x78, 0xec, 0x2a, 0x3d, 0xf3, 0x48, 0x48, 0x50, 0x3e, 0x0a, 0xdf, 0x46, 0x55,
212 0x8b, 0x27, 0x6d, 0xc3, 0x10, 0x4d, 0x0d, 0x91, 0x52, 0x43, 0xd8, 0x87, 0xe0, 0x5d, 0x4e, 0x36,
213 0xb5, 0x21, 0xca, 0x5f, 0x39, 0x40, 0x04, 0x5f, 0x5b, 0x7e, 0xcc, 0xa3, 0xc6, 0x2b, 0xa9, 0x40,
214 0x1e, 0xd9, 0x36, 0x84, 0xd6, 0x48, 0xf3, 0x92, 0x1e, 0x34, 0x46, 0x20, 0x24, 0xc1, 0xa4, 0x51,
215 0x8e, 0x4a, 0x1a, 0xef, 0x50, 0x3f, 0x69, 0x5d, 0x19, 0x7f, 0x45, 0xc3, 0xc7, 0x01, 0x8f, 0x51,
216 0xc9, 0x23, 0xe8, 0x72, 0xae, 0xb4, 0xbc, 0x56, 0x09, 0x7f, 0x12, 0xcb, 0x1c, 0xb1, 0xaf, 0x29,
217 0x90, 0x0a, 0xc9, 0x55, 0xcc, 0x0f, 0xd3, 0xb4, 0x1a, 0xed, 0x47, 0x35, 0x5a, 0x4a, 0xed, 0x9c,
218 0x73, 0x04, 0x21, 0xd0, 0xaa, 0xbd, 0x0c, 0x13, 0xb5, 0x00, 0xca, 0x26, 0x6c, 0xc4, 0x6b, 0x0c,
219 0x94, 0x5a, 0x95, 0x94, 0xda, 0x50, 0x9a, 0xf1, 0xff, 0xa5, 0x2b, 0x66, 0x31, 0xa4, 0xc9, 0x38,
220 0xa0, 0xdf, 0x1d, 0x1f, 0xb8, 0x09, 0x2e, 0xf3, 0xa7, 0xe8, 0x67, 0x52, 0xab, 0x95, 0x1f, 0xe0,
221 0x46, 0x3e, 0xd8, 0xa4, 0xc3, 0xca, 0x5a, 0xc5, 0x31, 0x80, 0xe8, 0x48, 0x9a, 0x9f, 0x94, 0x69,
222 0xfe, 0x19, 0xdd, 0xd8, 0x73, 0x7c, 0x81, 0xca, 0x96, 0xde, 0x8e, 0xed, 0xb3, 0x32, 0x05, 0x65,
223 0x84, 0x34, 0xe6, 0xe6, 0xfd, 0x57, 0x10, 0xb5, 0x5f, 0x76, 0xbf, 0x2f, 0xb0, 0x10, 0x0d, 0xc5,
224 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x01, 0x1a, 0x30, 0x82, 0x01, 0x16, 0x30, 0x0f, 0x06,
225 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1d,
226 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xfd, 0xda, 0x14, 0xc4, 0x9f, 0x30, 0xde,
227 0x21, 0xbd, 0x1e, 0x42, 0x39, 0xfc, 0xab, 0x63, 0x23, 0x49, 0xe0, 0xf1, 0x84, 0x30, 0x0e, 0x06,
228 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x81, 0xd3,
229 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04, 0x81, 0xcb, 0x30, 0x81, 0xc8, 0x30, 0x81, 0x80, 0xa0, 0x7e,
230 0xa0, 0x7c, 0x86, 0x7a, 0x6c, 0x64, 0x61, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x69, 0x72, 0x65, 0x63,
231 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x64, 0x2d, 0x74, 0x72, 0x75, 0x73, 0x74, 0x2e, 0x6e, 0x65, 0x74,
232 0x2f, 0x43, 0x4e, 0x3d, 0x44, 0x2d, 0x54, 0x52, 0x55, 0x53, 0x54, 0x25, 0x32, 0x30, 0x52, 0x6f,
233 0x6f, 0x74, 0x25, 0x32, 0x30, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x25, 0x32, 0x30, 0x33, 0x25, 0x32,
234 0x30, 0x43, 0x41, 0x25, 0x32, 0x30, 0x32, 0x25, 0x32, 0x30, 0x32, 0x30, 0x30, 0x39, 0x2c, 0x4f,
235 0x3d, 0x44, 0x2d, 0x54, 0x72, 0x75, 0x73, 0x74, 0x25, 0x32, 0x30, 0x47, 0x6d, 0x62, 0x48, 0x2c,
236 0x43, 0x3d, 0x44, 0x45, 0x3f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65,
237 0x72, 0x65, 0x76, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x43,
238 0xa0, 0x41, 0xa0, 0x3f, 0x86, 0x3d, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
239 0x2e, 0x64, 0x2d, 0x74, 0x72, 0x75, 0x73, 0x74, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x72, 0x6c,
240 0x2f, 0x64, 0x2d, 0x74, 0x72, 0x75, 0x73, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x63, 0x6c,
241 0x61, 0x73, 0x73, 0x5f, 0x33, 0x5f, 0x63, 0x61, 0x5f, 0x32, 0x5f, 0x32, 0x30, 0x30, 0x39, 0x2e,
242 0x63, 0x72, 0x6c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
243 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x7f, 0x97, 0xdb, 0x30, 0xc8, 0xdf, 0xa4, 0x9c, 0x7d,
244 0x21, 0x7a, 0x80, 0x70, 0xce, 0x14, 0x12, 0x69, 0x88, 0x14, 0x95, 0x60, 0x44, 0x01, 0xac, 0xb2,
245 0xe9, 0x30, 0x4f, 0x9b, 0x50, 0xc2, 0x66, 0xd8, 0x7e, 0x8d, 0x30, 0xb5, 0x70, 0x31, 0xe9, 0xe2,
246 0x69, 0xc7, 0xf3, 0x70, 0xdb, 0x20, 0x15, 0x86, 0xd0, 0x0d, 0xf0, 0xbe, 0xac, 0x01, 0x75, 0x84,
247 0xce, 0x7e, 0x9f, 0x4d, 0xbf, 0xb7, 0x60, 0x3b, 0x9c, 0xf3, 0xca, 0x1d, 0xe2, 0x5e, 0x68, 0xd8,
248 0xa3, 0x9d, 0x97, 0xe5, 0x40, 0x60, 0xd2, 0x36, 0x21, 0xfe, 0xd0, 0xb4, 0xb8, 0x17, 0xda, 0x74,
249 0xa3, 0x7f, 0xd4, 0xdf, 0xb0, 0x98, 0x02, 0xac, 0x6f, 0x6b, 0x6b, 0x2c, 0x25, 0x24, 0x72, 0xa1,
250 0x65, 0xee, 0x25, 0x5a, 0xe5, 0xe6, 0x32, 0xe7, 0xf2, 0xdf, 0xab, 0x49, 0xfa, 0xf3, 0x90, 0x69,
251 0x23, 0xdb, 0x04, 0xd9, 0xe7, 0x5c, 0x58, 0xfc, 0x65, 0xd4, 0x97, 0xbe, 0xcc, 0xfc, 0x2e, 0x0a,
252 0xcc, 0x25, 0x2a, 0x35, 0x04, 0xf8, 0x60, 0x91, 0x15, 0x75, 0x3d, 0x41, 0xff, 0x23, 0x1f, 0x19,
253 0xc8, 0x6c, 0xeb, 0x82, 0x53, 0x04, 0xa6, 0xe4, 0x4c, 0x22, 0x4d, 0x8d, 0x8c, 0xba, 0xce, 0x5b,
254 0x73, 0xec, 0x64, 0x54, 0x50, 0x6d, 0xd1, 0x9c, 0x55, 0xfb, 0x69, 0xc3, 0x36, 0xc3, 0x8c, 0xbc,
255 0x3c, 0x85, 0xa6, 0x6b, 0x0a, 0x26, 0x0d, 0xe0, 0x93, 0x98, 0x60, 0xae, 0x7e, 0xc6, 0x24, 0x97,
256 0x8a, 0x61, 0x5f, 0x91, 0x8e, 0x66, 0x92, 0x09, 0x87, 0x36, 0xcd, 0x8b, 0x9b, 0x2d, 0x3e, 0xf6,
257 0x51, 0xd4, 0x50, 0xd4, 0x59, 0x28, 0xbd, 0x83, 0xf2, 0xcc, 0x28, 0x7b, 0x53, 0x86, 0x6d, 0xd8,
258 0x26, 0x88, 0x70, 0xd7, 0xea, 0x91, 0xcd, 0x3e, 0xb9, 0xca, 0xc0, 0x90, 0x6e, 0x5a, 0xc6, 0x5e,
259 0x74, 0x65, 0xd7, 0x5c, 0xfe, 0xa3, 0xe2
260 };
261
262 static const uint8_t g_certData04[] = { /* invalid data */
263 0xa0, 0x41, 0xa0, 0x3f, 0x86, 0x3d, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
264 0x2e, 0x64, 0x2d, 0x74, 0x72, 0x75, 0x73, 0x74, 0x2e, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x72, 0x6c,
265 0x2f, 0x64, 0x2d, 0x74, 0x72, 0x75, 0x73, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x63, 0x6c,
266 0x61, 0x73, 0x73, 0x5f, 0x33, 0x5f, 0x63, 0x61, 0x5f, 0x32, 0x5f, 0x32, 0x30, 0x30, 0x39, 0x2e,
267 0x63, 0x72, 0x6c, 0x30, 0x0d, 0x06, 0x09, 0x2a
268 };
269
270 static const uint8_t g_certData05[] = { /* 2e0g9ue5 */
271 0x30, 0x82, 0x02, 0xc1, 0x30, 0x82, 0x01, 0xa9, 0x02, 0x01, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a,
272 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x1a, 0x31, 0x18, 0x30, 0x16,
273 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x52,
274 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x32, 0x31, 0x32, 0x31, 0x36,
275 0x31, 0x30, 0x33, 0x38, 0x31, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x35, 0x30, 0x39, 0x31, 0x30, 0x31,
276 0x30, 0x33, 0x38, 0x31, 0x39, 0x5a, 0x30, 0x33, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04,
277 0x03, 0x0c, 0x06, 0x54, 0x45, 0x53, 0x54, 0x30, 0x31, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55,
278 0x04, 0x0b, 0x0c, 0x06, 0x54, 0x45, 0x53, 0x54, 0x30, 0x32, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03,
279 0x55, 0x04, 0x0a, 0x0c, 0x06, 0x54, 0x45, 0x53, 0x54, 0x30, 0x33, 0x30, 0x82, 0x01, 0x22, 0x30,
280 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82,
281 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xa3, 0x21, 0x49, 0xd7,
282 0x60, 0xb9, 0x49, 0xe3, 0x40, 0x4e, 0x02, 0x92, 0x07, 0xa6, 0xfb, 0x4a, 0xef, 0x4d, 0xfa, 0x0b,
283 0xcc, 0xab, 0x5b, 0x7b, 0x1b, 0x86, 0x4f, 0x99, 0x77, 0xb3, 0x52, 0xd8, 0x79, 0x04, 0x1e, 0x80,
284 0xff, 0xed, 0xb8, 0xfd, 0x51, 0xfe, 0xdd, 0xed, 0xe3, 0xdd, 0x85, 0x76, 0xb0, 0xe4, 0x0a, 0xd7,
285 0xbf, 0x9a, 0x08, 0x33, 0xa5, 0x24, 0x37, 0xb1, 0xe6, 0x18, 0x9e, 0x32, 0xb6, 0x49, 0x4c, 0xcf,
286 0x8c, 0x94, 0x75, 0xd3, 0xf9, 0x44, 0xe2, 0xb5, 0xa4, 0xe2, 0x86, 0x6d, 0x0c, 0xef, 0x89, 0xf2,
287 0x71, 0x06, 0x8a, 0x3a, 0x08, 0xaf, 0x11, 0x46, 0x08, 0xc5, 0xa6, 0x45, 0x37, 0x2f, 0x69, 0x1a,
288 0xc6, 0x2d, 0x56, 0xa3, 0x4b, 0x72, 0x98, 0x1f, 0x66, 0x58, 0x66, 0x29, 0x69, 0x1e, 0xb6, 0xdc,
289 0xe0, 0x50, 0x95, 0xd2, 0x5b, 0xa4, 0xf1, 0x3d, 0xc6, 0xac, 0x82, 0x05, 0x52, 0x3e, 0xef, 0x61,
290 0x5d, 0xa1, 0x8d, 0x17, 0x6b, 0x8d, 0xff, 0x1f, 0x7f, 0xe7, 0xa9, 0x07, 0x2a, 0x6f, 0x3f, 0xca,
291 0xaa, 0xfa, 0x4b, 0x4f, 0x0d, 0x2f, 0xf7, 0xa8, 0xae, 0x42, 0x6d, 0x8c, 0x83, 0xb0, 0x2b, 0x42,
292 0xec, 0x7d, 0x93, 0xd9, 0xb1, 0xbd, 0xbd, 0xa6, 0x59, 0x49, 0xe2, 0x70, 0xe4, 0x5b, 0x45, 0xa9,
293 0xdf, 0x9d, 0xbd, 0x11, 0xe1, 0xbc, 0xd9, 0x7e, 0x91, 0xc6, 0x4f, 0x40, 0xd7, 0xfb, 0x33, 0x51,
294 0xc0, 0x9b, 0x4f, 0x94, 0x53, 0xd7, 0x89, 0x26, 0x69, 0x4e, 0x58, 0x79, 0xcd, 0x68, 0x76, 0x64,
295 0xbe, 0x25, 0xee, 0xce, 0xde, 0x2b, 0xaf, 0x05, 0x93, 0x57, 0xb6, 0x6f, 0x67, 0x09, 0x26, 0x13,
296 0xb9, 0x5a, 0xbc, 0x6a, 0xc8, 0x4e, 0x37, 0xf1, 0x2c, 0xf9, 0x2d, 0x03, 0x62, 0x35, 0x83, 0x67,
297 0x5b, 0x56, 0xe4, 0xb2, 0xb5, 0x7e, 0x9e, 0x2a, 0x2a, 0x9e, 0xef, 0x21, 0x02, 0x03, 0x01, 0x00,
298 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00,
299 0x03, 0x82, 0x01, 0x01, 0x00, 0x8f, 0x54, 0xb6, 0x5a, 0x0b, 0x49, 0x1d, 0x9c, 0x3b, 0x26, 0xc9,
300 0x33, 0x47, 0x83, 0xd2, 0x56, 0x5f, 0xa2, 0x2e, 0x2f, 0x49, 0x40, 0x49, 0x08, 0xf3, 0x9b, 0xfd,
301 0x4d, 0x7b, 0x00, 0xdb, 0xb5, 0xec, 0xe0, 0x48, 0xc6, 0x2d, 0xcc, 0x7d, 0x98, 0xa0, 0x99, 0x6d,
302 0x35, 0xf2, 0xcc, 0x92, 0x84, 0xbc, 0xa6, 0xa6, 0x01, 0x8f, 0x29, 0x8d, 0xa4, 0x43, 0x8b, 0x1c,
303 0xd6, 0x6e, 0x44, 0x25, 0x46, 0x44, 0xe0, 0xa0, 0x91, 0xdc, 0x80, 0xa4, 0xbb, 0x01, 0x04, 0xba,
304 0x69, 0x00, 0xd9, 0xbd, 0x88, 0xa0, 0x3e, 0x7d, 0xe2, 0xca, 0x88, 0x0e, 0x99, 0x08, 0x5d, 0xd9,
305 0x4f, 0x6a, 0x22, 0xbf, 0x8d, 0xeb, 0xd5, 0xfa, 0xe0, 0x7f, 0xbd, 0x5e, 0x34, 0x0b, 0xd3, 0xec,
306 0x0b, 0x0c, 0x83, 0x93, 0xde, 0xd8, 0xf6, 0x4f, 0x7c, 0x66, 0x23, 0x6d, 0xb9, 0x4a, 0xd4, 0xd3,
307 0xd5, 0x16, 0x99, 0x65, 0x69, 0x7f, 0xd6, 0x29, 0x67, 0x63, 0xd5, 0xcc, 0xfd, 0xe7, 0x1c, 0x7a,
308 0x96, 0x68, 0x16, 0x1f, 0xc9, 0x24, 0xd6, 0xaf, 0x9f, 0xd0, 0xd3, 0x5d, 0xc6, 0x70, 0xcf, 0x5d,
309 0x10, 0x47, 0x59, 0x0c, 0x16, 0xae, 0x19, 0x89, 0x35, 0x7b, 0xe4, 0x42, 0xb7, 0x62, 0x67, 0x2d,
310 0xcc, 0xcd, 0x8d, 0x52, 0x4d, 0xa3, 0xf3, 0x4f, 0x44, 0x47, 0xcf, 0xf3, 0x57, 0x96, 0xab, 0xef,
311 0xd5, 0xe8, 0x8c, 0xf6, 0xca, 0xed, 0x4b, 0x40, 0xae, 0xad, 0x6a, 0x03, 0xb5, 0x7a, 0xb6, 0xc8,
312 0x59, 0x7d, 0x32, 0x2f, 0x52, 0x6a, 0x29, 0x01, 0x51, 0xd1, 0x81, 0xe0, 0x8b, 0xb5, 0x1c, 0xaa,
313 0x09, 0xdb, 0x1c, 0x86, 0xbc, 0xd6, 0x95, 0x7c, 0x18, 0x1e, 0x53, 0x8d, 0x63, 0xf1, 0xc0, 0xae,
314 0x86, 0x91, 0x12, 0x67, 0xe0, 0x93, 0x78, 0xbf, 0x1a, 0x63, 0x27, 0x0a, 0x14, 0x29, 0x8d, 0x5f,
315 0x59, 0xae, 0x6b, 0x04, 0x1b
316 };
317
318 struct UserCertListResult {
319 struct CertAbstract certAbstract;
320 bool bExpectResult;
321 };
322
323 struct UserCertListResult g_certListExpectResult[] = {
324 {
325 {
326 "oh:t=c;o=40dc992e;u=0;a=0",
327 "40dc992e",
328 true,
329 "CN=Hellenic Academic and Research Institutions RootCA 2011,OU=,"
330 "O=Hellenic Academic and Research Institutions Cert. Authority"
331 },
332 true
333 },
334 {
335 {
336 "oh:t=c;o=985c1f52;u=0;a=0",
337 "985c1f52",
338 true,
339 "CN=GlobalSign,OU=GlobalSign Root CA - R6,O=GlobalSign"
340 },
341 true
342 },
343 {
344 {
345 "oh:t=c;o=1df5a75f;u=0;a=0",
346 "1df5a75f",
347 true,
348 "CN=D-TRUST Root Class 3 CA 2 2009,OU=,O=D-Trust GmbH"
349 },
350 true
351 },
352 {
353 {
354 "oh:t=c;o=2e0g9ue5;u=0;a=0",
355 "2e0g9ue5",
356 true,
357 "CN=TEST01,OU=TEST02,O=TEST03"
358 },
359 true
360 }
361 };
362
363 struct UserCertInfoResult {
364 struct CertInfo certInfo;
365 bool bExpectResult;
366 };
367
368 struct UserCertInfoResult g_certInfoExpectResult[] = {
369 {
370 {
371 "oh:t=c;o=40dc992e;u=0;a=0",
372 "40dc992e",
373 true,
374 "CN=Hellenic Academic and Research Institutions RootCA 2011,OU=,"
375 "O=Hellenic Academic and Research Institutions Cert. Authority",
376 "CN=Hellenic Academic and Research Institutions RootCA 2011,OU=,"
377 "O=Hellenic Academic and Research Institutions Cert. Authority",
378 "0",
379 "2011-12-6",
380 "2031-12-1",
381 "BC:10:4F:15:A4:8B:E7:09:DC:A5:42:A7:E1:D4:B9:DF:6F:05:45:27:E8:02:EA:A9:2D:59:54:44:25:8A:FE:71",
382 { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) }
383 },
384 true
385 },
386 {
387 {
388 "oh:t=c;o=985c1f52;u=0;a=0",
389 "985c1f52",
390 true,
391 "CN=GlobalSign,OU=GlobalSign Root CA - R6,O=GlobalSign",
392 "CN=GlobalSign,OU=GlobalSign Root CA - R6,O=GlobalSign",
393 "45E6BB038333C3856548E6FF4551",
394 "2014-12-10",
395 "2034-12-10",
396 "2C:AB:EA:FE:37:D0:6C:A2:2A:BA:73:91:C0:03:3D:25:98:29:52:C4:53:64:73:49:76:3A:3A:B5:AD:6C:CF:69",
397 { sizeof(g_certData02), const_cast<uint8_t *>(g_certData02) }
398 },
399 true
400 },
401 {
402 {
403 "oh:t=c;o=1df5a75f;u=0;a=0",
404 "1df5a75f",
405 true,
406 "CN=D-TRUST Root Class 3 CA 2 2009,OU=,O=D-Trust GmbH",
407 "CN=D-TRUST Root Class 3 CA 2 2009,OU=,O=D-Trust GmbH",
408 "0983F3",
409 "2009-11-5",
410 "2029-11-5",
411 "49:E7:A4:42:AC:F0:EA:62:87:05:00:54:B5:25:64:B6:50:E4:F4:9E:42:E3:48:D6:AA:38:E0:39:E9:57:B1:C1",
412 { sizeof(g_certData03), const_cast<uint8_t *>(g_certData03) }
413 },
414 true
415 },
416 {
417 {
418 "oh:t=c;o=2e0g9ue5;u=0;a=0",
419 "2e0g9ue5",
420 true,
421 "CN=Example Root CA,OU=,O=",
422 "CN=TEST01,OU=TEST02,O=TEST03",
423 "01",
424 "2022-12-16",
425 "2025-9-10",
426 "60:57:A8:41:CD:4E:45:F6:7F:93:21:C4:E9:A0:F9:5F:45:CB:D5:39:02:43:A9:AF:4F:0A:04:D0:2C:41:99:68",
427 { sizeof(g_certData05), const_cast<uint8_t *>(g_certData05) }
428 },
429 true
430 }
431 };
432
433 struct UserCertStatusExpectResult {
434 char uri[MAX_URI_LEN];
435 bool inparamStatus;
436 bool expectStatus;
437 };
438
439 struct UserCertStatusExpectResult g_certStatusExpectResult[] = {
440 {
441 {"oh:t=c;o=40dc992e;u=0;a=0"}, false, false
442 },
443 {
444 {"oh:t=c;o=985c1f52;u=0;a=0"}, false, false
445 },
446 {
447 {"oh:t=c;o=1df5a75f;u=0;a=0"}, true, true
448 },
449 {
450 {"oh:t=c;o=2e0g9ue5;u=0;a=0"}, true, true
451 }
452 };
453
454 struct CmBlob userCert[] = {
455 { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) },
456 { sizeof(g_certData02), const_cast<uint8_t *>(g_certData02) },
457 { sizeof(g_certData03), const_cast<uint8_t *>(g_certData03) },
458 { sizeof(g_certData05), const_cast<uint8_t *>(g_certData05) }
459 };
460
461 static uint8_t certAliasBuf01[] = "40dc992e";
462 static uint8_t certAliasBuf02[] = "985c1f52";
463 static uint8_t certAliasBuf03[] = "1df5a75f";
464 static uint8_t certAliasBuf05[] = "2e0g9ue5";
465
466 struct CmBlob certAlias[] = {
467 { sizeof(certAliasBuf01), certAliasBuf01 },
468 { sizeof(certAliasBuf02), certAliasBuf02 },
469 { sizeof(certAliasBuf03), certAliasBuf03 },
470 { sizeof(certAliasBuf05), certAliasBuf05 }
471 };
472
473 class CmUserCertTest : public testing::Test {
474 public:
475 static void SetUpTestCase(void);
476
477 static void TearDownTestCase(void);
478
479 void SetUp();
480
481 void TearDown();
482 };
483
SetUpTestCase(void)484 void CmUserCertTest::SetUpTestCase(void)
485 {
486 SetATPermission();
487 }
488
TearDownTestCase(void)489 void CmUserCertTest::TearDownTestCase(void)
490 {
491 }
492
SetUp()493 void CmUserCertTest::SetUp()
494 {
495 }
496
TearDown()497 void CmUserCertTest::TearDown()
498 {
499 }
500
501 /**
502 * @tc.name: InstallUserCertTest001
503 * @tc.desc: Test CertManager Install user cert interface base function
504 * @tc.type: FUNC
505 * @tc.require: AR000H0MJ8 /SR000H09N7
506 */
507 HWTEST_F(CmUserCertTest, InstallUserCertTest001, TestSize.Level0)
508 {
509 int32_t ret;
510 uint8_t uriBuf001[MAX_URI_LEN] = {0};
511 struct CmBlob certUri = { sizeof(uriBuf001), uriBuf001 };
512
513 ret = CmInstallUserTrustedCert(&userCert[0], &certAlias[0], &certUri);
514 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
515
516 ret = CmUninstallUserTrustedCert(&certUri);
517 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
518 }
519
520 /**
521 * @tc.name: InstallUserCertTest002
522 * @tc.desc: Test CertManager Install cert interface base function
523 * @tc.type: FUNC
524 * @tc.require: AR000H0MJ8 /SR000H09N7
525 */
526 HWTEST_F(CmUserCertTest, InstallUserCertTest002, TestSize.Level0)
527 {
528 int32_t ret;
529 uint8_t uriBuf002[MAX_URI_LEN] = {0};
530 struct CmBlob certUri = { sizeof(uriBuf002), uriBuf002 };
531
532 ret = CmInstallUserTrustedCert(&userCert[1], &certAlias[1], &certUri);
533 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
534
535 ret = CmUninstallUserTrustedCert(&certUri);
536 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
537 }
538
539 /**
540 * @tc.name: InstallUserCertTest003
541 * @tc.desc: Test CertManager Install user cert interface base function
542 * @tc.type: FUNC
543 * @tc.require: AR000H0MJ8 /SR000H09N7
544 */
545 HWTEST_F(CmUserCertTest, InstallUserCertTest003, TestSize.Level0)
546 {
547 int32_t ret;
548 uint8_t uriBuf003[MAX_URI_LEN] = {0};
549 struct CmBlob certUri = { sizeof(uriBuf003), uriBuf003 };
550
551 ret = CmInstallUserTrustedCert(&userCert[2], &certAlias[2], &certUri);
552 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
553
554 ret = CmUninstallUserTrustedCert(&certUri);
555 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
556 }
557
558 /**
559 * @tc.name: InstallUserCertTest004
560 * @tc.desc: Test CertManager Update user cert interface base function
561 * @tc.type: FUNC
562 * @tc.require: AR000H0MJ8 /SR000H09N7
563 */
564 HWTEST_F(CmUserCertTest, InstallUserCertTest004, TestSize.Level0)
565 {
566 int32_t ret;
567 uint8_t aliasBuf001[] = "40dc992e";
568 uint8_t uriBuf004[MAX_URI_LEN] = {0};
569 struct CmBlob userCertUpdate = { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) };
570 struct CmBlob certAliasUpdate = { sizeof(aliasBuf001), aliasBuf001 };
571 struct CmBlob certUriUpdate = { sizeof(uriBuf004), uriBuf004 };
572
573 ret = CmInstallUserTrustedCert(&userCertUpdate, &certAliasUpdate, &certUriUpdate);
574 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
575
576 ret = CmInstallUserTrustedCert(&userCertUpdate, &certAliasUpdate, &certUriUpdate);
577 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
578
579 ret = CmUninstallUserTrustedCert(&certUriUpdate);
580 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
581 }
582
583 /**
584 * @tc.name: InstallUserCertTest005
585 * @tc.desc: Test CertManager Install user cert interface Abnormal function
586 * @tc.type: FUNC
587 * @tc.require: AR000H0MJ8 /SR000H09N7
588 */
589 HWTEST_F(CmUserCertTest, InstallUserCertTest005, TestSize.Level0)
590 {
591 int32_t ret;
592 uint8_t aliasBuf002[] = "abnormal-invalid-certdata";
593 uint8_t uriBuf005[MAX_URI_LEN] = {0};
594
595 struct CmBlob userCertTemp = { sizeof(g_certData04),
596 const_cast<uint8_t *>(g_certData04) }; /* invalid certData */
597 struct CmBlob certAliasTemp = { sizeof(aliasBuf002), aliasBuf002 };
598 struct CmBlob certUriTemp = { sizeof(uriBuf005), uriBuf005 };
599
600 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, &certUriTemp);
601 EXPECT_EQ(ret, CMR_ERROR_INVALID_CERT_FORMAT) << "Normal user cert Install test failed, recode:" << ret;
602 }
603
604 /**
605 * @tc.name: InstallUserCertTest006
606 * @tc.desc: Test CertManager Install user cert interface Abnormal function
607 * @tc.type: FUNC
608 * @tc.require: AR000H0MJ8 /SR000H09N7
609 */
610 HWTEST_F(CmUserCertTest, InstallUserCertTest006, TestSize.Level0)
611 {
612 int32_t ret;
613 uint8_t aliasBuf003[] = "abnormal-inputparam-null";
614 uint8_t uriBuf006[MAX_URI_LEN] = {0};
615
616 struct CmBlob userCertTemp = { sizeof(g_certData03), const_cast<uint8_t *>(g_certData03) };
617 struct CmBlob certAliasTemp = { sizeof(aliasBuf003), aliasBuf003 };
618 struct CmBlob certUriTemp = { sizeof(uriBuf006), uriBuf006 };
619
620 ret = CmInstallUserTrustedCert(nullptr, &certAliasTemp, &certUriTemp);
621 EXPECT_EQ(ret, CMR_ERROR_INVALID_ARGUMENT) << "Normal user cert Install test failed, recode:" << ret;
622
623 ret = CmInstallUserTrustedCert(&userCertTemp, nullptr, &certUriTemp);
624 EXPECT_EQ(ret, CMR_ERROR_INVALID_ARGUMENT) << "Normal user cert Install test failed, recode:" << ret;
625
626 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, nullptr);
627 EXPECT_EQ(ret, CMR_ERROR_INVALID_ARGUMENT) << "Normal user cert Install test failed, recode:" << ret;
628 }
629
630 /**
631 * @tc.name: InstallUserCertTest007
632 * @tc.desc: Test CertManager install max count user cert interface base function
633 * @tc.type: FUNC
634 * @tc.require: AR000H0MJ8 /SR000H09N7
635 */
636 HWTEST_F(CmUserCertTest, InstallUserCertTest007, TestSize.Level0)
637 {
638 int32_t ret;
639 struct CmBlob userCertTest = { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) };
640
641 for (uint32_t i = 0; i < MAX_COUNT_CERTIFICATE; i++) { /* install 256 times user cert */
642 char alias[] = "alias";
643 char aliasBuf004[MAX_LEN_CERT_ALIAS];
644 (void)snprintf_s(aliasBuf004, MAX_LEN_CERT_ALIAS, MAX_LEN_CERT_ALIAS - 1, "%s%u", alias, i);
645 struct CmBlob certAliasTest = { strlen(aliasBuf004) + 1, reinterpret_cast<uint8_t *>(aliasBuf004) };
646
647 uint8_t uriBuf007[MAX_URI_LEN] = {0};
648 struct CmBlob certUriTest = { sizeof(uriBuf007), uriBuf007 };
649
650 ret = CmInstallUserTrustedCert(&userCertTest, &certAliasTest, &certUriTest);
651 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
652 }
653
654 uint8_t certAliasBuf257[] = "40dc992e"; /* install 257th user cert */
655 uint8_t certUriBuf257[MAX_URI_LEN] = {0};
656 struct CmBlob certAlias257 = { sizeof(certAliasBuf257), certAliasBuf257 };
657 struct CmBlob certUri257 = { sizeof(certUriBuf257), certUriBuf257 };
658
659 ret = CmInstallUserTrustedCert(&userCertTest, &certAlias257, &certUri257);
660 EXPECT_EQ(ret, CM_FAILURE) << "Normal user cert Install test failed, recode:" << ret;
661
662 uint8_t certAliasBuf000[] = "alias0"; /* update 001th user cert */
663 uint8_t certUriBuf000[MAX_URI_LEN] = {0};
664 struct CmBlob certAlias000 = { sizeof(certAliasBuf000), certAliasBuf000 };
665 struct CmBlob certUri000 = { sizeof(certUriBuf000), certUriBuf000 };
666
667 ret = CmInstallUserTrustedCert(&userCertTest, &certAlias000, &certUri000);
668 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
669
670 ret = CmUninstallAllUserTrustedCert();
671 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
672 }
673
674 /**
675 * @tc.name: InstallUserCertTest008
676 * @tc.desc: Test CertManager Install user cert interface performance
677 * @tc.type: FUNC
678 * @tc.require: AR000H0MJ8 /SR000H09N7
679 */
680 HWTEST_F(CmUserCertTest, InstallUserCertTest008, TestSize.Level0)
681 {
682 int32_t ret;
683 for (uint32_t times = 0; times < PERFORMACE_COUNT; ++times) {
684 uint8_t uriBuf008[MAX_URI_LEN] = {0};
685 struct CmBlob certUri = { sizeof(uriBuf008), uriBuf008 };
686
687 ret = CmInstallUserTrustedCert(&userCert[2], &certAlias[2], &certUri);
688 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
689
690 ret = CmUninstallUserTrustedCert(&certUri);
691 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
692 }
693 }
694
695 /**
696 * @tc.name: InstallUserCertTest009
697 * @tc.desc: Test CertManager Install user cert interface Abnormal function
698 * @tc.type: FUNC
699 * @tc.require: AR000H0MJ8 /SR000H09N7
700 */
701 HWTEST_F(CmUserCertTest, InstallUserCertTest009, TestSize.Level0)
702 {
703 int32_t ret;
704 uint8_t largeAliasBuf[] = "large-size-input-cert-alias-000000000000000000000000000000000000";
705 uint8_t certUriBuf[MAX_URI_LEN] = {0};
706
707 struct CmBlob userCertTemp = { sizeof(g_certData02), const_cast<uint8_t *>(g_certData02) };
708 struct CmBlob largeAlias = { sizeof(largeAliasBuf), largeAliasBuf };
709 struct CmBlob certUriTemp = { sizeof(certUriBuf), certUriBuf };
710
711 ret = CmInstallUserTrustedCert(&userCertTemp, &largeAlias, &certUriTemp);
712 EXPECT_EQ(ret, CM_FAILURE) << "Normal user cert Install test failed, recode:" << ret;
713 }
714
715 /**
716 * @tc.name: InstallUserCertTest010
717 * @tc.desc: Test CertManager Install user cert interface Abnormal function
718 * @tc.type: FUNC
719 * @tc.require: AR000H0MJ8 /SR000H09N7
720 */
721 HWTEST_F(CmUserCertTest, InstallUserCertTest010, TestSize.Level0)
722 {
723 int32_t ret;
724 char errAliasBuf[] = "AliasNoEnd";
725 uint8_t certUriBuf[MAX_URI_LEN] = {0};
726
727 struct CmBlob userCertTemp = { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) };
728 struct CmBlob noEndAlias = { strlen(errAliasBuf), reinterpret_cast<uint8_t *>(errAliasBuf) };
729 struct CmBlob certUriTemp = { sizeof(certUriBuf), certUriBuf };
730
731 ret = CmInstallUserTrustedCert(&userCertTemp, &noEndAlias, &certUriTemp);
732 EXPECT_EQ(ret, CMR_ERROR_INVALID_ARGUMENT) << "Normal user cert Install test failed, recode:" << ret;
733 }
734
735 /**
736 * @tc.name: InstallUserCertTest011
737 * @tc.desc: Test CertManager Install user cert interface Abnormal function
738 * @tc.type: FUNC
739 * @tc.require: AR000H0MJ8 /SR000H09N7
740 */
741 HWTEST_F(CmUserCertTest, InstallUserCertTest011, TestSize.Level0)
742 {
743 int32_t ret;
744 char edgeAliasBuf[] = "aliaslengthis4800000000000000000000000000000000"; /* size is 48 */
745 uint8_t largeUriBuf[MAX_URI_LEN] = {0}; /* oh:t=c;o=;u=0;a=0 + alias size is 65 */
746
747 struct CmBlob userCertTemp = { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) };
748 struct CmBlob edgeAlias = { strlen(edgeAliasBuf) + 1, reinterpret_cast<uint8_t *>(edgeAliasBuf) };
749 struct CmBlob largeUri = { sizeof(largeUriBuf), largeUriBuf };
750
751 ret = CmInstallUserTrustedCert(&userCertTemp, &edgeAlias, &largeUri);
752 EXPECT_EQ(ret, CM_FAILURE) << "Normal user cert Install test failed, recode:" << ret;
753 }
754
755 /**
756 * @tc.name: UninstallUserCertTest001
757 * @tc.desc: Test CertManager Uninstall user cert interface base function
758 * @tc.type: FUNC
759 * @tc.require: AR000H0MJ8 /SR000H09N7
760 */
761 HWTEST_F(CmUserCertTest, UninstallUserCertTest001, TestSize.Level0)
762 {
763 int32_t ret;
764 uint8_t aliasBuf005[] = "985c1f52";
765 uint8_t uriBuf009[MAX_URI_LEN] = {0};
766 struct CmBlob userCertTemp = { sizeof(g_certData02), const_cast<uint8_t *>(g_certData02) };
767 struct CmBlob certAliasTemp = { sizeof(aliasBuf005), aliasBuf005 };
768 struct CmBlob certUriTemp = { sizeof(uriBuf009), uriBuf009 };
769
770 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, &certUriTemp);
771 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
772
773 ret = CmUninstallUserTrustedCert(&certUriTemp);
774 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
775 }
776
777 /**
778 * @tc.name: UninstallUserCertTest002
779 * @tc.desc: Test CertManager Uninstall user cert interface Abnormal function
780 * @tc.type: FUNC
781 * @tc.require: AR000H0MJ8 /SR000H09N7
782 */
783 HWTEST_F(CmUserCertTest, UninstallUserCertTest002, TestSize.Level0)
784 {
785 int32_t ret;
786 uint8_t aliasBuf006[] = "40dc992e";
787 uint8_t uriBuf010[MAX_URI_LEN] = {0};
788
789 struct CmBlob userCertTemp = { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) };
790 struct CmBlob certAliasTemp = { sizeof(aliasBuf006), aliasBuf006 };
791 struct CmBlob certUriTemp = { sizeof(uriBuf010), uriBuf010 };
792
793 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, &certUriTemp);
794 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
795
796 ret = CmUninstallUserTrustedCert(nullptr); /* uri is nullptr */
797 EXPECT_EQ(ret, CMR_ERROR_INVALID_ARGUMENT) << "Normal user cert Uninstall test failed, recode:" << ret;
798
799 ret = CmUninstallUserTrustedCert(&certUriTemp);
800 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
801 }
802
803 /**
804 * @tc.name: UninstallUserCertTest003
805 * @tc.desc: Test CertManager Uninstall user cert interface Abnormal function
806 * @tc.type: FUNC
807 * @tc.require: AR000H0MJ8 /SR000H09N7
808 */
809 HWTEST_F(CmUserCertTest, UninstallUserCertTest003, TestSize.Level0)
810 {
811 int32_t ret;
812 uint8_t aliasBuf007[] = "985c1f52";
813 uint8_t uriBuf011[MAX_URI_LEN] = {0};
814
815 struct CmBlob userCertTemp = { sizeof(g_certData02), const_cast<uint8_t *>(g_certData02) };
816 struct CmBlob certAliasTemp = { sizeof(aliasBuf007), aliasBuf007 };
817 struct CmBlob certUriTemp = { sizeof(uriBuf011), uriBuf011 };
818
819 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, &certUriTemp);
820 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
821
822 uint8_t errUriBuf[MAX_URI_LEN] = "*****"; /* error uri */
823 struct CmBlob errUri = { sizeof(errUriBuf), errUriBuf };
824 ret = CmUninstallUserTrustedCert(&errUri);
825 EXPECT_EQ(ret, CMR_ERROR_INVALID_ARGUMENT) << "Normal user cert Uninstall test failed, recode:" << ret;
826
827 ret = CmUninstallUserTrustedCert(&certUriTemp);
828 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
829 }
830
831 /**
832 * @tc.name: UninstallUserCertTest004
833 * @tc.desc: Test CertManager Uninstall user cert interface Abnormal function
834 * @tc.type: FUNC
835 * @tc.require: AR000H0MJ8 /SR000H09N7
836 */
837 HWTEST_F(CmUserCertTest, UninstallUserCertTest004, TestSize.Level0)
838 {
839 int32_t ret;
840 char invalidUriBuf[] = "oh:t=c;o=NOEXIST;u=0;a=0"; /* cert of uri is not exist */
841 struct CmBlob invalidUri = { strlen(invalidUriBuf) + 1, reinterpret_cast<uint8_t *>(invalidUriBuf) };
842
843 ret = CmUninstallUserTrustedCert(&invalidUri);
844 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
845 }
846
847 /**
848 * @tc.name: UninstallALLUserCertTest001
849 * @tc.desc: Test CertManager uninstall all user cert interface base function
850 * @tc.type: FUNC
851 * @tc.require: AR000H0MJ8 /SR000H09N7
852 */
853 HWTEST_F(CmUserCertTest, UninstallALLUserCertTest001, TestSize.Level0)
854 {
855 int32_t ret;
856
857 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
858 for (uint32_t i = 0; i < size; i++) {
859 uint8_t uriBuf012[MAX_URI_LEN] = {0};
860 struct CmBlob certUri = { sizeof(uriBuf012), uriBuf012 };
861 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUri);
862 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
863 }
864
865 ret = CmUninstallAllUserTrustedCert();
866 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
867 }
868
869 /**
870 * @tc.name: UninstallALLUserCertTest002
871 * @tc.desc: Test CertManager uninstall all user cert interface performance
872 * @tc.type: FUNC
873 * @tc.require: AR000H0MJ8 /SR000H09N7
874 */
875 HWTEST_F(CmUserCertTest, UninstallALLUserCertTest002, TestSize.Level0)
876 {
877 int32_t ret;
878
879 for (uint32_t time = 0; time < PERFORMACE_COUNT; time++) {
880 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
881 for (uint32_t i = 0; i < size; i++) {
882 uint8_t uriBuf013[MAX_URI_LEN] = {0};
883 struct CmBlob certUriTemp = { sizeof(uriBuf013), uriBuf013 };
884 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUriTemp);
885 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
886 }
887
888 ret = CmUninstallAllUserTrustedCert();
889 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
890 }
891 }
892
893 /**
894 * @tc.name: GetUserCertListTest001
895 * @tc.desc: Test CertManager Get user cert list interface base function
896 * @tc.type: FUNC
897 * @tc.require: AR000H0MJ8 /SR000H09N7
898 */
899 HWTEST_F(CmUserCertTest, GetUserCertListTest001, TestSize.Level0)
900 {
901 int32_t ret;
902
903 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
904 for (uint32_t i = 0; i < size; i++) {
905 uint8_t uriBuf014[MAX_URI_LEN] = {0};
906 struct CmBlob certUri = { sizeof(uriBuf014), uriBuf014 };
907 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUri);
908 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
909 }
910
911 struct CertList *certList001 = nullptr;
912 InitCertList(&certList001);
913 ret = CmGetUserCertList(CM_USER_TRUSTED_STORE, certList001);
914 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert list test failed, recode:" << ret;
915 FreeCertList(certList001);
916
917 ret = CmUninstallAllUserTrustedCert();
918 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
919 }
920
921 /**
922 * @tc.name: GetUserCertListTest002
923 * @tc.desc: Test CertManager Get user cert list And check content interface function
924 * @tc.type: FUNC
925 * @tc.require: AR000H0MJ8 /SR000H09N7
926 */
927 HWTEST_F(CmUserCertTest, GetUserCertListTest002, TestSize.Level0)
928 {
929 int32_t ret;
930 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
931 for (uint32_t i = 0; i < size; i++) {
932 uint8_t uriBuf015[MAX_URI_LEN] = {0};
933 struct CmBlob certUri = { sizeof(uriBuf015), uriBuf015 };
934 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUri);
935 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
936 }
937
938 struct CertList *certList002 = nullptr;
939 InitCertList(&certList002);
940 ret = CmGetUserCertList(CM_USER_TRUSTED_STORE, certList002);
941 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert list test failed, recode:" << ret;
942
943 uint32_t len = sizeof(g_certListExpectResult) / sizeof(g_certListExpectResult[0]);
944 bool found = false;
945 for (uint32_t i = 0; i < len; i++) {
946 found = FindCertAbstract(&(g_certListExpectResult[i].certAbstract), certList002);
947 EXPECT_EQ(found, g_certListExpectResult[i].bExpectResult) << DumpCertList(certList002);
948 }
949 FreeCertList(certList002);
950
951 ret = CmUninstallAllUserTrustedCert();
952 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
953 }
954
955 /**
956 * @tc.name: GetUserCertListTest003
957 * @tc.desc: Test CertManager Get user cert list interface Abnormal function
958 * @tc.type: FUNC
959 * @tc.require: AR000H0MJ8 /SR000H09N7
960 */
961 HWTEST_F(CmUserCertTest, GetUserCertListTest003, TestSize.Level0)
962 {
963 int32_t ret;
964
965 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
966 for (uint32_t i = 0; i < size; i++) {
967 uint8_t uriBuf016[MAX_URI_LEN] = {0};
968 struct CmBlob certUri = { sizeof(uriBuf016), uriBuf016 };
969 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUri);
970 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
971 }
972
973 ret = CmGetUserCertList(CM_USER_TRUSTED_STORE, nullptr); /* cList is nullptr */
974 EXPECT_EQ(ret, CMR_ERROR_NULL_POINTER);
975
976 struct CertList *certList003 = nullptr;
977 InitCertList(&certList003);
978 ret = CmGetUserCertList(100, certList003); /* invalid store 100 */
979 EXPECT_EQ(ret, CM_FAILURE);
980 FreeCertList(certList003);
981
982 ret = CmUninstallAllUserTrustedCert();
983 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
984 }
985
986 /**
987 * @tc.name: GetUserCertListTest004
988 * @tc.desc: Test CertManager Get user cert list interface performance
989 * @tc.type: FUNC
990 * @tc.require: AR000H0MJ8 /SR000H09N7
991 */
992 HWTEST_F(CmUserCertTest, GetUserCertListTest004, TestSize.Level0)
993 {
994 int32_t ret;
995
996 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
997 for (uint32_t i = 0; i < size; i++) {
998 uint8_t uriBuf017[MAX_URI_LEN] = {0};
999 struct CmBlob certUri = { sizeof(uriBuf017), uriBuf017 };
1000 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUri);
1001 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1002 }
1003
1004 for (uint32_t times = 0; times < PERFORMACE_COUNT; ++times) {
1005 struct CertList *certList004 = nullptr;
1006 InitCertList(&certList004);
1007 ret = CmGetUserCertList(CM_USER_TRUSTED_STORE, certList004);
1008 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert list test failed, recode:" << ret;
1009 FreeCertList(certList004);
1010 }
1011
1012 ret = CmUninstallAllUserTrustedCert();
1013 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
1014 }
1015
1016 /**
1017 * @tc.name: GetUserCertListTest005
1018 * @tc.desc: Test CertManager Get user cert list interface Abnormal function
1019 * @tc.type: FUNC
1020 * @tc.require: AR000H0MJ8 /SR000H09N7
1021 */
1022 HWTEST_F(CmUserCertTest, GetUserCertListTest005, TestSize.Level0)
1023 {
1024 struct CertList *certList005 = nullptr;
1025 InitCertList(&certList005);
1026 int32_t ret = CmGetUserCertList(CM_USER_TRUSTED_STORE, certList005); /* empty dir */
1027 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert list test failed, recode:" << ret;
1028 FreeCertList(certList005);
1029 }
1030
1031 /**
1032 * @tc.name: GetUserCertInfoTest001
1033 * @tc.desc: Test CertManager Get user cert info interface base function
1034 * @tc.type: FUNC
1035 * @tc.require: AR000H0MJ8 /SR000H09N7
1036 */
1037 HWTEST_F(CmUserCertTest, GetUserCertInfoTest001, TestSize.Level0)
1038 {
1039 int32_t ret;
1040 uint8_t aliasBuf008[] = "40dc992e";
1041 uint8_t uriBuf018[MAX_URI_LEN] = {0};
1042
1043 struct CmBlob testUserCert = { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) };
1044 struct CmBlob testCertAlias = { sizeof(aliasBuf008), aliasBuf008 };
1045 struct CmBlob testCertUri = { sizeof(uriBuf018), uriBuf018 };
1046
1047 ret = CmInstallUserTrustedCert(&testUserCert, &testCertAlias, &testCertUri);
1048 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1049
1050 struct CertInfo *certInfo001 = nullptr;
1051 InitUserCertInfo(&certInfo001);
1052 ret = CmGetUserCertInfo(&testCertUri, CM_USER_TRUSTED_STORE, certInfo001);
1053 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert info test failed, recode:" << ret;
1054
1055 EXPECT_EQ(CompareCertInfo(certInfo001, &(g_certInfoExpectResult[0].certInfo)), true) << DumpCertInfo(certInfo001);
1056 EXPECT_EQ(CompareCertData(&(certInfo001->certInfo), &(g_certInfoExpectResult[0].certInfo.certInfo)), true);
1057 FreeCertInfo(certInfo001);
1058
1059 ret = CmUninstallUserTrustedCert(&testCertUri);
1060 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
1061 }
1062
1063 /**
1064 * @tc.name: GetUserCertInfoTest002
1065 * @tc.desc: Test CertManager Get user cert info interface base function
1066 * @tc.type: FUNC
1067 * @tc.require: AR000H0MJ8 /SR000H09N7
1068 */
1069 HWTEST_F(CmUserCertTest, GetUserCertInfoTest002, TestSize.Level0)
1070 {
1071 int32_t ret;
1072
1073 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
1074 for (uint32_t i = 0; i < size; i++) {
1075 uint8_t uriBuf019[MAX_URI_LEN] = {0};
1076 struct CmBlob certUri = { sizeof(uriBuf019), uriBuf019 };
1077 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUri);
1078 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1079 }
1080
1081 struct CertList *certList006 = nullptr;
1082 InitCertList(&certList006);
1083 ret = CmGetUserCertList(CM_USER_TRUSTED_STORE, certList006);
1084 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert list test failed, recode:" << ret;
1085
1086 uint32_t certCnt = sizeof(g_certInfoExpectResult) / sizeof(g_certInfoExpectResult[0]);
1087 bool found = false;
1088 for (uint32_t i = 0; i < certCnt; i++) {
1089 struct CertAbstract *ptr = &(g_certListExpectResult[i].certAbstract);
1090 ASSERT_TRUE(ptr != nullptr);
1091 found = FindCertAbstract(ptr, certList006);
1092 EXPECT_EQ(found, g_certListExpectResult[i].bExpectResult);
1093
1094 struct CmBlob uriBlob = { strlen(ptr->uri) + 1, reinterpret_cast<uint8_t *>(ptr->uri) };
1095 struct CertInfo *certInfo002 = nullptr;
1096 InitUserCertInfo(&certInfo002);
1097 ret = CmGetUserCertInfo(&uriBlob, CM_USER_TRUSTED_STORE, certInfo002);
1098 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert info test failed, recode:" << ret;
1099
1100 EXPECT_EQ(CompareCertInfo(certInfo002, &(g_certInfoExpectResult[i].certInfo)), true) <<
1101 DumpCertInfo(certInfo002);
1102 EXPECT_EQ(CompareCertData(&(certInfo002->certInfo), &(g_certInfoExpectResult[i].certInfo.certInfo)), true);
1103 FreeCertInfo(certInfo002);
1104 }
1105 FreeCertList(certList006);
1106
1107 ret = CmUninstallAllUserTrustedCert();
1108 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
1109 }
1110
1111 /**
1112 * @tc.name: GetUserCertInfoTest003
1113 * @tc.desc: Test CertManager Get user cert info interface Abnormal function
1114 * @tc.type: FUNC
1115 * @tc.require: AR000H0MJ8 /SR000H09N7
1116 */
1117 HWTEST_F(CmUserCertTest, GetUserCertInfoTest003, TestSize.Level0)
1118 {
1119 int32_t ret;
1120 struct CertInfo *certInfo003 = nullptr;
1121 InitUserCertInfo(&certInfo003);
1122 ret = CmGetUserCertInfo(nullptr, CM_USER_TRUSTED_STORE, certInfo003); /* uri is nullptr */
1123 EXPECT_EQ(ret, CMR_ERROR_NULL_POINTER);
1124 FreeCertInfo(certInfo003);
1125 }
1126
1127 /**
1128 * @tc.name: GetUserCertInfoTest004
1129 * @tc.desc: Test CertManager Get user cert info interface Abnormal function
1130 * @tc.type: FUNC
1131 * @tc.require: AR000H0MJ8 /SR000H09N7
1132 */
1133 HWTEST_F(CmUserCertTest, GetUserCertInfoTest004, TestSize.Level0)
1134 {
1135 int32_t ret;
1136 char *uri = g_certInfoExpectResult[0].certInfo.uri;
1137 struct CmBlob certUri = { strlen(uri) + 1, reinterpret_cast<uint8_t *>(uri) };
1138
1139 struct CertInfo *certInfo004 = nullptr;
1140 InitUserCertInfo(&certInfo004);
1141 ret = CmGetUserCertInfo(&certUri, 100, certInfo004); /* invalid store 100 */
1142 EXPECT_EQ(ret, CM_FAILURE);
1143 FreeCertInfo(certInfo004);
1144 }
1145
1146 /**
1147 * @tc.name: GetUserCertInfoTest005
1148 * @tc.desc: Test CertManager Get user cert info interface Abnormal function
1149 * @tc.type: FUNC
1150 * @tc.require: AR000H0MJ8 /SR000H09N7
1151 */
1152 HWTEST_F(CmUserCertTest, GetUserCertInfoTest005, TestSize.Level0)
1153 {
1154 int32_t ret;
1155 char *uri = g_certInfoExpectResult[1].certInfo.uri;
1156 struct CmBlob certUri = { strlen(uri) + 1, reinterpret_cast<uint8_t *>(uri) };
1157
1158 ret = CmGetUserCertInfo(&certUri, CM_USER_TRUSTED_STORE, nullptr); /* cInfo not malloc */
1159 EXPECT_EQ(ret, CMR_ERROR_NULL_POINTER);
1160 }
1161
1162 /**
1163 * @tc.name: GetUserCertInfoTest006
1164 * @tc.desc: Test CertManager Get user cert info interface performance
1165 * @tc.type: FUNC
1166 * @tc.require: AR000H0MJ8 /SR000H09N7
1167 */
1168 HWTEST_F(CmUserCertTest, GetUserCertInfoTest006, TestSize.Level0)
1169 {
1170 int32_t ret;
1171 uint8_t aliasBuf009[] = "40dc992e";
1172 uint8_t uriBuf020[MAX_URI_LEN] = {0};
1173
1174 struct CmBlob userCertTemp = { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) };
1175 struct CmBlob certAliasTemp = { sizeof(aliasBuf009), aliasBuf009 };
1176 struct CmBlob certUri = { sizeof(uriBuf020), uriBuf020 };
1177
1178 for (uint32_t time = 0; time < PERFORMACE_COUNT; time++) {
1179 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, &certUri);
1180 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1181
1182 struct CertInfo *certInfo005 = nullptr;
1183 InitUserCertInfo(&certInfo005);
1184 ret = CmGetUserCertInfo(&certUri, CM_USER_TRUSTED_STORE, certInfo005);
1185 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert info test failed, recode:" << ret;
1186
1187 EXPECT_EQ(CompareCertInfo(certInfo005, &(g_certInfoExpectResult[0].certInfo)), true) <<
1188 DumpCertInfo(certInfo005);
1189 EXPECT_EQ(CompareCertData(&(certInfo005->certInfo), &(g_certInfoExpectResult[0].certInfo.certInfo)), true);
1190 FreeCertInfo(certInfo005);
1191
1192 ret = CmUninstallUserTrustedCert(&certUri);
1193 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
1194 }
1195 }
1196
1197 /**
1198 * @tc.name: SetUserCertStatusTest001
1199 * @tc.desc: Test CertManager Set user cert status interface base function
1200 * @tc.type: FUNC
1201 * @tc.require: AR000H0MJ8 /SR000H09N7
1202 */
1203 HWTEST_F(CmUserCertTest, SetUserCertStatusTest001, TestSize.Level0)
1204 {
1205 int32_t ret;
1206
1207 uint8_t aliasBuf010[] = "1df5a75f";
1208 uint8_t uriBuf021[MAX_URI_LEN] = {0};
1209 struct CmBlob userCertTemp = { sizeof(g_certData03), const_cast<uint8_t *>(g_certData03) };
1210 struct CmBlob certAliasTemp = { sizeof(aliasBuf010), aliasBuf010 };
1211 struct CmBlob certUri = { sizeof(uriBuf021), uriBuf021 };
1212 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, &certUri);
1213 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1214
1215 char *uri = g_certStatusExpectResult[2].uri;
1216 struct CmBlob uriTemp = { strlen(uri) + 1, reinterpret_cast<uint8_t *>(uri) };
1217 ret = CmSetUserCertStatus(&uriTemp, CM_USER_TRUSTED_STORE, g_certStatusExpectResult[2].inparamStatus);
1218 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1219
1220 ret = CmSetUserCertStatus(&uriTemp, CM_USER_TRUSTED_STORE, true);
1221 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1222 ret = CmUninstallUserTrustedCert(&certUri);
1223 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
1224 }
1225
1226 /**
1227 * @tc.name: SetUserCertStatusTest002
1228 * @tc.desc: Test CertManager set user cert status interface base function
1229 * @tc.type: FUNC
1230 * @tc.require: AR000H0MJ8 /SR000H09N7
1231 */
1232 HWTEST_F(CmUserCertTest, SetUserCertStatusTest002, TestSize.Level0)
1233 {
1234 int32_t ret;
1235
1236 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
1237 for (uint32_t i = 0; i < size; i++) {
1238 uint8_t uriBuf022[MAX_URI_LEN] = {0};
1239 struct CmBlob certUriTemp = { sizeof(uriBuf022), uriBuf022 };
1240 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUriTemp);
1241 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1242 }
1243
1244 uint32_t len = sizeof(g_certStatusExpectResult) / sizeof(g_certStatusExpectResult[0]);
1245 for (uint32_t i = 0; i < len; i++) {
1246 struct CmBlob certUri = { strlen(g_certStatusExpectResult[i].uri) + 1,
1247 reinterpret_cast<uint8_t *>(g_certStatusExpectResult[i].uri) };
1248
1249 ret = CmSetUserCertStatus(&certUri, CM_USER_TRUSTED_STORE, g_certStatusExpectResult[i].inparamStatus);
1250 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1251
1252 struct CertInfo *certInfo006 = nullptr;
1253 InitUserCertInfo(&certInfo006);
1254 ret = CmGetUserCertInfo(&certUri, CM_USER_TRUSTED_STORE, certInfo006);
1255 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert info test failed, recode:" << ret;
1256
1257 int32_t status = (g_certStatusExpectResult[i].expectStatus == certInfo006->status) ? 1 : 0;
1258 EXPECT_EQ(status, 1) << "set user cert status test failed, cert info: " <<
1259 DumpCertInfo(certInfo006);
1260 FreeCertInfo(certInfo006);
1261
1262 ret = CmSetUserCertStatus(&certUri, CM_USER_TRUSTED_STORE, true);
1263 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1264 }
1265
1266 ret = CmUninstallAllUserTrustedCert();
1267 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
1268 }
1269
1270 /**
1271 * @tc.name: SetUserCertStatusTest003
1272 * @tc.desc: Test CertManager Set user cert status interface base function
1273 * @tc.type: FUNC
1274 * @tc.require: AR000H0MJ8 /SR000H09N7
1275 */
1276 HWTEST_F(CmUserCertTest, SetUserCertStatusTest003, TestSize.Level0)
1277 {
1278 int32_t ret;
1279
1280 uint32_t size = sizeof(certAlias) / sizeof(certAlias[0]);
1281 for (uint32_t i = 0; i < size; i++) {
1282 uint8_t uriBuf023[MAX_URI_LEN] = {0};
1283 struct CmBlob certUriTemp = { sizeof(uriBuf023), uriBuf023 };
1284 ret = CmInstallUserTrustedCert(&userCert[i], &certAlias[i], &certUriTemp);
1285 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1286 }
1287
1288 struct CertList *certList007 = nullptr;
1289 InitCertList(&certList007);
1290 ret = CmGetUserCertList(CM_USER_TRUSTED_STORE, certList007);
1291 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert list test failed, recode:" << ret;
1292
1293 for (uint32_t i = 0; i < certList007->certsCount; ++i) {
1294 struct CertAbstract *ptr = &(certList007->certAbstract[i]);
1295 struct CmBlob uri01 = { strlen(ptr->uri) + 1, reinterpret_cast<uint8_t *>(ptr->uri) };
1296 ret = CmSetUserCertStatus(&uri01, CM_USER_TRUSTED_STORE, false);
1297 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1298 }
1299
1300 for (uint32_t i = 0; i < certList007->certsCount; ++i) {
1301 struct CertAbstract *ptr = &(certList007->certAbstract[i]);
1302 struct CmBlob uri02 = { strlen(ptr->uri) + 1, reinterpret_cast<uint8_t *>(ptr->uri) };
1303 ret = CmSetUserCertStatus(&uri02, CM_USER_TRUSTED_STORE, true);
1304 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1305 }
1306
1307 FreeCertList(certList007);
1308 ret = CmUninstallAllUserTrustedCert();
1309 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
1310 }
1311
1312 /**
1313 * @tc.name: SetUserCertStatusTest004
1314 * @tc.desc: Test CertManager set user cert status interface Abnormal function
1315 * @tc.type: FUNC
1316 * @tc.require: AR000H0MJ8 /SR000H09N7
1317 */
1318 HWTEST_F(CmUserCertTest, SetUserCertStatusTest004, TestSize.Level0)
1319 {
1320 int32_t ret;
1321
1322 ret = CmSetUserCertStatus(nullptr, CM_USER_TRUSTED_STORE, true); /* uri is nullptr */
1323 EXPECT_EQ(ret, CMR_ERROR_NULL_POINTER) << "Normal set user cert status test failed, recode:" << ret;
1324 }
1325
1326 /**
1327 * @tc.name: SetUserCertStatusTest005
1328 * @tc.desc: Test CertManager set user cert status interface Abnormal function
1329 * @tc.type: FUNC
1330 * @tc.require: AR000H0MJ8 /SR000H09N7
1331 */
1332 HWTEST_F(CmUserCertTest, SetUserCertStatusTest005, TestSize.Level0)
1333 {
1334 int32_t ret;
1335 struct CmBlob certUri = { strlen(g_certStatusExpectResult[1].uri) + 1,
1336 reinterpret_cast<uint8_t *>(g_certStatusExpectResult[1].uri) };
1337
1338 ret = CmSetUserCertStatus(&certUri, 100, true); /* invalid store */
1339 EXPECT_EQ(ret, CM_FAILURE) << "Normal set user cert status test failed, recode:" << ret;
1340 }
1341
1342 /**
1343 * @tc.name: SetUserCertStatusTest006
1344 * @tc.desc: Test CertManager set user cert status interface Abnormal function
1345 * @tc.type: FUNC
1346 * @tc.require: AR000H0MJ8 /SR000H09N7
1347 */
1348 HWTEST_F(CmUserCertTest, SetUserCertStatusTest006, TestSize.Level0)
1349 {
1350 int32_t ret;
1351 uint8_t invalidUriBuf[] = "invaliduri";
1352 struct CmBlob invalidCertUri = { sizeof(invalidUriBuf), invalidUriBuf };
1353
1354 ret = CmSetUserCertStatus(&invalidCertUri, CM_USER_TRUSTED_STORE, true);
1355 EXPECT_EQ(ret, CMR_ERROR_NOT_FOUND) << "Normal set user cert status test failed, recode:" << ret;
1356 }
1357
1358 /**
1359 * @tc.name: SetUserCertStatusTest007
1360 * @tc.desc: Test CertManager update user cert AND set user cert status interface Abnormal function
1361 * @tc.type: FUNC
1362 * @tc.require: AR000H0MJ8 /SR000H09N7
1363 */
1364 HWTEST_F(CmUserCertTest, SetUserCertStatusTest007, TestSize.Level0)
1365 {
1366 int32_t ret;
1367 uint8_t aliasBuf011[] = "40dc992e";
1368 uint8_t uriBuf024[MAX_URI_LEN] = {0};
1369 struct CmBlob userCertTemp = { sizeof(g_certData01), const_cast<uint8_t *>(g_certData01) };
1370 struct CmBlob certAliasTemp = { sizeof(aliasBuf011), aliasBuf011 };
1371 struct CmBlob certUri = { sizeof(uriBuf024), uriBuf024 };
1372
1373 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, &certUri); /* install */
1374 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1375
1376 ret = CmSetUserCertStatus(&certUri, CM_USER_TRUSTED_STORE, false); /* set status false */
1377 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1378
1379 ret = CmInstallUserTrustedCert(&userCertTemp, &certAliasTemp, &certUri); /* update cert */
1380 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1381
1382 struct CertInfo *certInfo007 = nullptr;
1383 InitUserCertInfo(&certInfo007);
1384 ret = CmGetUserCertInfo(&certUri, CM_USER_TRUSTED_STORE, certInfo007);
1385 EXPECT_EQ(ret, CM_SUCCESS) << "Normal get user cert info test failed, recode:" << ret;
1386
1387 EXPECT_EQ(true, certInfo007->status);
1388
1389 FreeCertInfo(certInfo007);
1390
1391 ret = CmUninstallAllUserTrustedCert();
1392 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall All test failed, recode:" << ret;
1393 }
1394
1395 /**
1396 * @tc.name: SetUserCertStatusTest008
1397 * @tc.desc: Test CertManager set user cert status interface performance
1398 * @tc.type: FUNC
1399 * @tc.require: AR000H0MJ8 /SR000H09N7
1400 */
1401 HWTEST_F(CmUserCertTest, SetUserCertStatusTest008, TestSize.Level0)
1402 {
1403 int32_t ret;
1404 uint8_t aliasBuf012[] = "1df5a75f";
1405 uint8_t uriBuf025[MAX_URI_LEN] = {0};
1406 struct CmBlob userCert = { sizeof(g_certData03), const_cast<uint8_t *>(g_certData03) };
1407 struct CmBlob certAlias = { sizeof(aliasBuf012), aliasBuf012 };
1408 struct CmBlob certUri = { sizeof(uriBuf025), uriBuf025 };
1409
1410 ret = CmInstallUserTrustedCert(&userCert, &certAlias, &certUri);
1411 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Install test failed, recode:" << ret;
1412
1413 for (uint32_t time = 0; time < PERFORMACE_COUNT; time++) {
1414 ret = CmSetUserCertStatus(&certUri, CM_USER_TRUSTED_STORE, g_certStatusExpectResult[2].inparamStatus);
1415 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1416
1417 ret = CmSetUserCertStatus(&certUri, CM_USER_TRUSTED_STORE, true);
1418 EXPECT_EQ(ret, CM_SUCCESS) << "Normal set user cert status test failed, recode:" << ret;
1419 }
1420
1421 ret = CmUninstallUserTrustedCert(&certUri);
1422 EXPECT_EQ(ret, CM_SUCCESS) << "Normal user cert Uninstall test failed, recode:" << ret;
1423 }
1424 }
1425