]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c
CryptoPkg/BaseCryptLib: Add new API to get organization name
[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 - 2018, 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 Return FALSE to indicate this interface is not supported.
40
41 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
42 On output, pointer to the X509 stack object with new
43 inserted X509 certificate.
44 @param ... A list of DER-encoded single certificate data followed
45 by certificate size. A NULL terminates the list. The
46 pairs are the arguments to X509ConstructCertificate().
47
48 @retval FALSE This interface is not supported.
49
50 **/
51 BOOLEAN
52 EFIAPI
53 X509ConstructCertificateStack (
54 IN OUT UINT8 **X509Stack,
55 ...
56 )
57 {
58 ASSERT (FALSE);
59 return FALSE;
60 }
61
62 /**
63 Release the specified X509 object.
64
65 If the interface is not supported, then ASSERT().
66
67 @param[in] X509Cert Pointer to the X509 object to be released.
68
69 **/
70 VOID
71 EFIAPI
72 X509Free (
73 IN VOID *X509Cert
74 )
75 {
76 ASSERT (FALSE);
77 }
78
79 /**
80 Release the specified X509 stack object.
81
82 If the interface is not supported, then ASSERT().
83
84 @param[in] X509Stack Pointer to the X509 stack object to be released.
85
86 **/
87 VOID
88 EFIAPI
89 X509StackFree (
90 IN VOID *X509Stack
91 )
92 {
93 ASSERT (FALSE);
94 }
95
96 /**
97 Retrieve the subject bytes from one X.509 certificate.
98
99 Return FALSE to indicate this interface is not supported.
100
101 @param[in] Cert Pointer to the DER-encoded X509 certificate.
102 @param[in] CertSize Size of the X509 certificate in bytes.
103 @param[out] CertSubject Pointer to the retrieved certificate subject bytes.
104 @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,
105 and the size of buffer returned CertSubject on output.
106
107
108 @retval FALSE This interface is not supported.
109
110 **/
111 BOOLEAN
112 EFIAPI
113 X509GetSubjectName (
114 IN CONST UINT8 *Cert,
115 IN UINTN CertSize,
116 OUT UINT8 *CertSubject,
117 IN OUT UINTN *SubjectSize
118 )
119 {
120 ASSERT (FALSE);
121 return FALSE;
122 }
123
124 /**
125 Retrieve the common name (CN) string from one X.509 certificate.
126
127 Return RETURN_UNSUPPORTED to indicate this interface is not supported.
128
129 @param[in] Cert Pointer to the DER-encoded X509 certificate.
130 @param[in] CertSize Size of the X509 certificate in bytes.
131 @param[out] CommonName Buffer to contain the retrieved certificate common
132 name string (UTF8). At most CommonNameSize bytes will be
133 written and the string will be null terminated. May be
134 NULL in order to determine the size buffer needed.
135 @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,
136 and the size of buffer returned CommonName on output.
137 If CommonName is NULL then the amount of space needed
138 in buffer (including the final null) is returned.
139
140 @retval RETURN_UNSUPPORTED The operation is not supported.
141
142 **/
143 RETURN_STATUS
144 EFIAPI
145 X509GetCommonName (
146 IN CONST UINT8 *Cert,
147 IN UINTN CertSize,
148 OUT CHAR8 *CommonName, OPTIONAL
149 IN OUT UINTN *CommonNameSize
150 )
151 {
152 ASSERT (FALSE);
153 return RETURN_UNSUPPORTED;
154 }
155
156 /**
157 Retrieve the organization name (ON) string from one X.509 certificate.
158
159 Return RETURN_UNSUPPORTED to indicate this interface is not supported.
160
161 @param[in] Cert Pointer to the DER-encoded X509 certificate.
162 @param[in] CertSize Size of the X509 certificate in bytes.
163 @param[out] NameBuffer Buffer to contain the retrieved certificate organization
164 name string. At most NameBufferSize bytes will be
165 written and the string will be null terminated. May be
166 NULL in order to determine the size buffer needed.
167 @param[in,out] NameBufferSize The size in bytes of the Name buffer on input,
168 and the size of buffer returned Name on output.
169 If NameBuffer is NULL then the amount of space needed
170 in buffer (including the final null) is returned.
171
172 @retval RETURN_UNSUPPORTED The operation is not supported.
173
174 **/
175 RETURN_STATUS
176 EFIAPI
177 X509GetOrganizationName (
178 IN CONST UINT8 *Cert,
179 IN UINTN CertSize,
180 OUT CHAR8 *NameBuffer, OPTIONAL
181 IN OUT UINTN *NameBufferSize
182 )
183 {
184 ASSERT (FALSE);
185 return RETURN_UNSUPPORTED;
186 }
187
188 /**
189 Retrieve the RSA Public Key from one DER-encoded X509 certificate.
190
191 Return FALSE to indicate this interface is not supported.
192
193 @param[in] Cert Pointer to the DER-encoded X509 certificate.
194 @param[in] CertSize Size of the X509 certificate in bytes.
195 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
196 RSA public key component. Use RsaFree() function to free the
197 resource.
198
199 @retval FALSE This interface is not supported.
200
201 **/
202 BOOLEAN
203 EFIAPI
204 RsaGetPublicKeyFromX509 (
205 IN CONST UINT8 *Cert,
206 IN UINTN CertSize,
207 OUT VOID **RsaContext
208 )
209 {
210 ASSERT (FALSE);
211 return FALSE;
212 }
213
214 /**
215 Verify one X509 certificate was issued by the trusted CA.
216
217 Return FALSE to indicate this interface is not supported.
218
219 @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.
220 @param[in] CertSize Size of the X509 certificate in bytes.
221 @param[in] CACert Pointer to the DER-encoded trusted CA certificate.
222 @param[in] CACertSize Size of the CA Certificate in bytes.
223
224 @retval FALSE This interface is not supported.
225
226 **/
227 BOOLEAN
228 EFIAPI
229 X509VerifyCert (
230 IN CONST UINT8 *Cert,
231 IN UINTN CertSize,
232 IN CONST UINT8 *CACert,
233 IN UINTN CACertSize
234 )
235 {
236 ASSERT (FALSE);
237 return FALSE;
238 }
239
240 /**
241 Retrieve the TBSCertificate from one given X.509 certificate.
242
243 Return FALSE to indicate this interface is not supported.
244
245 @param[in] Cert Pointer to the given DER-encoded X509 certificate.
246 @param[in] CertSize Size of the X509 certificate in bytes.
247 @param[out] TBSCert DER-Encoded To-Be-Signed certificate.
248 @param[out] TBSCertSize Size of the TBS certificate in bytes.
249
250 @retval FALSE This interface is not supported.
251
252 **/
253 BOOLEAN
254 EFIAPI
255 X509GetTBSCert (
256 IN CONST UINT8 *Cert,
257 IN UINTN CertSize,
258 OUT UINT8 **TBSCert,
259 OUT UINTN *TBSCertSize
260 )
261 {
262 ASSERT (FALSE);
263 return FALSE;
264 }