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