3 * Copyright (c) 2020-2021 Project CHIP Authors
4 * Copyright (c) 2019 Google LLC.
5 * Copyright (c) 2016-2017 Nest Labs, Inc.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * This file contains definitions of test certificates used by various unit tests.
29 #include <asn1/ASN1OID.h>
30 #include <core/CHIPConfig.h>
31 #include <support/BitFlags.h>
32 #include <support/CodeUtils.h>
37 using namespace chip::Credentials;
38 using namespace chip::ASN1;
47 kFirmwareSigningCA = 0x05,
48 kFirmwareSigning = 0x06,
51 // Special flags to alter how certificates are fetched/loaded.
52 enum class TestCertLoadFlags : uint8_t
56 kSuppressKeyUsage = 0x04,
57 kSuppressKeyCertSign = 0x08,
58 kSetPathLenConstZero = 0x10,
59 kSetAppDefinedCertType = 0x20,
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);
68 extern const uint8_t gTestCerts[];
69 extern const size_t gNumTestCerts;
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;
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;
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;
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;
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;
131 } // namespace TestCerts