Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / credentials / tests / CHIPCert_test_vectors.h
1 /*
2  *
3  *    Copyright (c) 2020-2021 Project CHIP Authors
4  *    Copyright (c) 2019 Google LLC.
5  *    Copyright (c) 2016-2017 Nest Labs, Inc.
6  *    All rights reserved.
7  *
8  *    Licensed under the Apache License, Version 2.0 (the "License");
9  *    you may not use this file except in compliance with the License.
10  *    You may obtain a copy of the License at
11  *
12  *        http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing, software
15  *    distributed under the License is distributed on an "AS IS" BASIS,
16  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  *    See the License for the specific language governing permissions and
18  *    limitations under the License.
19  */
20
21 /**
22  *    @file
23  *      This file contains definitions of test certificates used by various unit tests.
24  *
25  */
26
27 #pragma once
28
29 #include <asn1/ASN1OID.h>
30 #include <core/CHIPConfig.h>
31 #include <support/BitFlags.h>
32 #include <support/CodeUtils.h>
33
34 namespace chip {
35 namespace TestCerts {
36
37 using namespace chip::Credentials;
38 using namespace chip::ASN1;
39
40 enum TestCertTypes
41 {
42     kNone              = 0x00,
43     kRoot              = 0x01,
44     kRootKey           = 0x02,
45     kNodeCA            = 0x03,
46     kNode01            = 0x04,
47     kFirmwareSigningCA = 0x05,
48     kFirmwareSigning   = 0x06,
49 };
50
51 // Special flags to alter how certificates are fetched/loaded.
52 enum class TestCertLoadFlags : uint8_t
53 {
54     kDERForm               = 0x01,
55     kSuppressIsCA          = 0x02,
56     kSuppressKeyUsage      = 0x04,
57     kSuppressKeyCertSign   = 0x08,
58     kSetPathLenConstZero   = 0x10,
59     kSetAppDefinedCertType = 0x20,
60 };
61
62 extern CHIP_ERROR GetTestCert(uint8_t certType, BitFlags<TestCertLoadFlags> certLoadFlags, const uint8_t *& certData,
63                               uint32_t & certDataLen);
64 extern const char * GetTestCertName(uint8_t certType);
65 extern CHIP_ERROR LoadTestCert(ChipCertificateSet & certSet, uint8_t certType, BitFlags<TestCertLoadFlags> certLoadFlags,
66                                BitFlags<CertDecodeFlags> decodeFlags);
67
68 extern const uint8_t gTestCerts[];
69 extern const size_t gNumTestCerts;
70
71 extern const uint8_t sTestCert_Root_Chip[];
72 extern const uint32_t sTestCert_Root_Chip_Len;
73 extern const uint8_t sTestCert_Root_DER[];
74 extern const uint32_t sTestCert_Root_DER_Len;
75 extern const uint8_t sTestCert_Root_PublicKey[];
76 extern const uint8_t sTestCert_Root_PublicKey_Len;
77 extern const uint8_t sTestCert_Root_PrivateKey[];
78 extern const uint8_t sTestCert_Root_PrivateKey_Len;
79 extern const uint8_t sTestCert_Root_SubjectKeyId[];
80 extern const uint8_t sTestCert_Root_SubjectKeyId_Len;
81 extern const uint64_t sTestCert_Root_Id;
82
83 extern const uint8_t sTestCert_NodeCA_Chip[];
84 extern const uint32_t sTestCert_NodeCA_Chip_Len;
85 extern const uint8_t sTestCert_NodeCA_DER[];
86 extern const uint32_t sTestCert_NodeCA_DER_Len;
87 extern const uint8_t sTestCert_NodeCA_PublicKey[];
88 extern const uint8_t sTestCert_NodeCA_PublicKey_Len;
89 extern const uint8_t sTestCert_NodeCA_PrivateKey[];
90 extern const uint8_t sTestCert_NodeCA_PrivateKey_Len;
91 extern const uint8_t sTestCert_NodeCA_SubjectKeyId[];
92 extern const uint8_t sTestCert_NodeCA_SubjectKeyId_Len;
93 extern const uint64_t sTestCert_NodeCA_Id;
94
95 extern const uint8_t sTestCert_Node01_Chip[];
96 extern const uint32_t sTestCert_Node01_Chip_Len;
97 extern const uint8_t sTestCert_Node01_DER[];
98 extern const uint32_t sTestCert_Node01_DER_Len;
99 extern const uint8_t sTestCert_Node01_PublicKey[];
100 extern const uint8_t sTestCert_Node01_PublicKey_Len;
101 extern const uint8_t sTestCert_Node01_PrivateKey[];
102 extern const uint8_t sTestCert_Node01_PrivateKey_Len;
103 extern const uint8_t sTestCert_Node01_SubjectKeyId[];
104 extern const uint8_t sTestCert_Node01_SubjectKeyId_Len;
105 extern const uint64_t sTestCert_Node01_Id;
106
107 extern const uint8_t sTestCert_FirmwareSigningCA_Chip[];
108 extern const uint32_t sTestCert_FirmwareSigningCA_Chip_Len;
109 extern const uint8_t sTestCert_FirmwareSigningCA_DER[];
110 extern const uint32_t sTestCert_FirmwareSigningCA_DER_Len;
111 extern const uint8_t sTestCert_FirmwareSigningCA_PublicKey[];
112 extern const uint8_t sTestCert_FirmwareSigningCA_PublicKey_Len;
113 extern const uint8_t sTestCert_FirmwareSigningCA_PrivateKey[];
114 extern const uint8_t sTestCert_FirmwareSigningCA_PrivateKey_Len;
115 extern const uint8_t sTestCert_FirmwareSigningCA_SubjectKeyId[];
116 extern const uint8_t sTestCert_FirmwareSigningCA_SubjectKeyId_Len;
117 extern const uint64_t sTestCert_FirmwareSigningCA_Id;
118
119 extern const uint8_t sTestCert_FirmwareSigning_Chip[];
120 extern const uint32_t sTestCert_FirmwareSigning_Chip_Len;
121 extern const uint8_t sTestCert_FirmwareSigning_DER[];
122 extern const uint32_t sTestCert_FirmwareSigning_DER_Len;
123 extern const uint8_t sTestCert_FirmwareSigning_PublicKey[];
124 extern const uint8_t sTestCert_FirmwareSigning_PublicKey_Len;
125 extern const uint8_t sTestCert_FirmwareSigning_PrivateKey[];
126 extern const uint8_t sTestCert_FirmwareSigning_PrivateKey_Len;
127 extern const uint8_t sTestCert_FirmwareSigning_SubjectKeyId[];
128 extern const uint8_t sTestCert_FirmwareSigning_SubjectKeyId_Len;
129 extern const uint64_t sTestCert_FirmwareSigning_Id;
130
131 } // namespace TestCerts
132 } // namespace chip