x509_common.c
Go to the documentation of this file.
1 /**
2  * @file x509_common.c
3  * @brief X.509 common definitions
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.8
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "pkix/x509_common.h"
37 #include "encoding/asn1.h"
38 #include "encoding/oid.h"
39 #include "hash/hash_algorithms.h"
40 #include "debug.h"
41 
42 //Check crypto library configuration
43 #if (X509_SUPPORT == ENABLED || PEM_SUPPORT == ENABLED)
44 
45 //Common Name OID (2.5.4.3)
46 const uint8_t X509_COMMON_NAME_OID[3] = {0x55, 0x04, 0x03};
47 //Surname OID (2.5.4.4)
48 const uint8_t X509_SURNAME_OID[3] = {0x55, 0x04, 0x04};
49 //Serial Number OID (2.5.4.5)
50 const uint8_t X509_SERIAL_NUMBER_OID[3] = {0x55, 0x04, 0x05};
51 //Country Name OID (2.5.4.6)
52 const uint8_t X509_COUNTRY_NAME_OID[3] = {0x55, 0x04, 0x06};
53 //Locality Name OID (2.5.4.7)
54 const uint8_t X509_LOCALITY_NAME_OID[3] = {0x55, 0x04, 0x07};
55 //State Or Province Name OID (2.5.4.8)
56 const uint8_t X509_STATE_OR_PROVINCE_NAME_OID[] = {0x55, 0x04, 0x08};
57 //Organization Name OID (2.5.4.10)
58 const uint8_t X509_ORGANIZATION_NAME_OID[3] = {0x55, 0x04, 0x0A};
59 //Organizational Unit Name OID (2.5.4.11)
60 const uint8_t X509_ORGANIZATIONAL_UNIT_NAME_OID[3] = {0x55, 0x04, 0x0B};
61 //Title OID (2.5.4.12)
62 const uint8_t X509_TITLE_OID[3] = {0x55, 0x04, 0x0C};
63 //Name OID (2.5.4.41)
64 const uint8_t X509_NAME_OID[3] = {0x55, 0x04, 0x29};
65 //Given Name OID (2.5.4.42)
66 const uint8_t X509_GIVEN_NAME_OID[3] = {0x55, 0x04, 0x2A};
67 //Initials OID (2.5.4.43)
68 const uint8_t X509_INITIALS_OID[3] = {0x55, 0x04, 0x2B};
69 //Generation Qualifier OID (2.5.4.44)
70 const uint8_t X509_GENERATION_QUALIFIER_OID[3] = {0x55, 0x04, 0x2C};
71 //DN Qualifier OID (2.5.4.46)
72 const uint8_t X509_DN_QUALIFIER_OID[3] = {0x55, 0x04, 0x2E};
73 //Pseudonym OID (2.5.4.65)
74 const uint8_t X509_PSEUDONYM_OID[3] = {0x55, 0x04, 0x41};
75 //Domain Component OID (0.9.2342.19200300.100.1.25)
76 const uint8_t X509_DOMAIN_COMPONENT_OID[10] = {0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19};
77 
78 //Subject Directory Attributes OID (2.5.29.9)
79 const uint8_t X509_SUBJECT_DIR_ATTR_OID[3] = {0x55, 0x1D, 0x09};
80 //Subject Key Identifier OID (2.5.29.14)
81 const uint8_t X509_SUBJECT_KEY_ID_OID[3] = {0x55, 0x1D, 0x0E};
82 //Key Usage OID (2.5.29.15)
83 const uint8_t X509_KEY_USAGE_OID[3] = {0x55, 0x1D, 0x0F};
84 //Subject Alternative Name OID (2.5.29.17)
85 const uint8_t X509_SUBJECT_ALT_NAME_OID[3] = {0x55, 0x1D, 0x11};
86 //Issuer Alternative Name OID (2.5.29.18)
87 const uint8_t X509_ISSUER_ALT_NAME_OID[3] = {0x55, 0x1D, 0x12};
88 //Basic Constraints OID (2.5.29.19)
89 const uint8_t X509_BASIC_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x13};
90 //CRL Number OID (2.5.29.20)
91 const uint8_t X509_CRL_NUMBER_OID[3] = {0x55, 0x1D, 0x14};
92 //Reason Code OID (2.5.29.21)
93 const uint8_t X509_REASON_CODE_OID[3] = {0x55, 0x1D, 0x15};
94 //Invalidity Date OID (2.5.29.24)
95 const uint8_t X509_INVALIDITY_DATE_OID[3] = {0x55, 0x1D, 0x18};
96 //Delta CRL Indicator OID (2.5.29.27)
97 const uint8_t X509_DELTA_CRL_INDICATOR_OID[3] = {0x55, 0x1D, 0x1B};
98 //Issuing Distribution Point OID (2.5.29.28)
99 const uint8_t X509_ISSUING_DISTR_POINT_OID[3] = {0x55, 0x1D, 0x1C};
100 //Certificate Issuer OID (2.5.29.29)
101 const uint8_t X509_CERTIFICATE_ISSUER_OID[3] = {0x55, 0x1D, 0x1D};
102 //Name Constraints OID (2.5.29.30)
103 const uint8_t X509_NAME_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x1E};
104 //CRL Distribution Points OID (2.5.29.31)
105 const uint8_t X509_CRL_DISTR_POINTS_OID[3] = {0x55, 0x1D, 0x1F};
106 //Certificate Policies OID (2.5.29.32)
107 const uint8_t X509_CERTIFICATE_POLICIES_OID[3] = {0x55, 0x1D, 0x20};
108 //Policy Mappings OID (2.5.29.33)
109 const uint8_t X509_POLICY_MAPPINGS_OID[3] = {0x55, 0x1D, 0x21};
110 //Authority Key Identifier OID (2.5.29.35)
111 const uint8_t X509_AUTHORITY_KEY_ID_OID[3] = {0x55, 0x1D, 0x23};
112 //Policy Constraints OID (2.5.29.36)
113 const uint8_t X509_POLICY_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x24};
114 //Extended Key Usage OID (2.5.29.37)
115 const uint8_t X509_EXTENDED_KEY_USAGE_OID[3] = {0x55, 0x1D, 0x25};
116 //Freshest CRL OID (2.5.29.46)
117 const uint8_t X509_FRESHEST_CRL_OID[3] = {0x55, 0x1D, 0x2E};
118 //Inhibit Any-Policy OID (2.5.29.54)
119 const uint8_t X509_INHIBIT_ANY_POLICY_OID[3] = {0x55, 0x1D, 0x36};
120 //Authority Information Access OID (1.3.6.1.5.5.7.1.1)
121 const uint8_t X509_AUTH_INFO_ACCESS_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x01};
122 //PKIX OCSP No Check OID (1.3.6.1.5.5.7.48.1.5)
123 const uint8_t X509_PKIX_OCSP_NO_CHECK_OID[9] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x05};
124 //Netscape Certificate Type OID (2.16.840.1.113730.1.1)
125 const uint8_t X509_NS_CERT_TYPE_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x86, 0xF8, 0x42, 0x01, 0x01};
126 
127 //Any Extended Key Usage OID (2.5.29.37.0)
128 const uint8_t X509_ANY_EXT_KEY_USAGE_OID[4] = {0x55, 0x1D, 0x25, 0x00};
129 //Key Purpose Server Auth OID (1.3.6.1.5.5.7.3.1)
130 const uint8_t X509_KP_SERVER_AUTH_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01};
131 //Key Purpose Client Auth OID (1.3.6.1.5.5.7.3.2)
132 const uint8_t X509_KP_CLIENT_AUTH_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02};
133 //Key Purpose Code Signing OID (1.3.6.1.5.5.7.3.3)
134 const uint8_t X509_KP_CODE_SIGNING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x03};
135 //Key Purpose Email Protection OID (1.3.6.1.5.5.7.3.4)
136 const uint8_t X509_KP_EMAIL_PROTECTION_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x04};
137 //Key Purpose IPsec End System OID (1.3.6.1.5.5.7.3.5)
138 const uint8_t X509_KP_IPSEC_END_SYSTEM_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x05};
139 //Key Purpose IPsec Tunnel OID (1.3.6.1.5.5.7.3.6)
140 const uint8_t X509_KP_IPSEC_TUNNEL_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x06};
141 //Key Purpose IPsec User OID (1.3.6.1.5.5.7.3.7)
142 const uint8_t X509_KP_IPSEC_USER_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x07};
143 //Key Purpose Time Stamping OID (1.3.6.1.5.5.7.3.8)
144 const uint8_t X509_KP_TIME_STAMPING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x08};
145 //Key Purpose OCSP Signing OID (1.3.6.1.5.5.7.3.9)
146 const uint8_t X509_KP_OCSP_SIGNING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x09};
147 //Key Purpose IPsec IKE OID (1.3.6.1.5.5.7.3.17)
148 const uint8_t X509_KP_IPSEC_IKE_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x11};
149 //Key Purpose Secure Shell Client OID (1.3.6.1.5.5.7.3.21)
150 const uint8_t X509_KP_SSH_CLIENT_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x15};
151 //Key Purpose Secure Shell Client OID (1.3.6.1.5.5.7.3.22)
152 const uint8_t X509_KP_SSH_SERVER_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x16};
153 //Key Purpose CMC Certification Authorities OID (1.3.6.1.5.5.7.3.27)
154 const uint8_t X509_KP_CMC_CA_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x1B};
155 //Key Purpose CMC Registration Authorities OID (1.3.6.1.5.5.7.3.28)
156 const uint8_t X509_KP_CMC_RA_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x1C};
157 //Key Purpose Document Signing OID (1.3.6.1.5.5.7.3.36)
158 const uint8_t X509_KP_DOC_SIGNING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x24};
159 
160 //Access Description OCSP OID (1.3.6.1.5.5.7.48.1)
161 const uint8_t X509_AD_OCSP[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01};
162 //Access Description CA Issuers OID (1.3.6.1.5.5.7.48.2)
163 const uint8_t X509_AD_CA_ISSUERS[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02};
164 
165 //PKCS #9 E-mail Address OID (1.2.840.113549.1.9.1)
166 const uint8_t PKCS9_EMAIL_ADDR_OID[9] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01};
167 //PKCS #9 Challenge Password OID (1.2.840.113549.1.9.7)
168 const uint8_t PKCS9_CHALLENGE_PASSWORD_OID[9] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x07};
169 //PKCS #9 Extension Request OID (1.2.840.113549.1.9.14)
170 const uint8_t PKCS9_EXTENSION_REQUEST_OID[9] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x0E};
171 
172 //Default certificate parsing options
174 {
175  FALSE, //Ignore unknown extensions
176  FALSE //Do not check the validity period
177 };
178 
179 
180 /**
181  * @brief Compare distinguished names
182  * @param[in] name1 Pointer to the first distinguished name
183  * @param[in] nameLen1 Length of the first distinguished name
184  * @param[in] name2 Pointer to the second distinguished name
185  * @param[in] nameLen2 Length of the second distinguished name
186  * @return Comparison result
187  **/
188 
189 bool_t x509CompareName(const uint8_t *name1, size_t nameLen1,
190  const uint8_t *name2, size_t nameLen2)
191 {
192  //Compare the length of the distinguished names
193  if(nameLen1 != nameLen2)
194  {
195  return FALSE;
196  }
197 
198  //Compare the contents of the distinguished names
199  if(osMemcmp(name1, name2, nameLen1) != 0)
200  {
201  return FALSE;
202  }
203 
204  //The distinguished names match
205  return TRUE;
206 }
207 
208 
209 /**
210  * @brief Check whether a given signature algorithm is supported
211  * @param[in] signAlgo signature algorithm
212  * @return TRUE is the signature algorithm is supported, else FALSE
213  **/
214 
216 {
217  bool_t acceptable;
218 
219  //Invalid signature algorithm?
220  if(signAlgo == X509_SIGN_ALGO_NONE)
221  {
222  acceptable = FALSE;
223  }
224 #if (X509_RSA_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
225  //RSA signature algorithm?
226  else if(signAlgo == X509_SIGN_ALGO_RSA)
227  {
228  acceptable = TRUE;
229  }
230 #endif
231 #if (X509_RSA_PSS_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
232  //RSA-PSS signature algorithm?
233  else if(signAlgo == X509_SIGN_ALGO_RSA_PSS)
234  {
235  acceptable = TRUE;
236  }
237 #endif
238 #if (X509_DSA_SUPPORT == ENABLED && DSA_SUPPORT == ENABLED)
239  //DSA signature algorithm?
240  else if(signAlgo == X509_SIGN_ALGO_DSA)
241  {
242  acceptable = TRUE;
243  }
244 #endif
245 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
246  //ECDSA signature algorithm?
247  else if(signAlgo == X509_SIGN_ALGO_ECDSA)
248  {
249  acceptable = TRUE;
250  }
251 #endif
252 #if (X509_SM2_SUPPORT == ENABLED && SM2_SUPPORT == ENABLED)
253  //SM2 signature algorithm?
254  else if(signAlgo == X509_SIGN_ALGO_SM2)
255  {
256  acceptable = TRUE;
257  }
258 #endif
259 #if (X509_ED25519_SUPPORT == ENABLED && ED25519_SUPPORT == ENABLED)
260  //Ed25519 signature algorithm?
261  else if(signAlgo == X509_SIGN_ALGO_ED25519)
262  {
263  acceptable = TRUE;
264  }
265 #endif
266 #if (X509_ED448_SUPPORT == ENABLED && ED448_SUPPORT == ENABLED)
267  //Ed448 signature algorithm?
268  else if(signAlgo == X509_SIGN_ALGO_ED448)
269  {
270  acceptable = TRUE;
271  }
272 #endif
273 #if (X509_MLDSA44_SUPPORT == ENABLED && MLDSA44_SUPPORT == ENABLED)
274  //ML-DSA-44 signature algorithm?
275  else if(signAlgo == X509_SIGN_ALGO_MLDSA44)
276  {
277  acceptable = TRUE;
278  }
279 #endif
280 #if (X509_MLDSA65_SUPPORT == ENABLED && MLDSA65_SUPPORT == ENABLED)
281  //ML-DSA-65 signature algorithm?
282  else if(signAlgo == X509_SIGN_ALGO_MLDSA65)
283  {
284  acceptable = TRUE;
285  }
286 #endif
287 #if (X509_MLDSA87_SUPPORT == ENABLED && MLDSA87_SUPPORT == ENABLED)
288  //ML-DSA-87 signature algorithm?
289  else if(signAlgo == X509_SIGN_ALGO_MLDSA87)
290  {
291  acceptable = TRUE;
292  }
293 #endif
294  //Invalid signature algorithm?
295  else
296  {
297  acceptable = FALSE;
298  }
299 
300  //Return TRUE is the signature algorithm is supported
301  return acceptable;
302 }
303 
304 
305 /**
306  * @brief Check whether a given hash algorithm is supported
307  * @param[in] hashAlgo signature hash
308  * @return TRUE is the signature hash is supported, else FALSE
309  **/
310 
312 {
313  bool_t acceptable;
314 
315  //Invalid hash algorithm?
316  if(hashAlgo == X509_HASH_ALGO_NONE)
317  {
318  acceptable = FALSE;
319  }
320 #if (X509_MD5_SUPPORT == ENABLED && MD5_SUPPORT == ENABLED)
321  //MD5 hash algorithm?
322  else if(hashAlgo == X509_HASH_ALGO_MD5)
323  {
324  acceptable = TRUE;
325  }
326 #endif
327 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
328  //SHA-1 hash algorithm?
329  else if(hashAlgo == X509_HASH_ALGO_SHA1)
330  {
331  acceptable = TRUE;
332  }
333 #endif
334 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
335  //SHA-224 hash algorithm?
336  else if(hashAlgo == X509_HASH_ALGO_SHA224)
337  {
338  acceptable = TRUE;
339  }
340 #endif
341 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
342  //SHA-256 hash algorithm?
343  else if(hashAlgo == X509_HASH_ALGO_SHA256)
344  {
345  acceptable = TRUE;
346  }
347 #endif
348 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
349  //SHA-384 hash algorithm?
350  else if(hashAlgo == X509_HASH_ALGO_SHA384)
351  {
352  acceptable = TRUE;
353  }
354 #endif
355 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
356  //SHA-512 hash algorithm?
357  else if(hashAlgo == X509_HASH_ALGO_SHA512)
358  {
359  acceptable = TRUE;
360  }
361 #endif
362 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
363  //SHA3-224 hash algorithm?
364  else if(hashAlgo == X509_HASH_ALGO_SHA3_224)
365  {
366  acceptable = TRUE;
367  }
368 #endif
369 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
370  //SHA3-256 hash algorithm?
371  else if(hashAlgo == X509_HASH_ALGO_SHA3_256)
372  {
373  acceptable = TRUE;
374  }
375 #endif
376 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
377  //SHA3-384 hash algorithm?
378  else if(hashAlgo == X509_HASH_ALGO_SHA3_384)
379  {
380  acceptable = TRUE;
381  }
382 #endif
383 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
384  //SHA3-512 hash algorithm?
385  else if(hashAlgo == X509_HASH_ALGO_SHA3_512)
386  {
387  acceptable = TRUE;
388  }
389 #endif
390 #if (X509_SHAKE128_SUPPORT == ENABLED && SHAKE128_256_SUPPORT == ENABLED)
391  //SHAKE128/256 hash algorithm?
392  else if(hashAlgo == X509_HASH_ALGO_SHAKE128_256)
393  {
394  acceptable = TRUE;
395  }
396 #endif
397 #if (X509_SHAKE256_SUPPORT == ENABLED && SHAKE256_512_SUPPORT == ENABLED)
398  //SHAKE256/512 hash algorithm?
399  else if(hashAlgo == X509_HASH_ALGO_SHAKE256_512)
400  {
401  acceptable = TRUE;
402  }
403 #endif
404 #if (X509_SM3_SUPPORT == ENABLED && SM3_SUPPORT == ENABLED)
405  //SM3 hash algorithm?
406  else if(hashAlgo == X509_HASH_ALGO_SM3)
407  {
408  acceptable = TRUE;
409  }
410 #endif
411  //Invalid hash algorithm?
412  else
413  {
414  acceptable = FALSE;
415  }
416 
417  //Return TRUE is the hash algorithm is supported
418  return acceptable;
419 }
420 
421 
422 /**
423  * @brief Check whether a given elliptic curve is supported
424  * @param[in] oid Object identifier
425  * @param[in] length Length of the OID, in bytes
426  * @return TRUE is the elliptic curve is supported, else FALSE
427  **/
428 
429 bool_t x509IsCurveSupported(const uint8_t *oid, size_t length)
430 {
431  //Return TRUE is the elliptic curve is supported
432  if(x509GetCurve(oid, length) != NULL)
433  {
434  return TRUE;
435  }
436  else
437  {
438  return FALSE;
439  }
440 }
441 
442 
443 /**
444  * @brief Get the signature and hash algorithms that match the specified
445  * identifier
446  * @param[in] signAlgoId Signature algorithm identifier
447  * @param[out] signAlgo Signature algorithm
448  * @param[out] hashAlgo Hash algorithm
449  * @return Error code
450  **/
451 
453  X509SignatureAlgo *signAlgo, const HashAlgo **hashAlgo)
454 {
455  error_t error;
456  size_t oidLen;
457  const uint8_t *oid;
458 
459  //Initialize status code
460  error = NO_ERROR;
461 
462  //Point to the object identifier
463  oid = signAlgoId->oid.value;
464  oidLen = signAlgoId->oid.length;
465 
466  //Just for sanity
467  (void) oid;
468  (void) oidLen;
469 
470 #if (X509_RSA_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
471 #if (X509_MD5_SUPPORT == ENABLED && MD5_SUPPORT == ENABLED)
472  //RSA with MD5 signature algorithm?
474  {
475  *signAlgo = X509_SIGN_ALGO_RSA;
476  *hashAlgo = MD5_HASH_ALGO;
477  }
478  else
479 #endif
480 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
481  //RSA with SHA-1 signature algorithm?
483  {
484  *signAlgo = X509_SIGN_ALGO_RSA;
485  *hashAlgo = SHA1_HASH_ALGO;
486  }
487  else
488 #endif
489 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
490  //RSA with SHA-224 signature algorithm?
492  {
493  *signAlgo = X509_SIGN_ALGO_RSA;
494  *hashAlgo = SHA224_HASH_ALGO;
495  }
496  else
497 #endif
498 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
499  //RSA with SHA-256 signature algorithm?
501  {
502  *signAlgo = X509_SIGN_ALGO_RSA;
503  *hashAlgo = SHA256_HASH_ALGO;
504  }
505  else
506 #endif
507 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
508  //RSA with SHA-384 signature algorithm?
510  {
511  *signAlgo = X509_SIGN_ALGO_RSA;
512  *hashAlgo = SHA384_HASH_ALGO;
513  }
514  else
515 #endif
516 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
517  //RSA with SHA-512 signature algorithm?
519  {
520  *signAlgo = X509_SIGN_ALGO_RSA;
521  *hashAlgo = SHA512_HASH_ALGO;
522  }
523  else
524 #endif
525 #if (X509_SHA512_224_SUPPORT == ENABLED && SHA512_224_SUPPORT == ENABLED)
526  //RSA with SHA-512/224 signature algorithm?
528  {
529  *signAlgo = X509_SIGN_ALGO_RSA;
530  *hashAlgo = SHA512_224_HASH_ALGO;
531  }
532  else
533 #endif
534 #if (X509_SHA512_256_SUPPORT == ENABLED && SHA512_256_SUPPORT == ENABLED)
535  //RSA with SHA-512/256 signature algorithm?
537  {
538  *signAlgo = X509_SIGN_ALGO_RSA;
539  *hashAlgo = SHA512_256_HASH_ALGO;
540  }
541  else
542 #endif
543 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
544  //RSA with SHA3-224 signature algorithm?
546  {
547  *signAlgo = X509_SIGN_ALGO_RSA;
548  *hashAlgo = SHA3_224_HASH_ALGO;
549  }
550  else
551 #endif
552 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
553  //RSA with SHA3-256 signature algorithm?
555  {
556  *signAlgo = X509_SIGN_ALGO_RSA;
557  *hashAlgo = SHA3_256_HASH_ALGO;
558  }
559  else
560 #endif
561 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
562  //RSA with SHA3-384 signature algorithm?
564  {
565  *signAlgo = X509_SIGN_ALGO_RSA;
566  *hashAlgo = SHA3_384_HASH_ALGO;
567  }
568  else
569 #endif
570 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
571  //RSA with SHA3-512 signature algorithm?
573  {
574  *signAlgo = X509_SIGN_ALGO_RSA;
575  *hashAlgo = SHA3_512_HASH_ALGO;
576  }
577  else
578 #endif
579 #endif
580 #if (X509_RSA_PSS_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
581  //RSA-PSS signature algorithm
582  if(OID_COMP(oid, oidLen, RSASSA_PSS_OID) == 0)
583  {
584  //Select RSA-PSS signature algorithm
585  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
586 
587  //Select hash algorithm
588  *hashAlgo = x509GetHashAlgo(signAlgoId->rsaPssParams.hashAlgo.value,
589  signAlgoId->rsaPssParams.hashAlgo.length);
590 
591  //Invalid hash algorithm?
592  if(*hashAlgo == NULL)
593  {
594  //Report an error
596  }
597  }
598  else
599 #if (X509_SHAKE128_SUPPORT == ENABLED && SHAKE128_256_SUPPORT == ENABLED)
600  //RSA-PSS with SHAKE128 signature algorithm?
602  {
603  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
604  *hashAlgo = SHAKE128_256_HASH_ALGO;
605  }
606  else
607 #endif
608 #if (X509_SHAKE256_SUPPORT == ENABLED && SHAKE256_512_SUPPORT == ENABLED)
609  //RSA-PSS with SHAKE256 signature algorithm?
611  {
612  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
613  *hashAlgo = SHAKE256_512_HASH_ALGO;
614  }
615  else
616 #endif
617 #endif
618 #if (X509_DSA_SUPPORT == ENABLED && DSA_SUPPORT == ENABLED)
619 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
620  //DSA with SHA-1 signature algorithm?
622  {
623  *signAlgo = X509_SIGN_ALGO_DSA;
624  *hashAlgo = SHA1_HASH_ALGO;
625  }
626  else
627 #endif
628 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
629  //DSA with SHA-224 signature algorithm?
631  {
632  *signAlgo = X509_SIGN_ALGO_DSA;
633  *hashAlgo = SHA224_HASH_ALGO;
634  }
635  else
636 #endif
637 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
638  //DSA with SHA-256 signature algorithm?
640  {
641  *signAlgo = X509_SIGN_ALGO_DSA;
642  *hashAlgo = SHA256_HASH_ALGO;
643  }
644  else
645 #endif
646 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
647  //DSA with SHA-384 signature algorithm?
649  {
650  *signAlgo = X509_SIGN_ALGO_DSA;
651  *hashAlgo = SHA384_HASH_ALGO;
652  }
653  else
654 #endif
655 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
656  //DSA with SHA-512 signature algorithm?
658  {
659  *signAlgo = X509_SIGN_ALGO_DSA;
660  *hashAlgo = SHA512_HASH_ALGO;
661  }
662  else
663 #endif
664 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
665  //DSA with SHA3-224 signature algorithm?
667  {
668  *signAlgo = X509_SIGN_ALGO_DSA;
669  *hashAlgo = SHA3_224_HASH_ALGO;
670  }
671  else
672 #endif
673 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
674  //DSA with SHA3-256 signature algorithm?
676  {
677  *signAlgo = X509_SIGN_ALGO_DSA;
678  *hashAlgo = SHA3_256_HASH_ALGO;
679  }
680  else
681 #endif
682 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
683  //DSA with SHA3-384 signature algorithm?
685  {
686  *signAlgo = X509_SIGN_ALGO_DSA;
687  *hashAlgo = SHA3_384_HASH_ALGO;
688  }
689  else
690 #endif
691 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
692  //DSA with SHA3-512 signature algorithm?
694  {
695  *signAlgo = X509_SIGN_ALGO_DSA;
696  *hashAlgo = SHA3_512_HASH_ALGO;
697  }
698  else
699 #endif
700 #endif
701 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
702 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
703  //ECDSA with SHA-1 signature algorithm?
705  {
706  *signAlgo = X509_SIGN_ALGO_ECDSA;
707  *hashAlgo = SHA1_HASH_ALGO;
708  }
709  else
710 #endif
711 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
712  //ECDSA with SHA-224 signature algorithm?
714  {
715  *signAlgo = X509_SIGN_ALGO_ECDSA;
716  *hashAlgo = SHA224_HASH_ALGO;
717  }
718  else
719 #endif
720 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
721  //ECDSA with SHA-256 signature algorithm?
723  {
724  *signAlgo = X509_SIGN_ALGO_ECDSA;
725  *hashAlgo = SHA256_HASH_ALGO;
726  }
727  else
728 #endif
729 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
730  //ECDSA with SHA-384 signature algorithm?
732  {
733  *signAlgo = X509_SIGN_ALGO_ECDSA;
734  *hashAlgo = SHA384_HASH_ALGO;
735  }
736  else
737 #endif
738 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
739  //ECDSA with SHA-512 signature algorithm?
741  {
742  *signAlgo = X509_SIGN_ALGO_ECDSA;
743  *hashAlgo = SHA512_HASH_ALGO;
744  }
745  else
746 #endif
747 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
748  //ECDSA with SHA3-224 signature algorithm?
750  {
751  *signAlgo = X509_SIGN_ALGO_ECDSA;
752  *hashAlgo = SHA3_224_HASH_ALGO;
753  }
754  else
755 #endif
756 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
757  //ECDSA with SHA3-256 signature algorithm?
759  {
760  *signAlgo = X509_SIGN_ALGO_ECDSA;
761  *hashAlgo = SHA3_256_HASH_ALGO;
762  }
763  else
764 #endif
765 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
766  //ECDSA with SHA3-384 signature algorithm?
768  {
769  *signAlgo = X509_SIGN_ALGO_ECDSA;
770  *hashAlgo = SHA3_384_HASH_ALGO;
771  }
772  else
773 #endif
774 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
775  //ECDSA with SHA3-512 signature algorithm?
777  {
778  *signAlgo = X509_SIGN_ALGO_ECDSA;
779  *hashAlgo = SHA3_512_HASH_ALGO;
780  }
781  else
782 #endif
783 #if (X509_SHAKE128_SUPPORT == ENABLED && SHAKE128_256_SUPPORT == ENABLED)
784  //ECDSA with SHAKE128 signature algorithm?
786  {
787  *signAlgo = X509_SIGN_ALGO_ECDSA;
788  *hashAlgo = SHAKE128_256_HASH_ALGO;
789  }
790  else
791 #endif
792 #if (X509_SHAKE256_SUPPORT == ENABLED && SHAKE256_512_SUPPORT == ENABLED)
793  //ECDSA with SHAKE256 signature algorithm?
795  {
796  *signAlgo = X509_SIGN_ALGO_ECDSA;
797  *hashAlgo = SHAKE256_512_HASH_ALGO;
798  }
799  else
800 #endif
801 #endif
802 #if (X509_SM2_SUPPORT == ENABLED && SM2_SUPPORT == ENABLED && \
803  X509_SM3_SUPPORT == ENABLED && SM3_SUPPORT == ENABLED)
804  //SM2 with SM3 signature algorithm?
805  if(OID_COMP(oid, oidLen, SM2_WITH_SM3_OID) == 0)
806  {
807  *signAlgo = X509_SIGN_ALGO_SM2;
808  *hashAlgo = SM3_HASH_ALGO;
809  }
810  else
811 #endif
812 #if (X509_ED25519_SUPPORT == ENABLED && ED25519_SUPPORT == ENABLED)
813  //Ed25519 signature algorithm?
814  if(OID_COMP(oid, oidLen, ED25519_OID) == 0)
815  {
816  *signAlgo = X509_SIGN_ALGO_ED25519;
817  *hashAlgo = NULL;
818  }
819  else
820 #endif
821 #if (X509_ED448_SUPPORT == ENABLED && ED448_SUPPORT == ENABLED)
822  //Ed448 signature algorithm?
823  if(OID_COMP(oid, oidLen, ED448_OID) == 0)
824  {
825  *signAlgo = X509_SIGN_ALGO_ED448;
826  *hashAlgo = NULL;
827  }
828  else
829 #endif
830 #if (X509_MLDSA44_SUPPORT == ENABLED && MLDSA44_SUPPORT == ENABLED)
831  //ML-DSA-44 signature algorithm?
832  if(OID_COMP(oid, oidLen, MLDSA44_OID) == 0)
833  {
834  *signAlgo = X509_SIGN_ALGO_MLDSA44;
835  *hashAlgo = NULL;
836  }
837  else
838 #endif
839 #if (X509_MLDSA65_SUPPORT == ENABLED && MLDSA65_SUPPORT == ENABLED)
840  //ML-DSA-65 signature algorithm?
841  if(OID_COMP(oid, oidLen, MLDSA65_OID) == 0)
842  {
843  *signAlgo = X509_SIGN_ALGO_MLDSA65;
844  *hashAlgo = NULL;
845  }
846  else
847 #endif
848 #if (X509_MLDSA87_SUPPORT == ENABLED && MLDSA87_SUPPORT == ENABLED)
849  //ML-DSA-87 signature algorithm?
850  if(OID_COMP(oid, oidLen, MLDSA87_OID) == 0)
851  {
852  *signAlgo = X509_SIGN_ALGO_MLDSA87;
853  *hashAlgo = NULL;
854  }
855  else
856 #endif
857  //Unknown signature algorithm?
858  {
860  }
861 
862  //Return status code
863  return error;
864 }
865 
866 
867 /**
868  * @brief Get the public key type that matches the specified OID
869  * @param[in] oid Object identifier
870  * @param[in] length OID length
871  * @return Public key type
872  **/
873 
875 {
876  X509KeyType keyType;
877 
878  //Invalid parameters?
879  if(oid == NULL || length == 0)
880  {
881  keyType = X509_KEY_TYPE_UNKNOWN;
882  }
883 #if (RSA_SUPPORT == ENABLED)
884  //RSA algorithm identifier?
885  else if(OID_COMP(oid, length, RSA_ENCRYPTION_OID) == 0)
886  {
887  keyType = X509_KEY_TYPE_RSA;
888  }
889  //RSA-PSS algorithm identifier?
890  else if(OID_COMP(oid, length, RSASSA_PSS_OID) == 0)
891  {
892  keyType = X509_KEY_TYPE_RSA_PSS;
893  }
894 #endif
895 #if (DSA_SUPPORT == ENABLED)
896  //DSA algorithm identifier?
897  else if(OID_COMP(oid, length, DSA_OID) == 0)
898  {
899  keyType = X509_KEY_TYPE_DSA;
900  }
901 #endif
902 #if (EC_SUPPORT == ENABLED)
903  //EC public key identifier?
904  else if(OID_COMP(oid, length, EC_PUBLIC_KEY_OID) == 0)
905  {
906  keyType = X509_KEY_TYPE_EC;
907  }
908 #endif
909 #if (X25519_SUPPORT == ENABLED)
910  //X25519 algorithm identifier?
911  else if(OID_COMP(oid, length, X25519_OID) == 0)
912  {
913  keyType = X509_KEY_TYPE_X25519;
914  }
915 #endif
916 #if (ED25519_SUPPORT == ENABLED)
917  //Ed25519 algorithm identifier?
918  else if(OID_COMP(oid, length, ED25519_OID) == 0)
919  {
920  keyType = X509_KEY_TYPE_ED25519;
921  }
922 #endif
923 #if (X448_SUPPORT == ENABLED)
924  //X448 algorithm identifier?
925  else if(OID_COMP(oid, length, X448_OID) == 0)
926  {
927  keyType = X509_KEY_TYPE_X448;
928  }
929 #endif
930 #if (ED448_SUPPORT == ENABLED)
931  //Ed448 algorithm identifier?
932  else if(OID_COMP(oid, length, ED448_OID) == 0)
933  {
934  keyType = X509_KEY_TYPE_ED448;
935  }
936 #endif
937 #if (MLDSA44_SUPPORT == ENABLED)
938  //ML-DSA-44 algorithm identifier?
939  else if(OID_COMP(oid, length, MLDSA44_OID) == 0)
940  {
941  keyType = X509_KEY_TYPE_MLDSA44;
942  }
943 #endif
944 #if (MLDSA65_SUPPORT == ENABLED)
945  //ML-DSA-65 algorithm identifier?
946  else if(OID_COMP(oid, length, MLDSA65_OID) == 0)
947  {
948  keyType = X509_KEY_TYPE_MLDSA65;
949  }
950 #endif
951 #if (MLDSA87_SUPPORT == ENABLED)
952  //ML-DSA-87 algorithm identifier?
953  else if(OID_COMP(oid, length, MLDSA87_OID) == 0)
954  {
955  keyType = X509_KEY_TYPE_MLDSA87;
956  }
957 #endif
958  //Unknown algorithm identifier?
959  else
960  {
961  keyType = X509_KEY_TYPE_UNKNOWN;
962  }
963 
964  //Return public key type
965  return keyType;
966 }
967 
968 
969 /**
970  * @brief Get the hash algorithms that match the specified identifier
971  * @param[in] oid Object identifier
972  * @param[in] length Length of the OID, in bytes
973  * @return Hash algorithm
974  **/
975 
976 const HashAlgo *x509GetHashAlgo(const uint8_t *oid, size_t length)
977 {
978  const HashAlgo *hashAlgo;
979 
980 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
981  //SHA-1 hash algorithm identifier?
982  if(OID_COMP(oid, length, SHA1_OID) == 0)
983  {
984  hashAlgo = SHA1_HASH_ALGO;
985  }
986  else
987 #endif
988 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
989  //SHA-224 hash algorithm identifier?
990  if(OID_COMP(oid, length, SHA224_OID) == 0)
991  {
992  hashAlgo = SHA224_HASH_ALGO;
993  }
994  else
995 #endif
996 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
997  //SHA-256 hash algorithm identifier?
998  if(OID_COMP(oid, length, SHA256_OID) == 0)
999  {
1000  hashAlgo = SHA256_HASH_ALGO;
1001  }
1002  else
1003 #endif
1004 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
1005  //SHA-384 hash algorithm identifier?
1006  if(OID_COMP(oid, length, SHA384_OID) == 0)
1007  {
1008  hashAlgo = SHA384_HASH_ALGO;
1009  }
1010  else
1011 #endif
1012 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
1013  //SHA-512 hash algorithm identifier?
1014  if(OID_COMP(oid, length, SHA512_OID) == 0)
1015  {
1016  hashAlgo = SHA512_HASH_ALGO;
1017  }
1018  else
1019 #endif
1020 #if (X509_SHA512_224_SUPPORT == ENABLED && SHA512_224_SUPPORT == ENABLED)
1021  //SHA-512/224 hash algorithm identifier?
1023  {
1024  hashAlgo = SHA512_224_HASH_ALGO;
1025  }
1026  else
1027 #endif
1028 #if (X509_SHA512_256_SUPPORT == ENABLED && SHA512_256_SUPPORT == ENABLED)
1029  //SHA-512/256 hash algorithm identifier?
1031  {
1032  hashAlgo = SHA512_256_HASH_ALGO;
1033  }
1034  else
1035 #endif
1036 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
1037  //SHA3-224 hash algorithm identifier?
1038  if(OID_COMP(oid, length, SHA3_224_OID) == 0)
1039  {
1040  hashAlgo = SHA3_224_HASH_ALGO;
1041  }
1042  else
1043 #endif
1044 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
1045  //SHA3-256 hash algorithm identifier?
1046  if(OID_COMP(oid, length, SHA3_256_OID) == 0)
1047  {
1048  hashAlgo = SHA3_256_HASH_ALGO;
1049  }
1050  else
1051 #endif
1052 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
1053  //SHA3-384 hash algorithm identifier?
1054  if(OID_COMP(oid, length, SHA3_384_OID) == 0)
1055  {
1056  hashAlgo = SHA3_384_HASH_ALGO;
1057  }
1058  else
1059 #endif
1060 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
1061  //SHA3-512 hash algorithm identifier?
1062  if(OID_COMP(oid, length, SHA3_512_OID) == 0)
1063  {
1064  hashAlgo = SHA3_512_HASH_ALGO;
1065  }
1066  else
1067 #endif
1068  //Unknown hash algorithm identifier?
1069  {
1070  hashAlgo = NULL;
1071  }
1072 
1073  //Return the hash algorithm
1074  return hashAlgo;
1075 }
1076 
1077 
1078 /**
1079  * @brief Get the elliptic curve that matches the specified OID
1080  * @param[in] oid Object identifier
1081  * @param[in] length Length of the OID, in bytes
1082  * @return Elliptic curve parameters
1083  **/
1084 
1085 const EcCurve *x509GetCurve(const uint8_t *oid, size_t length)
1086 {
1087  const EcCurve *curve;
1088 
1089  //Default elliptic curve parameters
1090  curve = NULL;
1091 
1092 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
1093  //Invalid parameters?
1094  if(oid == NULL || length == 0)
1095  {
1096  curve = NULL;
1097  }
1098 #if (X509_SECP112R1_SUPPORT == ENABLED)
1099  //secp112r1 elliptic curve?
1100  else if(OID_COMP(oid, length, SECP112R1_OID) == 0)
1101  {
1102  curve = ecGetCurve(oid, length);
1103  }
1104 #endif
1105 #if (X509_SECP112R2_SUPPORT == ENABLED)
1106  //secp112r2 elliptic curve?
1107  else if(OID_COMP(oid, length, SECP112R2_OID) == 0)
1108  {
1109  curve = ecGetCurve(oid, length);
1110  }
1111 #endif
1112 #if (X509_SECP128R1_SUPPORT == ENABLED)
1113  //secp128r1 elliptic curve?
1114  else if(OID_COMP(oid, length, SECP128R1_OID) == 0)
1115  {
1116  curve = ecGetCurve(oid, length);
1117  }
1118 #endif
1119 #if (X509_SECP128R2_SUPPORT == ENABLED)
1120  //secp128r2 elliptic curve?
1121  else if(OID_COMP(oid, length, SECP128R2_OID) == 0)
1122  {
1123  curve = ecGetCurve(oid, length);
1124  }
1125 #endif
1126 #if (X509_SECP160K1_SUPPORT == ENABLED)
1127  //secp160k1 elliptic curve?
1128  else if(OID_COMP(oid, length, SECP160K1_OID) == 0)
1129  {
1130  curve = ecGetCurve(oid, length);
1131  }
1132 #endif
1133 #if (X509_SECP160R1_SUPPORT == ENABLED)
1134  //secp160r1 elliptic curve?
1135  else if(OID_COMP(oid, length, SECP160R1_OID) == 0)
1136  {
1137  curve = ecGetCurve(oid, length);
1138  }
1139 #endif
1140 #if (X509_SECP160R2_SUPPORT == ENABLED)
1141  //secp160r2 elliptic curve?
1142  else if(OID_COMP(oid, length, SECP160R2_OID) == 0)
1143  {
1144  curve = ecGetCurve(oid, length);
1145  }
1146 #endif
1147 #if (X509_SECP192K1_SUPPORT == ENABLED)
1148  //secp192k1 elliptic curve?
1149  else if(OID_COMP(oid, length, SECP192K1_OID) == 0)
1150  {
1151  curve = ecGetCurve(oid, length);
1152  }
1153 #endif
1154 #if (X509_SECP192R1_SUPPORT == ENABLED)
1155  //secp192r1 elliptic curve?
1156  else if(OID_COMP(oid, length, SECP192R1_OID) == 0)
1157  {
1158  curve = ecGetCurve(oid, length);
1159  }
1160 #endif
1161 #if (X509_SECP224K1_SUPPORT == ENABLED)
1162  //secp224k1 elliptic curve?
1163  else if(OID_COMP(oid, length, SECP224K1_OID) == 0)
1164  {
1165  curve = ecGetCurve(oid, length);
1166  }
1167 #endif
1168 #if (X509_SECP224R1_SUPPORT == ENABLED)
1169  //secp224r1 elliptic curve?
1170  else if(OID_COMP(oid, length, SECP224R1_OID) == 0)
1171  {
1172  curve = ecGetCurve(oid, length);
1173  }
1174 #endif
1175 #if (X509_SECP256K1_SUPPORT == ENABLED)
1176  //secp256k1 elliptic curve?
1177  else if(OID_COMP(oid, length, SECP256K1_OID) == 0)
1178  {
1179  curve = ecGetCurve(oid, length);
1180  }
1181 #endif
1182 #if (X509_SECP256R1_SUPPORT == ENABLED)
1183  //secp256r1 elliptic curve?
1184  else if(OID_COMP(oid, length, SECP256R1_OID) == 0)
1185  {
1186  curve = ecGetCurve(oid, length);
1187  }
1188 #endif
1189 #if (X509_SECP384R1_SUPPORT == ENABLED)
1190  //secp384r1 elliptic curve?
1191  else if(OID_COMP(oid, length, SECP384R1_OID) == 0)
1192  {
1193  curve = ecGetCurve(oid, length);
1194  }
1195 #endif
1196 #if (X509_SECP521R1_SUPPORT == ENABLED)
1197  //secp521r1 elliptic curve?
1198  else if(OID_COMP(oid, length, SECP521R1_OID) == 0)
1199  {
1200  curve = ecGetCurve(oid, length);
1201  }
1202 #endif
1203 #if (X509_BRAINPOOLP160R1_SUPPORT == ENABLED)
1204  //brainpoolP160r1 elliptic curve?
1205  else if(OID_COMP(oid, length, BRAINPOOLP160R1_OID) == 0)
1206  {
1207  curve = ecGetCurve(oid, length);
1208  }
1209 #endif
1210 #if (X509_BRAINPOOLP160T1_SUPPORT == ENABLED)
1211  //brainpoolP160t1 elliptic curve?
1212  else if(OID_COMP(oid, length, BRAINPOOLP160T1_OID) == 0)
1213  {
1214  curve = ecGetCurve(oid, length);
1215  }
1216 #endif
1217 #if (X509_BRAINPOOLP192R1_SUPPORT == ENABLED)
1218  //brainpoolP192r1 elliptic curve?
1219  else if(OID_COMP(oid, length, BRAINPOOLP192R1_OID) == 0)
1220  {
1221  curve = ecGetCurve(oid, length);
1222  }
1223 #endif
1224 #if (X509_BRAINPOOLP192T1_SUPPORT == ENABLED)
1225  //brainpoolP192t1 elliptic curve?
1226  else if(OID_COMP(oid, length, BRAINPOOLP192T1_OID) == 0)
1227  {
1228  curve = ecGetCurve(oid, length);
1229  }
1230 #endif
1231 #if (X509_BRAINPOOLP224R1_SUPPORT == ENABLED)
1232  //brainpoolP224r1 elliptic curve?
1233  else if(OID_COMP(oid, length, BRAINPOOLP224R1_OID) == 0)
1234  {
1235  curve = ecGetCurve(oid, length);
1236  }
1237 #endif
1238 #if (X509_BRAINPOOLP224T1_SUPPORT == ENABLED)
1239  //brainpoolP224t1 elliptic curve?
1240  else if(OID_COMP(oid, length, BRAINPOOLP224T1_OID) == 0)
1241  {
1242  curve = ecGetCurve(oid, length);
1243  }
1244 #endif
1245 #if (X509_BRAINPOOLP256R1_SUPPORT == ENABLED)
1246  //brainpoolP256r1 elliptic curve?
1247  else if(OID_COMP(oid, length, BRAINPOOLP256R1_OID) == 0)
1248  {
1249  curve = ecGetCurve(oid, length);
1250  }
1251 #endif
1252 #if (X509_BRAINPOOLP256T1_SUPPORT == ENABLED)
1253  //brainpoolP256t1 elliptic curve?
1254  else if(OID_COMP(oid, length, BRAINPOOLP256T1_OID) == 0)
1255  {
1256  curve = ecGetCurve(oid, length);
1257  }
1258 #endif
1259 #if (X509_BRAINPOOLP320R1_SUPPORT == ENABLED)
1260  //brainpoolP320r1 elliptic curve?
1261  else if(OID_COMP(oid, length, BRAINPOOLP320R1_OID) == 0)
1262  {
1263  curve = ecGetCurve(oid, length);
1264  }
1265 #endif
1266 #if (X509_BRAINPOOLP320T1_SUPPORT == ENABLED)
1267  //brainpoolP320t1 elliptic curve?
1268  else if(OID_COMP(oid, length, BRAINPOOLP320T1_OID) == 0)
1269  {
1270  curve = ecGetCurve(oid, length);
1271  }
1272 #endif
1273 #if (X509_BRAINPOOLP384R1_SUPPORT == ENABLED)
1274  //brainpoolP384r1 elliptic curve?
1275  else if(OID_COMP(oid, length, BRAINPOOLP384R1_OID) == 0)
1276  {
1277  curve = ecGetCurve(oid, length);
1278  }
1279 #endif
1280 #if (X509_BRAINPOOLP384T1_SUPPORT == ENABLED)
1281  //brainpoolP384t1 elliptic curve?
1282  else if(OID_COMP(oid, length, BRAINPOOLP384T1_OID) == 0)
1283  {
1284  curve = ecGetCurve(oid, length);
1285  }
1286 #endif
1287 #if (X509_BRAINPOOLP512R1_SUPPORT == ENABLED)
1288  //brainpoolP512r1 elliptic curve?
1289  else if(OID_COMP(oid, length, BRAINPOOLP512R1_OID) == 0)
1290  {
1291  curve = ecGetCurve(oid, length);
1292  }
1293 #endif
1294 #if (X509_BRAINPOOLP512T1_SUPPORT == ENABLED)
1295  //brainpoolP512t1 elliptic curve?
1296  else if(OID_COMP(oid, length, BRAINPOOLP512T1_OID) == 0)
1297  {
1298  curve = ecGetCurve(oid, length);
1299  }
1300 #endif
1301 #if (X509_FRP256V1_SUPPORT == ENABLED)
1302  //FRP256v1 elliptic curve?
1303  else if(OID_COMP(oid, length, FRP256V1_OID) == 0)
1304  {
1305  curve = ecGetCurve(oid, length);
1306  }
1307 #endif
1308 #if (X509_SM2_SUPPORT == ENABLED)
1309  //SM2 elliptic curve?
1310  else if(OID_COMP(oid, length, SM2_OID) == 0)
1311  {
1312  curve = ecGetCurve(oid, length);
1313  }
1314 #endif
1315 #if (X509_ED25519_SUPPORT == ENABLED)
1316  //Ed25519 elliptic curve?
1317  else if(OID_COMP(oid, length, ED25519_OID) == 0)
1318  {
1319  curve = ecGetCurve(oid, length);
1320  }
1321 #endif
1322 #if (X509_ED448_SUPPORT == ENABLED)
1323  //Ed448 elliptic curve?
1324  else if(OID_COMP(oid, length, ED448_OID) == 0)
1325  {
1326  curve = ecGetCurve(oid, length);
1327  }
1328 #endif
1329  //Unknown elliptic curve?
1330  else
1331  {
1332  curve = NULL;
1333  }
1334 #endif
1335 
1336  //Return the elliptic curve parameters, if any
1337  return curve;
1338 }
1339 
1340 #endif
const uint8_t X509_POLICY_MAPPINGS_OID[3]
Definition: x509_common.c:109
const uint8_t MLDSA44_OID[9]
Definition: mldsa.c:48
bool_t x509IsCurveSupported(const uint8_t *oid, size_t length)
Check whether a given elliptic curve is supported.
Definition: x509_common.c:429
#define SHA512_224_HASH_ALGO
Definition: sha512_224.h:45
#define SHA3_512_HASH_ALGO
Definition: sha3_512.h:45
X.509 common definitions.
@ X509_KEY_TYPE_RSA
Definition: x509_common.h:712
const uint8_t X509_DOMAIN_COMPONENT_OID[10]
Definition: x509_common.c:76
const uint8_t X509_CERTIFICATE_POLICIES_OID[3]
Definition: x509_common.c:107
const uint8_t RSASSA_PKCS1_V1_5_WITH_SHA3_512_OID[9]
Definition: rsa.c:82
#define SHA256_HASH_ALGO
Definition: sha256.h:49
int bool_t
Definition: compiler_port.h:63
const uint8_t X509_KP_DOC_SIGNING_OID[8]
Definition: x509_common.c:158
#define SHA1_HASH_ALGO
Definition: sha1.h:49
const uint8_t X509_KP_SERVER_AUTH_OID[8]
Definition: x509_common.c:130
const uint8_t SHA3_384_OID[9]
Definition: sha3_384.c:47
const uint8_t DSA_WITH_SHA224_OID[9]
Definition: dsa.c:55
bool_t x509IsSignAlgoSupported(X509SignatureAlgo signAlgo)
Check whether a given signature algorithm is supported.
Definition: x509_common.c:215
bool_t x509IsHashAlgoSupported(X509HashAlgo hashAlgo)
Check whether a given hash algorithm is supported.
Definition: x509_common.c:311
const uint8_t X509_ISSUER_ALT_NAME_OID[3]
Definition: x509_common.c:87
#define SHA512_HASH_ALGO
Definition: sha512.h:49
@ X509_SIGN_ALGO_MLDSA65
Definition: x509_common.h:742
const uint8_t X25519_OID[3]
Definition: ec_curves.c:108
const uint8_t MD5_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:59
const uint8_t X509_SUBJECT_ALT_NAME_OID[3]
Definition: x509_common.c:85
const uint8_t SHA512_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:69
@ X509_KEY_TYPE_X448
Definition: x509_common.h:719
const uint8_t MLDSA65_OID[9]
Definition: mldsa.c:50
const uint8_t RSASSA_PSS_SHAKE256_OID[8]
Definition: rsa.c:89
const uint8_t X509_ORGANIZATION_NAME_OID[3]
Definition: x509_common.c:58
const uint8_t RSASSA_PKCS1_V1_5_WITH_SHA3_384_OID[9]
Definition: rsa.c:80
X509OctetString hashAlgo
Definition: x509_common.h:1176
const uint8_t X509_KP_CODE_SIGNING_OID[8]
Definition: x509_common.c:134
@ X509_KEY_TYPE_MLDSA87
Definition: x509_common.h:723
OID (Object Identifier)
#define TRUE
Definition: os_port.h:50
const uint8_t RSASSA_PKCS1_V1_5_WITH_SHA3_224_OID[9]
Definition: rsa.c:76
const uint8_t BRAINPOOLP512T1_OID[9]
Definition: ec_curves.c:102
const uint8_t ECDSA_WITH_SHA3_512_OID[9]
Definition: ecdsa.c:63
const uint8_t EC_PUBLIC_KEY_OID[7]
Definition: ec.c:45
const uint8_t X509_EXTENDED_KEY_USAGE_OID[3]
Definition: x509_common.c:115
const uint8_t X509_ANY_EXT_KEY_USAGE_OID[4]
Definition: x509_common.c:128
const uint8_t SECP224R1_OID[5]
Definition: ec_curves.c:66
const uint8_t BRAINPOOLP512R1_OID[9]
Definition: ec_curves.c:100
const uint8_t X509_INVALIDITY_DATE_OID[3]
Definition: x509_common.c:95
const uint8_t BRAINPOOLP224T1_OID[9]
Definition: ec_curves.c:86
const uint8_t SECP160K1_OID[5]
Definition: ec_curves.c:54
const uint8_t X509_POLICY_CONSTRAINTS_OID[3]
Definition: x509_common.c:113
const uint8_t SECP256K1_OID[5]
Definition: ec_curves.c:68
const uint8_t ECDSA_WITH_SHA3_256_OID[9]
Definition: ecdsa.c:59
#define osMemcmp(p1, p2, length)
Definition: os_port.h:159
const uint8_t X509_KEY_USAGE_OID[3]
Definition: x509_common.c:83
const uint8_t X509_KP_TIME_STAMPING_OID[8]
Definition: x509_common.c:144
#define SM3_HASH_ALGO
Definition: sm3.h:49
const uint8_t BRAINPOOLP384R1_OID[9]
Definition: ec_curves.c:96
const uint8_t PKCS9_CHALLENGE_PASSWORD_OID[9]
Definition: x509_common.c:168
const uint8_t X509_ISSUING_DISTR_POINT_OID[3]
Definition: x509_common.c:99
const uint8_t X509_NAME_CONSTRAINTS_OID[3]
Definition: x509_common.c:103
const uint8_t RSASSA_PSS_OID[9]
Definition: rsa.c:85
const uint8_t X509_KP_OCSP_SIGNING_OID[8]
Definition: x509_common.c:146
const uint8_t X509_COUNTRY_NAME_OID[3]
Definition: x509_common.c:52
const uint8_t ECDSA_WITH_SHA256_OID[8]
Definition: ecdsa.c:51
const uint8_t BRAINPOOLP320R1_OID[9]
Definition: ec_curves.c:92
const uint8_t SECP256R1_OID[8]
Definition: ec_curves.c:70
uint8_t oid[]
Definition: lldp_tlv.h:300
const uint8_t X509_INHIBIT_ANY_POLICY_OID[3]
Definition: x509_common.c:119
const HashAlgo * x509GetHashAlgo(const uint8_t *oid, size_t length)
Get the hash algorithms that match the specified identifier.
Definition: x509_common.c:976
const uint8_t DSA_WITH_SHA3_512_OID[9]
Definition: dsa.c:69
const uint8_t X509_PSEUDONYM_OID[3]
Definition: x509_common.c:74
const uint8_t SECP224K1_OID[5]
Definition: ec_curves.c:64
const uint8_t BRAINPOOLP256T1_OID[9]
Definition: ec_curves.c:90
Certificate parsing options.
Definition: x509_common.h:1434
@ X509_SIGN_ALGO_MLDSA44
Definition: x509_common.h:741
const uint8_t X509_DELTA_CRL_INDICATOR_OID[3]
Definition: x509_common.c:97
const uint8_t ECDSA_WITH_SHAKE256_OID[8]
Definition: ecdsa.c:67
const uint8_t DSA_OID[7]
Definition: dsa.c:51
const uint8_t X509_BASIC_CONSTRAINTS_OID[3]
Definition: x509_common.c:89
const uint8_t RSASSA_PKCS1_V1_5_WITH_SHA3_256_OID[9]
Definition: rsa.c:78
#define SHA3_224_HASH_ALGO
Definition: sha3_224.h:45
const uint8_t X509_TITLE_OID[3]
Definition: x509_common.c:62
const uint8_t SHA384_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:67
const uint8_t SECP112R1_OID[5]
Definition: ec_curves.c:46
const uint8_t SECP521R1_OID[5]
Definition: ec_curves.c:74
@ X509_KEY_TYPE_EC
Definition: x509_common.h:715
const uint8_t SHA512_224_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:71
#define FALSE
Definition: os_port.h:46
X509SignatureAlgo
Signature algorithms.
Definition: x509_common.h:732
const uint8_t X509_AUTH_INFO_ACCESS_OID[8]
Definition: x509_common.c:121
const uint8_t BRAINPOOLP160R1_OID[9]
Definition: ec_curves.c:76
const X509Options X509_DEFAULT_OPTIONS
Definition: x509_common.c:173
const EcCurve * x509GetCurve(const uint8_t *oid, size_t length)
Get the elliptic curve that matches the specified OID.
Definition: x509_common.c:1085
error_t
Error codes.
Definition: error.h:43
const uint8_t DSA_WITH_SHA3_256_OID[9]
Definition: dsa.c:65
const uint8_t X509_INITIALS_OID[3]
Definition: x509_common.c:68
const uint8_t DSA_WITH_SHA384_OID[9]
Definition: dsa.c:59
const uint8_t X509_DN_QUALIFIER_OID[3]
Definition: x509_common.c:72
const uint8_t X509_SUBJECT_DIR_ATTR_OID[3]
Definition: x509_common.c:79
@ X509_SIGN_ALGO_ECDSA
Definition: x509_common.h:737
@ X509_HASH_ALGO_NONE
Definition: x509_common.h:753
const uint8_t SHA256_OID[9]
Definition: sha256.c:83
const uint8_t X509_LOCALITY_NAME_OID[3]
Definition: x509_common.c:54
const uint8_t BRAINPOOLP192T1_OID[9]
Definition: ec_curves.c:82
#define MD5_HASH_ALGO
Definition: md5.h:49
const uint8_t X509_REASON_CODE_OID[3]
Definition: x509_common.c:93
const uint8_t ECDSA_WITH_SHAKE128_OID[8]
Definition: ecdsa.c:65
const uint8_t X509_KP_EMAIL_PROTECTION_OID[8]
Definition: x509_common.c:136
const uint8_t X509_SERIAL_NUMBER_OID[3]
Definition: x509_common.c:50
const uint8_t ECDSA_WITH_SHA384_OID[8]
Definition: ecdsa.c:53
const uint8_t X509_AUTHORITY_KEY_ID_OID[3]
Definition: x509_common.c:111
#define SHAKE256_512_HASH_ALGO
Definition: shake256_512.h:45
@ X509_HASH_ALGO_SHA1
Definition: x509_common.h:755
const uint8_t SHA3_512_OID[9]
Definition: sha3_512.c:47
const uint8_t DSA_WITH_SHA512_OID[9]
Definition: dsa.c:61
const uint8_t X509_COMMON_NAME_OID[3]
Definition: x509_common.c:46
General definitions for cryptographic library.
error_t x509GetSignHashAlgo(const X509SignAlgoId *signAlgoId, X509SignatureAlgo *signAlgo, const HashAlgo **hashAlgo)
Get the signature and hash algorithms that match the specified identifier.
Definition: x509_common.c:452
const uint8_t X509_KP_IPSEC_USER_OID[8]
Definition: x509_common.c:142
const uint8_t SHA3_224_OID[9]
Definition: sha3_224.c:47
@ X509_HASH_ALGO_SHA3_224
Definition: x509_common.h:760
const uint8_t SECP128R2_OID[5]
Definition: ec_curves.c:52
const uint8_t SECP160R1_OID[5]
Definition: ec_curves.c:56
const uint8_t X509_PKIX_OCSP_NO_CHECK_OID[9]
Definition: x509_common.c:123
@ X509_KEY_TYPE_RSA_PSS
Definition: x509_common.h:713
const uint8_t X509_AD_OCSP[8]
Definition: x509_common.c:161
const uint8_t X509_KP_IPSEC_IKE_OID[8]
Definition: x509_common.c:148
@ X509_HASH_ALGO_SHA224
Definition: x509_common.h:756
@ X509_SIGN_ALGO_MLDSA87
Definition: x509_common.h:743
uint8_t length
Definition: tcp.h:375
const uint8_t X509_CRL_NUMBER_OID[3]
Definition: x509_common.c:91
const uint8_t SM2_WITH_SM3_OID[8]
Definition: sm2.c:46
X509OctetString oid
Definition: x509_common.h:1189
const uint8_t X509_CERTIFICATE_ISSUER_OID[3]
Definition: x509_common.c:101
const uint8_t ECDSA_WITH_SHA3_224_OID[9]
Definition: ecdsa.c:57
X509HashAlgo
Hash algorithms.
Definition: x509_common.h:752
const uint8_t X509_KP_CLIENT_AUTH_OID[8]
Definition: x509_common.c:132
const uint8_t ECDSA_WITH_SHA1_OID[7]
Definition: ecdsa.c:47
const uint8_t ECDSA_WITH_SHA224_OID[8]
Definition: ecdsa.c:49
@ X509_SIGN_ALGO_RSA
Definition: x509_common.h:734
const uint8_t X509_CRL_DISTR_POINTS_OID[3]
Definition: x509_common.c:105
const uint8_t SHA256_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:65
const uint8_t PKCS9_EMAIL_ADDR_OID[9]
Definition: x509_common.c:166
const uint8_t SECP192R1_OID[8]
Definition: ec_curves.c:62
const uint8_t ED448_OID[3]
Definition: ec_curves.c:114
const uint8_t ECDSA_WITH_SHA512_OID[8]
Definition: ecdsa.c:55
const uint8_t SECP384R1_OID[5]
Definition: ec_curves.c:72
Collection of hash algorithms.
const uint8_t ED25519_OID[3]
Definition: ec_curves.c:112
const uint8_t RSA_ENCRYPTION_OID[9]
Definition: rsa.c:54
const uint8_t X448_OID[3]
Definition: ec_curves.c:110
const uint8_t DSA_WITH_SHA3_384_OID[9]
Definition: dsa.c:67
@ X509_HASH_ALGO_SHA3_512
Definition: x509_common.h:763
#define SHA384_HASH_ALGO
Definition: sha384.h:45
const uint8_t BRAINPOOLP384T1_OID[9]
Definition: ec_curves.c:98
const uint8_t SECP192K1_OID[5]
Definition: ec_curves.c:60
const uint8_t X509_KP_SSH_SERVER_OID[8]
Definition: x509_common.c:152
const uint8_t DSA_WITH_SHA3_224_OID[9]
Definition: dsa.c:63
@ X509_HASH_ALGO_MD5
Definition: x509_common.h:754
const uint8_t BRAINPOOLP160T1_OID[9]
Definition: ec_curves.c:78
#define SHA3_256_HASH_ALGO
Definition: sha3_256.h:45
const uint8_t X509_FRESHEST_CRL_OID[3]
Definition: x509_common.c:117
const uint8_t SECP112R2_OID[5]
Definition: ec_curves.c:48
#define SHAKE128_256_HASH_ALGO
Definition: shake128_256.h:45
@ X509_SIGN_ALGO_RSA_PSS
Definition: x509_common.h:735
@ X509_KEY_TYPE_ED448
Definition: x509_common.h:720
@ X509_HASH_ALGO_SHA3_256
Definition: x509_common.h:761
@ X509_HASH_ALGO_SHA3_384
Definition: x509_common.h:762
const uint8_t BRAINPOOLP320T1_OID[9]
Definition: ec_curves.c:94
const uint8_t X509_NAME_OID[3]
Definition: x509_common.c:64
const uint8_t SHA3_256_OID[9]
Definition: sha3_256.c:47
#define OID_COMP(oid1, oidLen1, oid2)
Definition: oid.h:42
const uint8_t X509_AD_CA_ISSUERS[8]
Definition: x509_common.c:163
const uint8_t ECDSA_WITH_SHA3_384_OID[9]
Definition: ecdsa.c:61
@ X509_HASH_ALGO_SHA512
Definition: x509_common.h:759
@ X509_HASH_ALGO_SHAKE256_512
Definition: x509_common.h:765
@ X509_KEY_TYPE_MLDSA44
Definition: x509_common.h:721
const uint8_t X509_NS_CERT_TYPE_OID[9]
Definition: x509_common.c:125
@ X509_KEY_TYPE_DSA
Definition: x509_common.h:714
const uint8_t BRAINPOOLP224R1_OID[9]
Definition: ec_curves.c:84
const uint8_t FRP256V1_OID[10]
Definition: ec_curves.c:104
const uint8_t DSA_WITH_SHA1_OID[7]
Definition: dsa.c:53
const uint8_t DSA_WITH_SHA256_OID[9]
Definition: dsa.c:57
const uint8_t X509_GENERATION_QUALIFIER_OID[3]
Definition: x509_common.c:70
uint8_t oidLen
Definition: lldp_tlv.h:299
@ X509_HASH_ALGO_SHA384
Definition: x509_common.h:758
@ X509_HASH_ALGO_SHA256
Definition: x509_common.h:757
const uint8_t BRAINPOOLP192R1_OID[9]
Definition: ec_curves.c:80
const uint8_t SHA512_OID[9]
Definition: sha512.c:100
const uint8_t X509_KP_IPSEC_TUNNEL_OID[8]
Definition: x509_common.c:140
const uint8_t X509_KP_CMC_RA_OID[8]
Definition: x509_common.c:156
const uint8_t X509_ORGANIZATIONAL_UNIT_NAME_OID[3]
Definition: x509_common.c:60
const EcCurve * ecGetCurve(const uint8_t *oid, size_t length)
Get the elliptic curve that matches the specified OID.
Definition: ec_curves.c:5888
const uint8_t SECP160R2_OID[5]
Definition: ec_curves.c:58
const uint8_t X509_SURNAME_OID[3]
Definition: x509_common.c:48
const uint8_t SHA1_OID[5]
Definition: sha1.c:74
#define SHA512_256_HASH_ALGO
Definition: sha512_256.h:45
#define SHA224_HASH_ALGO
Definition: sha224.h:45
const uint8_t SHA224_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:63
const uint8_t X509_GIVEN_NAME_OID[3]
Definition: x509_common.c:66
const uint8_t X509_SUBJECT_KEY_ID_OID[3]
Definition: x509_common.c:81
const uint8_t * value
Definition: x509_common.h:787
Common interface for hash algorithms.
Definition: crypto.h:1266
@ X509_KEY_TYPE_UNKNOWN
Definition: x509_common.h:711
#define EcCurve
Definition: ec.h:347
const uint8_t SHA224_OID[9]
Definition: sha224.c:47
const uint8_t X509_KP_IPSEC_END_SYSTEM_OID[8]
Definition: x509_common.c:138
bool_t x509CompareName(const uint8_t *name1, size_t nameLen1, const uint8_t *name2, size_t nameLen2)
Compare distinguished names.
Definition: x509_common.c:189
@ ERROR_UNSUPPORTED_SIGNATURE_ALGO
Definition: error.h:132
@ X509_SIGN_ALGO_SM2
Definition: x509_common.h:738
@ X509_SIGN_ALGO_ED25519
Definition: x509_common.h:739
@ X509_HASH_ALGO_SHAKE128_256
Definition: x509_common.h:764
const uint8_t MLDSA87_OID[9]
Definition: mldsa.c:52
const uint8_t RSASSA_PSS_SHAKE128_OID[8]
Definition: rsa.c:87
@ X509_KEY_TYPE_ED25519
Definition: x509_common.h:718
X509KeyType
Public Key types.
Definition: x509_common.h:710
@ X509_SIGN_ALGO_NONE
Definition: x509_common.h:733
X509KeyType x509GetPublicKeyType(const uint8_t *oid, size_t length)
Get the public key type that matches the specified OID.
Definition: x509_common.c:874
const uint8_t SHA384_OID[9]
Definition: sha384.c:47
@ X509_HASH_ALGO_SM3
Definition: x509_common.h:766
@ X509_KEY_TYPE_MLDSA65
Definition: x509_common.h:722
X509RsaPssParameters rsaPssParams
Definition: x509_common.h:1191
const uint8_t X509_STATE_OR_PROVINCE_NAME_OID[]
Definition: x509_common.c:56
const uint8_t X509_KP_CMC_CA_OID[8]
Definition: x509_common.c:154
const uint8_t SHA1_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:61
const uint8_t PKCS9_EXTENSION_REQUEST_OID[9]
Definition: x509_common.c:170
#define SHA3_384_HASH_ALGO
Definition: sha3_384.h:45
Signature algorithm identifier.
Definition: x509_common.h:1188
@ NO_ERROR
Success.
Definition: error.h:44
const uint8_t SECP128R1_OID[5]
Definition: ec_curves.c:50
Debugging facilities.
const uint8_t SHA512_256_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:73
@ X509_KEY_TYPE_X25519
Definition: x509_common.h:717
ASN.1 (Abstract Syntax Notation One)
@ X509_SIGN_ALGO_DSA
Definition: x509_common.h:736
@ X509_SIGN_ALGO_ED448
Definition: x509_common.h:740
const uint8_t BRAINPOOLP256R1_OID[9]
Definition: ec_curves.c:88
const uint8_t X509_KP_SSH_CLIENT_OID[8]
Definition: x509_common.c:150
const uint8_t SM2_OID[8]
Definition: ec_curves.c:106