]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c
MdeModulePkg/PiDxeS3BootScriptLib: Fix potential numeric truncation (CVE-2019-14563)
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLib / Pk / CryptX509Null.c
CommitLineData
532616bb 1/** @file\r
2 X.509 Certificate Handler Wrapper Implementation which does not provide\r
3 real capabilities.\r
4\r
0b6457ef 5Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
2009f6b4 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
532616bb 7\r
8**/\r
9\r
10#include "InternalCryptLib.h"\r
11\r
12/**\r
13 Construct a X509 object from DER-encoded certificate data.\r
14\r
15 Return FALSE to indicate this interface is not supported.\r
16\r
17 @param[in] Cert Pointer to the DER-encoded certificate data.\r
18 @param[in] CertSize The size of certificate data in bytes.\r
19 @param[out] SingleX509Cert The generated X509 object.\r
20\r
21 @retval FALSE This interface is not supported.\r
22\r
23**/\r
24BOOLEAN\r
25EFIAPI\r
26X509ConstructCertificate (\r
27 IN CONST UINT8 *Cert,\r
28 IN UINTN CertSize,\r
29 OUT UINT8 **SingleX509Cert\r
30 )\r
31{\r
32 ASSERT (FALSE);\r
33 return FALSE;\r
34}\r
35\r
36/**\r
37 Construct a X509 stack object from a list of DER-encoded certificate data.\r
38\r
39 Return FALSE to indicate this interface is not supported.\r
40\r
952bd229 41 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r
532616bb 42 On output, pointer to the X509 stack object with new\r
43 inserted X509 certificate.\r
44 @param ... A list of DER-encoded single certificate data followed\r
45 by certificate size. A NULL terminates the list. The\r
46 pairs are the arguments to X509ConstructCertificate().\r
630f67dd 47\r
532616bb 48 @retval FALSE This interface is not supported.\r
49\r
50**/\r
51BOOLEAN\r
52EFIAPI\r
53X509ConstructCertificateStack (\r
54 IN OUT UINT8 **X509Stack,\r
630f67dd 55 ...\r
532616bb 56 )\r
57{\r
58 ASSERT (FALSE);\r
59 return FALSE;\r
60}\r
61\r
62/**\r
63 Release the specified X509 object.\r
64\r
65 If the interface is not supported, then ASSERT().\r
66\r
67 @param[in] X509Cert Pointer to the X509 object to be released.\r
68\r
69**/\r
70VOID\r
71EFIAPI\r
72X509Free (\r
73 IN VOID *X509Cert\r
74 )\r
630f67dd 75{\r
532616bb 76 ASSERT (FALSE);\r
77}\r
78\r
79/**\r
80 Release the specified X509 stack object.\r
81\r
82 If the interface is not supported, then ASSERT().\r
83\r
84 @param[in] X509Stack Pointer to the X509 stack object to be released.\r
85\r
86**/\r
87VOID\r
88EFIAPI\r
89X509StackFree (\r
90 IN VOID *X509Stack\r
91 )\r
92{\r
93 ASSERT (FALSE);\r
94}\r
95\r
96/**\r
97 Retrieve the subject bytes from one X.509 certificate.\r
98\r
99 Return FALSE to indicate this interface is not supported.\r
100\r
101 @param[in] Cert Pointer to the DER-encoded X509 certificate.\r
102 @param[in] CertSize Size of the X509 certificate in bytes.\r
103 @param[out] CertSubject Pointer to the retrieved certificate subject bytes.\r
104 @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,\r
105 and the size of buffer returned CertSubject on output.\r
106\r
107\r
108 @retval FALSE This interface is not supported.\r
109\r
110**/\r
111BOOLEAN\r
112EFIAPI\r
113X509GetSubjectName (\r
114 IN CONST UINT8 *Cert,\r
115 IN UINTN CertSize,\r
116 OUT UINT8 *CertSubject,\r
117 IN OUT UINTN *SubjectSize\r
118 )\r
119{\r
120 ASSERT (FALSE);\r
121 return FALSE;\r
122}\r
123\r
5b7c2245
QL
124/**\r
125 Retrieve the common name (CN) string from one X.509 certificate.\r
126\r
127 Return RETURN_UNSUPPORTED to indicate this interface is not supported.\r
128\r
129 @param[in] Cert Pointer to the DER-encoded X509 certificate.\r
130 @param[in] CertSize Size of the X509 certificate in bytes.\r
131 @param[out] CommonName Buffer to contain the retrieved certificate common\r
0b6457ef 132 name string (UTF8). At most CommonNameSize bytes will be\r
5b7c2245
QL
133 written and the string will be null terminated. May be\r
134 NULL in order to determine the size buffer needed.\r
135 @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,\r
136 and the size of buffer returned CommonName on output.\r
137 If CommonName is NULL then the amount of space needed\r
138 in buffer (including the final null) is returned.\r
139\r
140 @retval RETURN_UNSUPPORTED The operation is not supported.\r
141\r
142**/\r
143RETURN_STATUS\r
144EFIAPI\r
145X509GetCommonName (\r
146 IN CONST UINT8 *Cert,\r
147 IN UINTN CertSize,\r
148 OUT CHAR8 *CommonName, OPTIONAL\r
149 IN OUT UINTN *CommonNameSize\r
150 )\r
151{\r
152 ASSERT (FALSE);\r
153 return RETURN_UNSUPPORTED;\r
154}\r
155\r
912e1e1e
BB
156/**\r
157 Retrieve the organization name (ON) string from one X.509 certificate.\r
158\r
159 Return RETURN_UNSUPPORTED to indicate this interface is not supported.\r
160\r
161 @param[in] Cert Pointer to the DER-encoded X509 certificate.\r
162 @param[in] CertSize Size of the X509 certificate in bytes.\r
163 @param[out] NameBuffer Buffer to contain the retrieved certificate organization\r
164 name string. At most NameBufferSize bytes will be\r
165 written and the string will be null terminated. May be\r
166 NULL in order to determine the size buffer needed.\r
167 @param[in,out] NameBufferSize The size in bytes of the Name buffer on input,\r
168 and the size of buffer returned Name on output.\r
169 If NameBuffer is NULL then the amount of space needed\r
170 in buffer (including the final null) is returned.\r
171\r
172 @retval RETURN_UNSUPPORTED The operation is not supported.\r
173\r
174**/\r
175RETURN_STATUS\r
176EFIAPI\r
177X509GetOrganizationName (\r
178 IN CONST UINT8 *Cert,\r
179 IN UINTN CertSize,\r
180 OUT CHAR8 *NameBuffer, OPTIONAL\r
181 IN OUT UINTN *NameBufferSize\r
182 )\r
183{\r
184 ASSERT (FALSE);\r
185 return RETURN_UNSUPPORTED;\r
186}\r
187\r
532616bb 188/**\r
189 Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r
190\r
191 Return FALSE to indicate this interface is not supported.\r
192\r
193 @param[in] Cert Pointer to the DER-encoded X509 certificate.\r
194 @param[in] CertSize Size of the X509 certificate in bytes.\r
195 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r
196 RSA public key component. Use RsaFree() function to free the\r
197 resource.\r
198\r
199 @retval FALSE This interface is not supported.\r
200\r
201**/\r
202BOOLEAN\r
203EFIAPI\r
204RsaGetPublicKeyFromX509 (\r
205 IN CONST UINT8 *Cert,\r
206 IN UINTN CertSize,\r
207 OUT VOID **RsaContext\r
208 )\r
209{\r
210 ASSERT (FALSE);\r
211 return FALSE;\r
212}\r
213\r
214/**\r
215 Verify one X509 certificate was issued by the trusted CA.\r
216\r
217 Return FALSE to indicate this interface is not supported.\r
218\r
219 @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.\r
220 @param[in] CertSize Size of the X509 certificate in bytes.\r
221 @param[in] CACert Pointer to the DER-encoded trusted CA certificate.\r
222 @param[in] CACertSize Size of the CA Certificate in bytes.\r
223\r
224 @retval FALSE This interface is not supported.\r
630f67dd 225\r
532616bb 226**/\r
227BOOLEAN\r
228EFIAPI\r
229X509VerifyCert (\r
230 IN CONST UINT8 *Cert,\r
231 IN UINTN CertSize,\r
232 IN CONST UINT8 *CACert,\r
233 IN UINTN CACertSize\r
234 )\r
235{\r
236 ASSERT (FALSE);\r
237 return FALSE;\r
238}\r
12d95665
LQ
239\r
240/**\r
241 Retrieve the TBSCertificate from one given X.509 certificate.\r
242\r
243 Return FALSE to indicate this interface is not supported.\r
244\r
245 @param[in] Cert Pointer to the given DER-encoded X509 certificate.\r
246 @param[in] CertSize Size of the X509 certificate in bytes.\r
247 @param[out] TBSCert DER-Encoded To-Be-Signed certificate.\r
248 @param[out] TBSCertSize Size of the TBS certificate in bytes.\r
249\r
250 @retval FALSE This interface is not supported.\r
251\r
252**/\r
253BOOLEAN\r
254EFIAPI\r
255X509GetTBSCert (\r
256 IN CONST UINT8 *Cert,\r
257 IN UINTN CertSize,\r
258 OUT UINT8 **TBSCert,\r
259 OUT UINTN *TBSCertSize\r
260 )\r
261{\r
262 ASSERT (FALSE);\r
263 return FALSE;\r
264}\r