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.6
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 CA Issuers OID (1.3.6.1.5.5.7.48.1)
161 const uint8_t X509_AD_CA_ISSUERS[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01};
162 //Access Description OCSP (1.3.6.1.5.5.7.48.2)
163 const uint8_t X509_AD_OCSP[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 };
177 
178 
179 /**
180  * @brief Compare distinguished names
181  * @param[in] name1 Pointer to the first distinguished name
182  * @param[in] nameLen1 Length of the first distinguished name
183  * @param[in] name2 Pointer to the second distinguished name
184  * @param[in] nameLen2 Length of the second distinguished name
185  * @return Comparison result
186  **/
187 
188 bool_t x509CompareName(const uint8_t *name1, size_t nameLen1,
189  const uint8_t *name2, size_t nameLen2)
190 {
191  //Compare the length of the distinguished names
192  if(nameLen1 != nameLen2)
193  return FALSE;
194 
195  //Compare the contents of the distinguished names
196  if(osMemcmp(name1, name2, nameLen1))
197  return FALSE;
198 
199  //The distinguished names match
200  return TRUE;
201 }
202 
203 
204 /**
205  * @brief Check whether a given signature algorithm is supported
206  * @param[in] signAlgo signature algorithm
207  * @return TRUE is the signature algorithm is supported, else FALSE
208  **/
209 
211 {
212  bool_t acceptable;
213 
214  //Invalid signature algorithm?
215  if(signAlgo == X509_SIGN_ALGO_NONE)
216  {
217  acceptable = FALSE;
218  }
219 #if (X509_RSA_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
220  //RSA signature algorithm?
221  else if(signAlgo == X509_SIGN_ALGO_RSA)
222  {
223  acceptable = TRUE;
224  }
225 #endif
226 #if (X509_RSA_PSS_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
227  //RSA-PSS signature algorithm?
228  else if(signAlgo == X509_SIGN_ALGO_RSA_PSS)
229  {
230  acceptable = TRUE;
231  }
232 #endif
233 #if (X509_DSA_SUPPORT == ENABLED && DSA_SUPPORT == ENABLED)
234  //DSA signature algorithm?
235  else if(signAlgo == X509_SIGN_ALGO_DSA)
236  {
237  acceptable = TRUE;
238  }
239 #endif
240 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
241  //ECDSA signature algorithm?
242  else if(signAlgo == X509_SIGN_ALGO_ECDSA)
243  {
244  acceptable = TRUE;
245  }
246 #endif
247 #if (X509_SM2_SUPPORT == ENABLED && SM2_SUPPORT == ENABLED)
248  //SM2 signature algorithm?
249  else if(signAlgo == X509_SIGN_ALGO_SM2)
250  {
251  acceptable = TRUE;
252  }
253 #endif
254 #if (X509_ED25519_SUPPORT == ENABLED && ED25519_SUPPORT == ENABLED)
255  //Ed25519 signature algorithm?
256  else if(signAlgo == X509_SIGN_ALGO_ED25519)
257  {
258  acceptable = TRUE;
259  }
260 #endif
261 #if (X509_ED448_SUPPORT == ENABLED && ED448_SUPPORT == ENABLED)
262  //Ed448 signature algorithm?
263  else if(signAlgo == X509_SIGN_ALGO_ED448)
264  {
265  acceptable = TRUE;
266  }
267 #endif
268 #if (X509_MLDSA44_SUPPORT == ENABLED && MLDSA44_SUPPORT == ENABLED)
269  //ML-DSA-44 signature algorithm?
270  else if(signAlgo == X509_SIGN_ALGO_MLDSA44)
271  {
272  acceptable = TRUE;
273  }
274 #endif
275 #if (X509_MLDSA65_SUPPORT == ENABLED && MLDSA65_SUPPORT == ENABLED)
276  //ML-DSA-65 signature algorithm?
277  else if(signAlgo == X509_SIGN_ALGO_MLDSA65)
278  {
279  acceptable = TRUE;
280  }
281 #endif
282 #if (X509_MLDSA87_SUPPORT == ENABLED && MLDSA87_SUPPORT == ENABLED)
283  //ML-DSA-87 signature algorithm?
284  else if(signAlgo == X509_SIGN_ALGO_MLDSA87)
285  {
286  acceptable = TRUE;
287  }
288 #endif
289  //Invalid signature algorithm?
290  else
291  {
292  acceptable = FALSE;
293  }
294 
295  //Return TRUE is the signature algorithm is supported
296  return acceptable;
297 }
298 
299 
300 /**
301  * @brief Check whether a given hash algorithm is supported
302  * @param[in] hashAlgo signature hash
303  * @return TRUE is the signature hash is supported, else FALSE
304  **/
305 
307 {
308  bool_t acceptable;
309 
310  //Invalid hash algorithm?
311  if(hashAlgo == X509_HASH_ALGO_NONE)
312  {
313  acceptable = FALSE;
314  }
315 #if (X509_MD5_SUPPORT == ENABLED && MD5_SUPPORT == ENABLED)
316  //MD5 hash algorithm?
317  else if(hashAlgo == X509_HASH_ALGO_MD5)
318  {
319  acceptable = TRUE;
320  }
321 #endif
322 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
323  //SHA-1 hash algorithm?
324  else if(hashAlgo == X509_HASH_ALGO_SHA1)
325  {
326  acceptable = TRUE;
327  }
328 #endif
329 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
330  //SHA-224 hash algorithm?
331  else if(hashAlgo == X509_HASH_ALGO_SHA224)
332  {
333  acceptable = TRUE;
334  }
335 #endif
336 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
337  //SHA-256 hash algorithm?
338  else if(hashAlgo == X509_HASH_ALGO_SHA256)
339  {
340  acceptable = TRUE;
341  }
342 #endif
343 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
344  //SHA-384 hash algorithm?
345  else if(hashAlgo == X509_HASH_ALGO_SHA384)
346  {
347  acceptable = TRUE;
348  }
349 #endif
350 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
351  //SHA-512 hash algorithm?
352  else if(hashAlgo == X509_HASH_ALGO_SHA512)
353  {
354  acceptable = TRUE;
355  }
356 #endif
357 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
358  //SHA3-224 hash algorithm?
359  else if(hashAlgo == X509_HASH_ALGO_SHA3_224)
360  {
361  acceptable = TRUE;
362  }
363 #endif
364 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
365  //SHA3-256 hash algorithm?
366  else if(hashAlgo == X509_HASH_ALGO_SHA3_256)
367  {
368  acceptable = TRUE;
369  }
370 #endif
371 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
372  //SHA3-384 hash algorithm?
373  else if(hashAlgo == X509_HASH_ALGO_SHA3_384)
374  {
375  acceptable = TRUE;
376  }
377 #endif
378 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
379  //SHA3-512 hash algorithm?
380  else if(hashAlgo == X509_HASH_ALGO_SHA3_512)
381  {
382  acceptable = TRUE;
383  }
384 #endif
385 #if (X509_SHAKE128_SUPPORT == ENABLED && SHAKE128_256_SUPPORT == ENABLED)
386  //SHAKE128/256 hash algorithm?
387  else if(hashAlgo == X509_HASH_ALGO_SHAKE128_256)
388  {
389  acceptable = TRUE;
390  }
391 #endif
392 #if (X509_SHAKE256_SUPPORT == ENABLED && SHAKE256_512_SUPPORT == ENABLED)
393  //SHAKE256/512 hash algorithm?
394  else if(hashAlgo == X509_HASH_ALGO_SHAKE256_512)
395  {
396  acceptable = TRUE;
397  }
398 #endif
399 #if (X509_SM3_SUPPORT == ENABLED && SM3_SUPPORT == ENABLED)
400  //SM3 hash algorithm?
401  else if(hashAlgo == X509_HASH_ALGO_SM3)
402  {
403  acceptable = TRUE;
404  }
405 #endif
406  //Invalid hash algorithm?
407  else
408  {
409  acceptable = FALSE;
410  }
411 
412  //Return TRUE is the hash algorithm is supported
413  return acceptable;
414 }
415 
416 
417 /**
418  * @brief Check whether a given elliptic curve is supported
419  * @param[in] oid Object identifier
420  * @param[in] length Length of the OID, in bytes
421  * @return TRUE is the elliptic curve is supported, else FALSE
422  **/
423 
424 bool_t x509IsCurveSupported(const uint8_t *oid, size_t length)
425 {
426  //Return TRUE is the elliptic curve is supported
427  if(x509GetCurve(oid, length) != NULL)
428  {
429  return TRUE;
430  }
431  else
432  {
433  return FALSE;
434  }
435 }
436 
437 
438 /**
439  * @brief Get the signature and hash algorithms that match the specified
440  * identifier
441  * @param[in] signAlgoId Signature algorithm identifier
442  * @param[out] signAlgo Signature algorithm
443  * @param[out] hashAlgo Hash algorithm
444  * @return Error code
445  **/
446 
448  X509SignatureAlgo *signAlgo, const HashAlgo **hashAlgo)
449 {
450  error_t error;
451  size_t oidLen;
452  const uint8_t *oid;
453 
454  //Initialize status code
455  error = NO_ERROR;
456 
457  //Point to the object identifier
458  oid = signAlgoId->oid.value;
459  oidLen = signAlgoId->oid.length;
460 
461  //Just for sanity
462  (void) oid;
463  (void) oidLen;
464 
465 #if (X509_RSA_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
466 #if (X509_MD5_SUPPORT == ENABLED && MD5_SUPPORT == ENABLED)
467  //RSA with MD5 signature algorithm?
469  {
470  *signAlgo = X509_SIGN_ALGO_RSA;
471  *hashAlgo = MD5_HASH_ALGO;
472  }
473  else
474 #endif
475 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
476  //RSA with SHA-1 signature algorithm?
478  {
479  *signAlgo = X509_SIGN_ALGO_RSA;
480  *hashAlgo = SHA1_HASH_ALGO;
481  }
482  else
483 #endif
484 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
485  //RSA with SHA-224 signature algorithm?
487  {
488  *signAlgo = X509_SIGN_ALGO_RSA;
489  *hashAlgo = SHA224_HASH_ALGO;
490  }
491  else
492 #endif
493 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
494  //RSA with SHA-256 signature algorithm?
496  {
497  *signAlgo = X509_SIGN_ALGO_RSA;
498  *hashAlgo = SHA256_HASH_ALGO;
499  }
500  else
501 #endif
502 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
503  //RSA with SHA-384 signature algorithm?
505  {
506  *signAlgo = X509_SIGN_ALGO_RSA;
507  *hashAlgo = SHA384_HASH_ALGO;
508  }
509  else
510 #endif
511 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
512  //RSA with SHA-512 signature algorithm?
514  {
515  *signAlgo = X509_SIGN_ALGO_RSA;
516  *hashAlgo = SHA512_HASH_ALGO;
517  }
518  else
519 #endif
520 #if (X509_SHA512_224_SUPPORT == ENABLED && SHA512_224_SUPPORT == ENABLED)
521  //RSA with SHA-512/224 signature algorithm?
523  {
524  *signAlgo = X509_SIGN_ALGO_RSA;
525  *hashAlgo = SHA512_224_HASH_ALGO;
526  }
527  else
528 #endif
529 #if (X509_SHA512_256_SUPPORT == ENABLED && SHA512_256_SUPPORT == ENABLED)
530  //RSA with SHA-512/256 signature algorithm?
532  {
533  *signAlgo = X509_SIGN_ALGO_RSA;
534  *hashAlgo = SHA512_256_HASH_ALGO;
535  }
536  else
537 #endif
538 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
539  //RSA with SHA3-224 signature algorithm?
541  {
542  *signAlgo = X509_SIGN_ALGO_RSA;
543  *hashAlgo = SHA3_224_HASH_ALGO;
544  }
545  else
546 #endif
547 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
548  //RSA with SHA3-256 signature algorithm?
550  {
551  *signAlgo = X509_SIGN_ALGO_RSA;
552  *hashAlgo = SHA3_256_HASH_ALGO;
553  }
554  else
555 #endif
556 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
557  //RSA with SHA3-384 signature algorithm?
559  {
560  *signAlgo = X509_SIGN_ALGO_RSA;
561  *hashAlgo = SHA3_384_HASH_ALGO;
562  }
563  else
564 #endif
565 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
566  //RSA with SHA3-512 signature algorithm?
568  {
569  *signAlgo = X509_SIGN_ALGO_RSA;
570  *hashAlgo = SHA3_512_HASH_ALGO;
571  }
572  else
573 #endif
574 #endif
575 #if (X509_RSA_PSS_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
576  //RSA-PSS signature algorithm
577  if(OID_COMP(oid, oidLen, RSASSA_PSS_OID) == 0)
578  {
579  //Select RSA-PSS signature algorithm
580  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
581 
582  //Select hash algorithm
583  *hashAlgo = x509GetHashAlgo(signAlgoId->rsaPssParams.hashAlgo.value,
584  signAlgoId->rsaPssParams.hashAlgo.length);
585 
586  //Invalid hash algorithm?
587  if(*hashAlgo == NULL)
588  {
589  //Report an error
591  }
592  }
593  else
594 #if (X509_SHAKE128_SUPPORT == ENABLED && SHAKE128_256_SUPPORT == ENABLED)
595  //RSA-PSS with SHAKE128 signature algorithm?
597  {
598  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
599  *hashAlgo = SHAKE128_256_HASH_ALGO;
600  }
601  else
602 #endif
603 #if (X509_SHAKE256_SUPPORT == ENABLED && SHAKE256_512_SUPPORT == ENABLED)
604  //RSA-PSS with SHAKE256 signature algorithm?
606  {
607  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
608  *hashAlgo = SHAKE256_512_HASH_ALGO;
609  }
610  else
611 #endif
612 #endif
613 #if (X509_DSA_SUPPORT == ENABLED && DSA_SUPPORT == ENABLED)
614 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
615  //DSA with SHA-1 signature algorithm?
617  {
618  *signAlgo = X509_SIGN_ALGO_DSA;
619  *hashAlgo = SHA1_HASH_ALGO;
620  }
621  else
622 #endif
623 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
624  //DSA with SHA-224 signature algorithm?
626  {
627  *signAlgo = X509_SIGN_ALGO_DSA;
628  *hashAlgo = SHA224_HASH_ALGO;
629  }
630  else
631 #endif
632 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
633  //DSA with SHA-256 signature algorithm?
635  {
636  *signAlgo = X509_SIGN_ALGO_DSA;
637  *hashAlgo = SHA256_HASH_ALGO;
638  }
639  else
640 #endif
641 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
642  //DSA with SHA-384 signature algorithm?
644  {
645  *signAlgo = X509_SIGN_ALGO_DSA;
646  *hashAlgo = SHA384_HASH_ALGO;
647  }
648  else
649 #endif
650 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
651  //DSA with SHA-512 signature algorithm?
653  {
654  *signAlgo = X509_SIGN_ALGO_DSA;
655  *hashAlgo = SHA512_HASH_ALGO;
656  }
657  else
658 #endif
659 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
660  //DSA with SHA3-224 signature algorithm?
662  {
663  *signAlgo = X509_SIGN_ALGO_DSA;
664  *hashAlgo = SHA3_224_HASH_ALGO;
665  }
666  else
667 #endif
668 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
669  //DSA with SHA3-256 signature algorithm?
671  {
672  *signAlgo = X509_SIGN_ALGO_DSA;
673  *hashAlgo = SHA3_256_HASH_ALGO;
674  }
675  else
676 #endif
677 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
678  //DSA with SHA3-384 signature algorithm?
680  {
681  *signAlgo = X509_SIGN_ALGO_DSA;
682  *hashAlgo = SHA3_384_HASH_ALGO;
683  }
684  else
685 #endif
686 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
687  //DSA with SHA3-512 signature algorithm?
689  {
690  *signAlgo = X509_SIGN_ALGO_DSA;
691  *hashAlgo = SHA3_512_HASH_ALGO;
692  }
693  else
694 #endif
695 #endif
696 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
697 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
698  //ECDSA with SHA-1 signature algorithm?
700  {
701  *signAlgo = X509_SIGN_ALGO_ECDSA;
702  *hashAlgo = SHA1_HASH_ALGO;
703  }
704  else
705 #endif
706 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
707  //ECDSA with SHA-224 signature algorithm?
709  {
710  *signAlgo = X509_SIGN_ALGO_ECDSA;
711  *hashAlgo = SHA224_HASH_ALGO;
712  }
713  else
714 #endif
715 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
716  //ECDSA with SHA-256 signature algorithm?
718  {
719  *signAlgo = X509_SIGN_ALGO_ECDSA;
720  *hashAlgo = SHA256_HASH_ALGO;
721  }
722  else
723 #endif
724 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
725  //ECDSA with SHA-384 signature algorithm?
727  {
728  *signAlgo = X509_SIGN_ALGO_ECDSA;
729  *hashAlgo = SHA384_HASH_ALGO;
730  }
731  else
732 #endif
733 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
734  //ECDSA with SHA-512 signature algorithm?
736  {
737  *signAlgo = X509_SIGN_ALGO_ECDSA;
738  *hashAlgo = SHA512_HASH_ALGO;
739  }
740  else
741 #endif
742 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
743  //ECDSA with SHA3-224 signature algorithm?
745  {
746  *signAlgo = X509_SIGN_ALGO_ECDSA;
747  *hashAlgo = SHA3_224_HASH_ALGO;
748  }
749  else
750 #endif
751 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
752  //ECDSA with SHA3-256 signature algorithm?
754  {
755  *signAlgo = X509_SIGN_ALGO_ECDSA;
756  *hashAlgo = SHA3_256_HASH_ALGO;
757  }
758  else
759 #endif
760 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
761  //ECDSA with SHA3-384 signature algorithm?
763  {
764  *signAlgo = X509_SIGN_ALGO_ECDSA;
765  *hashAlgo = SHA3_384_HASH_ALGO;
766  }
767  else
768 #endif
769 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
770  //ECDSA with SHA3-512 signature algorithm?
772  {
773  *signAlgo = X509_SIGN_ALGO_ECDSA;
774  *hashAlgo = SHA3_512_HASH_ALGO;
775  }
776  else
777 #endif
778 #if (X509_SHAKE128_SUPPORT == ENABLED && SHAKE128_256_SUPPORT == ENABLED)
779  //ECDSA with SHAKE128 signature algorithm?
781  {
782  *signAlgo = X509_SIGN_ALGO_ECDSA;
783  *hashAlgo = SHAKE128_256_HASH_ALGO;
784  }
785  else
786 #endif
787 #if (X509_SHAKE256_SUPPORT == ENABLED && SHAKE256_512_SUPPORT == ENABLED)
788  //ECDSA with SHAKE256 signature algorithm?
790  {
791  *signAlgo = X509_SIGN_ALGO_ECDSA;
792  *hashAlgo = SHAKE256_512_HASH_ALGO;
793  }
794  else
795 #endif
796 #endif
797 #if (X509_SM2_SUPPORT == ENABLED && SM2_SUPPORT == ENABLED && \
798  X509_SM3_SUPPORT == ENABLED && SM3_SUPPORT == ENABLED)
799  //SM2 with SM3 signature algorithm?
800  if(OID_COMP(oid, oidLen, SM2_WITH_SM3_OID) == 0)
801  {
802  *signAlgo = X509_SIGN_ALGO_SM2;
803  *hashAlgo = SM3_HASH_ALGO;
804  }
805  else
806 #endif
807 #if (X509_ED25519_SUPPORT == ENABLED && ED25519_SUPPORT == ENABLED)
808  //Ed25519 signature algorithm?
809  if(OID_COMP(oid, oidLen, ED25519_OID) == 0)
810  {
811  *signAlgo = X509_SIGN_ALGO_ED25519;
812  *hashAlgo = NULL;
813  }
814  else
815 #endif
816 #if (X509_ED448_SUPPORT == ENABLED && ED448_SUPPORT == ENABLED)
817  //Ed448 signature algorithm?
818  if(OID_COMP(oid, oidLen, ED448_OID) == 0)
819  {
820  *signAlgo = X509_SIGN_ALGO_ED448;
821  *hashAlgo = NULL;
822  }
823  else
824 #endif
825 #if (X509_MLDSA44_SUPPORT == ENABLED && MLDSA44_SUPPORT == ENABLED)
826  //ML-DSA-44 signature algorithm?
827  if(OID_COMP(oid, oidLen, MLDSA44_OID) == 0)
828  {
829  *signAlgo = X509_SIGN_ALGO_MLDSA44;
830  *hashAlgo = NULL;
831  }
832  else
833 #endif
834 #if (X509_MLDSA65_SUPPORT == ENABLED && MLDSA65_SUPPORT == ENABLED)
835  //ML-DSA-65 signature algorithm?
836  if(OID_COMP(oid, oidLen, MLDSA65_OID) == 0)
837  {
838  *signAlgo = X509_SIGN_ALGO_MLDSA65;
839  *hashAlgo = NULL;
840  }
841  else
842 #endif
843 #if (X509_MLDSA87_SUPPORT == ENABLED && MLDSA87_SUPPORT == ENABLED)
844  //ML-DSA-87 signature algorithm?
845  if(OID_COMP(oid, oidLen, MLDSA87_OID) == 0)
846  {
847  *signAlgo = X509_SIGN_ALGO_MLDSA87;
848  *hashAlgo = NULL;
849  }
850  else
851 #endif
852  //Unknown signature algorithm?
853  {
855  }
856 
857  //Return status code
858  return error;
859 }
860 
861 
862 /**
863  * @brief Get the public key type that matches the specified OID
864  * @param[in] oid Object identifier
865  * @param[in] length OID length
866  * @return Public key type
867  **/
868 
870 {
871  X509KeyType keyType;
872 
873  //Invalid parameters?
874  if(oid == NULL || length == 0)
875  {
876  keyType = X509_KEY_TYPE_UNKNOWN;
877  }
878 #if (RSA_SUPPORT == ENABLED)
879  //RSA algorithm identifier?
880  else if(OID_COMP(oid, length, RSA_ENCRYPTION_OID) == 0)
881  {
882  keyType = X509_KEY_TYPE_RSA;
883  }
884  //RSA-PSS algorithm identifier?
885  else if(OID_COMP(oid, length, RSASSA_PSS_OID) == 0)
886  {
887  keyType = X509_KEY_TYPE_RSA_PSS;
888  }
889 #endif
890 #if (DSA_SUPPORT == ENABLED)
891  //DSA algorithm identifier?
892  else if(OID_COMP(oid, length, DSA_OID) == 0)
893  {
894  keyType = X509_KEY_TYPE_DSA;
895  }
896 #endif
897 #if (EC_SUPPORT == ENABLED)
898  //EC public key identifier?
899  else if(OID_COMP(oid, length, EC_PUBLIC_KEY_OID) == 0)
900  {
901  keyType = X509_KEY_TYPE_EC;
902  }
903 #endif
904 #if (X25519_SUPPORT == ENABLED)
905  //X25519 algorithm identifier?
906  else if(OID_COMP(oid, length, X25519_OID) == 0)
907  {
908  keyType = X509_KEY_TYPE_X25519;
909  }
910 #endif
911 #if (ED25519_SUPPORT == ENABLED)
912  //Ed25519 algorithm identifier?
913  else if(OID_COMP(oid, length, ED25519_OID) == 0)
914  {
915  keyType = X509_KEY_TYPE_ED25519;
916  }
917 #endif
918 #if (X448_SUPPORT == ENABLED)
919  //X448 algorithm identifier?
920  else if(OID_COMP(oid, length, X448_OID) == 0)
921  {
922  keyType = X509_KEY_TYPE_X448;
923  }
924 #endif
925 #if (ED448_SUPPORT == ENABLED)
926  //Ed448 algorithm identifier?
927  else if(OID_COMP(oid, length, ED448_OID) == 0)
928  {
929  keyType = X509_KEY_TYPE_ED448;
930  }
931 #endif
932 #if (MLDSA44_SUPPORT == ENABLED)
933  //ML-DSA-44 algorithm identifier?
934  else if(OID_COMP(oid, length, MLDSA44_OID) == 0)
935  {
936  keyType = X509_KEY_TYPE_MLDSA44;
937  }
938 #endif
939 #if (MLDSA65_SUPPORT == ENABLED)
940  //ML-DSA-65 algorithm identifier?
941  else if(OID_COMP(oid, length, MLDSA65_OID) == 0)
942  {
943  keyType = X509_KEY_TYPE_MLDSA65;
944  }
945 #endif
946 #if (MLDSA87_SUPPORT == ENABLED)
947  //ML-DSA-87 algorithm identifier?
948  else if(OID_COMP(oid, length, MLDSA87_OID) == 0)
949  {
950  keyType = X509_KEY_TYPE_MLDSA87;
951  }
952 #endif
953  //Unknown algorithm identifier?
954  else
955  {
956  keyType = X509_KEY_TYPE_UNKNOWN;
957  }
958 
959  //Return public key type
960  return keyType;
961 }
962 
963 
964 /**
965  * @brief Get the hash algorithms that match the specified identifier
966  * @param[in] oid Object identifier
967  * @param[in] length Length of the OID, in bytes
968  * @return Hash algorithm
969  **/
970 
971 const HashAlgo *x509GetHashAlgo(const uint8_t *oid, size_t length)
972 {
973  const HashAlgo *hashAlgo;
974 
975 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
976  //SHA-1 hash algorithm identifier?
977  if(OID_COMP(oid, length, SHA1_OID) == 0)
978  {
979  hashAlgo = SHA1_HASH_ALGO;
980  }
981  else
982 #endif
983 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
984  //SHA-224 hash algorithm identifier?
985  if(OID_COMP(oid, length, SHA224_OID) == 0)
986  {
987  hashAlgo = SHA224_HASH_ALGO;
988  }
989  else
990 #endif
991 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
992  //SHA-256 hash algorithm identifier?
993  if(OID_COMP(oid, length, SHA256_OID) == 0)
994  {
995  hashAlgo = SHA256_HASH_ALGO;
996  }
997  else
998 #endif
999 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
1000  //SHA-384 hash algorithm identifier?
1001  if(OID_COMP(oid, length, SHA384_OID) == 0)
1002  {
1003  hashAlgo = SHA384_HASH_ALGO;
1004  }
1005  else
1006 #endif
1007 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
1008  //SHA-512 hash algorithm identifier?
1009  if(OID_COMP(oid, length, SHA512_OID) == 0)
1010  {
1011  hashAlgo = SHA512_HASH_ALGO;
1012  }
1013  else
1014 #endif
1015 #if (X509_SHA512_224_SUPPORT == ENABLED && SHA512_224_SUPPORT == ENABLED)
1016  //SHA-512/224 hash algorithm identifier?
1018  {
1019  hashAlgo = SHA512_224_HASH_ALGO;
1020  }
1021  else
1022 #endif
1023 #if (X509_SHA512_256_SUPPORT == ENABLED && SHA512_256_SUPPORT == ENABLED)
1024  //SHA-512/256 hash algorithm identifier?
1026  {
1027  hashAlgo = SHA512_256_HASH_ALGO;
1028  }
1029  else
1030 #endif
1031 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
1032  //SHA3-224 hash algorithm identifier?
1033  if(OID_COMP(oid, length, SHA3_224_OID) == 0)
1034  {
1035  hashAlgo = SHA3_224_HASH_ALGO;
1036  }
1037  else
1038 #endif
1039 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
1040  //SHA3-256 hash algorithm identifier?
1041  if(OID_COMP(oid, length, SHA3_256_OID) == 0)
1042  {
1043  hashAlgo = SHA3_256_HASH_ALGO;
1044  }
1045  else
1046 #endif
1047 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
1048  //SHA3-384 hash algorithm identifier?
1049  if(OID_COMP(oid, length, SHA3_384_OID) == 0)
1050  {
1051  hashAlgo = SHA3_384_HASH_ALGO;
1052  }
1053  else
1054 #endif
1055 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
1056  //SHA3-512 hash algorithm identifier?
1057  if(OID_COMP(oid, length, SHA3_512_OID) == 0)
1058  {
1059  hashAlgo = SHA3_512_HASH_ALGO;
1060  }
1061  else
1062 #endif
1063  //Unknown hash algorithm identifier?
1064  {
1065  hashAlgo = NULL;
1066  }
1067 
1068  //Return the hash algorithm
1069  return hashAlgo;
1070 }
1071 
1072 
1073 /**
1074  * @brief Get the elliptic curve that matches the specified OID
1075  * @param[in] oid Object identifier
1076  * @param[in] length Length of the OID, in bytes
1077  * @return Elliptic curve parameters
1078  **/
1079 
1080 const EcCurve *x509GetCurve(const uint8_t *oid, size_t length)
1081 {
1082  const EcCurve *curve;
1083 
1084  //Default elliptic curve parameters
1085  curve = NULL;
1086 
1087 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
1088  //Invalid parameters?
1089  if(oid == NULL || length == 0)
1090  {
1091  curve = NULL;
1092  }
1093 #if (X509_SECP112R1_SUPPORT == ENABLED)
1094  //secp112r1 elliptic curve?
1095  else if(OID_COMP(oid, length, SECP112R1_OID) == 0)
1096  {
1097  curve = ecGetCurve(oid, length);
1098  }
1099 #endif
1100 #if (X509_SECP112R2_SUPPORT == ENABLED)
1101  //secp112r2 elliptic curve?
1102  else if(OID_COMP(oid, length, SECP112R2_OID) == 0)
1103  {
1104  curve = ecGetCurve(oid, length);
1105  }
1106 #endif
1107 #if (X509_SECP128R1_SUPPORT == ENABLED)
1108  //secp128r1 elliptic curve?
1109  else if(OID_COMP(oid, length, SECP128R1_OID) == 0)
1110  {
1111  curve = ecGetCurve(oid, length);
1112  }
1113 #endif
1114 #if (X509_SECP128R2_SUPPORT == ENABLED)
1115  //secp128r2 elliptic curve?
1116  else if(OID_COMP(oid, length, SECP128R2_OID) == 0)
1117  {
1118  curve = ecGetCurve(oid, length);
1119  }
1120 #endif
1121 #if (X509_SECP160K1_SUPPORT == ENABLED)
1122  //secp160k1 elliptic curve?
1123  else if(OID_COMP(oid, length, SECP160K1_OID) == 0)
1124  {
1125  curve = ecGetCurve(oid, length);
1126  }
1127 #endif
1128 #if (X509_SECP160R1_SUPPORT == ENABLED)
1129  //secp160r1 elliptic curve?
1130  else if(OID_COMP(oid, length, SECP160R1_OID) == 0)
1131  {
1132  curve = ecGetCurve(oid, length);
1133  }
1134 #endif
1135 #if (X509_SECP160R2_SUPPORT == ENABLED)
1136  //secp160r2 elliptic curve?
1137  else if(OID_COMP(oid, length, SECP160R2_OID) == 0)
1138  {
1139  curve = ecGetCurve(oid, length);
1140  }
1141 #endif
1142 #if (X509_SECP192K1_SUPPORT == ENABLED)
1143  //secp192k1 elliptic curve?
1144  else if(OID_COMP(oid, length, SECP192K1_OID) == 0)
1145  {
1146  curve = ecGetCurve(oid, length);
1147  }
1148 #endif
1149 #if (X509_SECP192R1_SUPPORT == ENABLED)
1150  //secp192r1 elliptic curve?
1151  else if(OID_COMP(oid, length, SECP192R1_OID) == 0)
1152  {
1153  curve = ecGetCurve(oid, length);
1154  }
1155 #endif
1156 #if (X509_SECP224K1_SUPPORT == ENABLED)
1157  //secp224k1 elliptic curve?
1158  else if(OID_COMP(oid, length, SECP224K1_OID) == 0)
1159  {
1160  curve = ecGetCurve(oid, length);
1161  }
1162 #endif
1163 #if (X509_SECP224R1_SUPPORT == ENABLED)
1164  //secp224r1 elliptic curve?
1165  else if(OID_COMP(oid, length, SECP224R1_OID) == 0)
1166  {
1167  curve = ecGetCurve(oid, length);
1168  }
1169 #endif
1170 #if (X509_SECP256K1_SUPPORT == ENABLED)
1171  //secp256k1 elliptic curve?
1172  else if(OID_COMP(oid, length, SECP256K1_OID) == 0)
1173  {
1174  curve = ecGetCurve(oid, length);
1175  }
1176 #endif
1177 #if (X509_SECP256R1_SUPPORT == ENABLED)
1178  //secp256r1 elliptic curve?
1179  else if(OID_COMP(oid, length, SECP256R1_OID) == 0)
1180  {
1181  curve = ecGetCurve(oid, length);
1182  }
1183 #endif
1184 #if (X509_SECP384R1_SUPPORT == ENABLED)
1185  //secp384r1 elliptic curve?
1186  else if(OID_COMP(oid, length, SECP384R1_OID) == 0)
1187  {
1188  curve = ecGetCurve(oid, length);
1189  }
1190 #endif
1191 #if (X509_SECP521R1_SUPPORT == ENABLED)
1192  //secp521r1 elliptic curve?
1193  else if(OID_COMP(oid, length, SECP521R1_OID) == 0)
1194  {
1195  curve = ecGetCurve(oid, length);
1196  }
1197 #endif
1198 #if (X509_BRAINPOOLP160R1_SUPPORT == ENABLED)
1199  //brainpoolP160r1 elliptic curve?
1200  else if(OID_COMP(oid, length, BRAINPOOLP160R1_OID) == 0)
1201  {
1202  curve = ecGetCurve(oid, length);
1203  }
1204 #endif
1205 #if (X509_BRAINPOOLP160T1_SUPPORT == ENABLED)
1206  //brainpoolP160t1 elliptic curve?
1207  else if(OID_COMP(oid, length, BRAINPOOLP160T1_OID) == 0)
1208  {
1209  curve = ecGetCurve(oid, length);
1210  }
1211 #endif
1212 #if (X509_BRAINPOOLP192R1_SUPPORT == ENABLED)
1213  //brainpoolP192r1 elliptic curve?
1214  else if(OID_COMP(oid, length, BRAINPOOLP192R1_OID) == 0)
1215  {
1216  curve = ecGetCurve(oid, length);
1217  }
1218 #endif
1219 #if (X509_BRAINPOOLP192T1_SUPPORT == ENABLED)
1220  //brainpoolP192t1 elliptic curve?
1221  else if(OID_COMP(oid, length, BRAINPOOLP192T1_OID) == 0)
1222  {
1223  curve = ecGetCurve(oid, length);
1224  }
1225 #endif
1226 #if (X509_BRAINPOOLP224R1_SUPPORT == ENABLED)
1227  //brainpoolP224r1 elliptic curve?
1228  else if(OID_COMP(oid, length, BRAINPOOLP224R1_OID) == 0)
1229  {
1230  curve = ecGetCurve(oid, length);
1231  }
1232 #endif
1233 #if (X509_BRAINPOOLP224T1_SUPPORT == ENABLED)
1234  //brainpoolP224t1 elliptic curve?
1235  else if(OID_COMP(oid, length, BRAINPOOLP224T1_OID) == 0)
1236  {
1237  curve = ecGetCurve(oid, length);
1238  }
1239 #endif
1240 #if (X509_BRAINPOOLP256R1_SUPPORT == ENABLED)
1241  //brainpoolP256r1 elliptic curve?
1242  else if(OID_COMP(oid, length, BRAINPOOLP256R1_OID) == 0)
1243  {
1244  curve = ecGetCurve(oid, length);
1245  }
1246 #endif
1247 #if (X509_BRAINPOOLP256T1_SUPPORT == ENABLED)
1248  //brainpoolP256t1 elliptic curve?
1249  else if(OID_COMP(oid, length, BRAINPOOLP256T1_OID) == 0)
1250  {
1251  curve = ecGetCurve(oid, length);
1252  }
1253 #endif
1254 #if (X509_BRAINPOOLP320R1_SUPPORT == ENABLED)
1255  //brainpoolP320r1 elliptic curve?
1256  else if(OID_COMP(oid, length, BRAINPOOLP320R1_OID) == 0)
1257  {
1258  curve = ecGetCurve(oid, length);
1259  }
1260 #endif
1261 #if (X509_BRAINPOOLP320T1_SUPPORT == ENABLED)
1262  //brainpoolP320t1 elliptic curve?
1263  else if(OID_COMP(oid, length, BRAINPOOLP320T1_OID) == 0)
1264  {
1265  curve = ecGetCurve(oid, length);
1266  }
1267 #endif
1268 #if (X509_BRAINPOOLP384R1_SUPPORT == ENABLED)
1269  //brainpoolP384r1 elliptic curve?
1270  else if(OID_COMP(oid, length, BRAINPOOLP384R1_OID) == 0)
1271  {
1272  curve = ecGetCurve(oid, length);
1273  }
1274 #endif
1275 #if (X509_BRAINPOOLP384T1_SUPPORT == ENABLED)
1276  //brainpoolP384t1 elliptic curve?
1277  else if(OID_COMP(oid, length, BRAINPOOLP384T1_OID) == 0)
1278  {
1279  curve = ecGetCurve(oid, length);
1280  }
1281 #endif
1282 #if (X509_BRAINPOOLP512R1_SUPPORT == ENABLED)
1283  //brainpoolP512r1 elliptic curve?
1284  else if(OID_COMP(oid, length, BRAINPOOLP512R1_OID) == 0)
1285  {
1286  curve = ecGetCurve(oid, length);
1287  }
1288 #endif
1289 #if (X509_BRAINPOOLP512T1_SUPPORT == ENABLED)
1290  //brainpoolP512t1 elliptic curve?
1291  else if(OID_COMP(oid, length, BRAINPOOLP512T1_OID) == 0)
1292  {
1293  curve = ecGetCurve(oid, length);
1294  }
1295 #endif
1296 #if (X509_FRP256V1_SUPPORT == ENABLED)
1297  //FRP256v1 elliptic curve?
1298  else if(OID_COMP(oid, length, FRP256V1_OID) == 0)
1299  {
1300  curve = ecGetCurve(oid, length);
1301  }
1302 #endif
1303 #if (X509_SM2_SUPPORT == ENABLED)
1304  //SM2 elliptic curve?
1305  else if(OID_COMP(oid, length, SM2_OID) == 0)
1306  {
1307  curve = ecGetCurve(oid, length);
1308  }
1309 #endif
1310 #if (X509_ED25519_SUPPORT == ENABLED)
1311  //Ed25519 elliptic curve?
1312  else if(OID_COMP(oid, length, ED25519_OID) == 0)
1313  {
1314  curve = ecGetCurve(oid, length);
1315  }
1316 #endif
1317 #if (X509_ED448_SUPPORT == ENABLED)
1318  //Ed448 elliptic curve?
1319  else if(OID_COMP(oid, length, ED448_OID) == 0)
1320  {
1321  curve = ecGetCurve(oid, length);
1322  }
1323 #endif
1324  //Unknown elliptic curve?
1325  else
1326  {
1327  curve = NULL;
1328  }
1329 #endif
1330 
1331  //Return the elliptic curve parameters, if any
1332  return curve;
1333 }
1334 
1335 #endif
const uint8_t X509_POLICY_MAPPINGS_OID[3]
Definition: x509_common.c:109
const uint8_t MLDSA44_OID[9]
Definition: mldsa.c:47
bool_t x509IsCurveSupported(const uint8_t *oid, size_t length)
Check whether a given elliptic curve is supported.
Definition: x509_common.c:424
#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:687
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:210
bool_t x509IsHashAlgoSupported(X509HashAlgo hashAlgo)
Check whether a given hash algorithm is supported.
Definition: x509_common.c:306
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:717
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:694
const uint8_t MLDSA65_OID[9]
Definition: mldsa.c:49
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:1151
const uint8_t X509_KP_CODE_SIGNING_OID[8]
Definition: x509_common.c:134
@ X509_KEY_TYPE_MLDSA87
Definition: x509_common.h:698
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:62
const uint8_t EC_PUBLIC_KEY_OID[7]
Definition: ec.c:44
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:58
#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:50
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:971
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:1409
@ X509_SIGN_ALGO_MLDSA44
Definition: x509_common.h:716
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:66
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:690
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:707
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:1080
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:712
@ X509_HASH_ALGO_NONE
Definition: x509_common.h:728
const uint8_t SHA256_OID[9]
Definition: sha256.c:82
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:64
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:52
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:730
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 algorithms.
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:447
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:735
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:688
const uint8_t X509_AD_OCSP[8]
Definition: x509_common.c:163
const uint8_t X509_KP_IPSEC_IKE_OID[8]
Definition: x509_common.c:148
@ X509_HASH_ALGO_SHA224
Definition: x509_common.h:731
@ X509_SIGN_ALGO_MLDSA87
Definition: x509_common.h:718
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:45
X509OctetString oid
Definition: x509_common.h:1164
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:56
X509HashAlgo
Hash algorithms.
Definition: x509_common.h:727
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:46
const uint8_t ECDSA_WITH_SHA224_OID[8]
Definition: ecdsa.c:48
@ X509_SIGN_ALGO_RSA
Definition: x509_common.h:709
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:54
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:738
#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:729
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:710
@ X509_KEY_TYPE_ED448
Definition: x509_common.h:695
@ X509_HASH_ALGO_SHA3_256
Definition: x509_common.h:736
@ X509_HASH_ALGO_SHA3_384
Definition: x509_common.h:737
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:161
const uint8_t ECDSA_WITH_SHA3_384_OID[9]
Definition: ecdsa.c:60
@ X509_HASH_ALGO_SHA512
Definition: x509_common.h:734
@ X509_HASH_ALGO_SHAKE256_512
Definition: x509_common.h:740
@ X509_KEY_TYPE_MLDSA44
Definition: x509_common.h:696
const uint8_t X509_NS_CERT_TYPE_OID[9]
Definition: x509_common.c:125
@ X509_KEY_TYPE_DSA
Definition: x509_common.h:689
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:733
@ X509_HASH_ALGO_SHA256
Definition: x509_common.h:732
const uint8_t BRAINPOOLP192R1_OID[9]
Definition: ec_curves.c:80
const uint8_t SHA512_OID[9]
Definition: sha512.c:99
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:73
#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:762
Common interface for hash algorithms.
Definition: crypto.h:1243
@ X509_KEY_TYPE_UNKNOWN
Definition: x509_common.h:686
#define EcCurve
Definition: ec.h:346
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:188
@ ERROR_UNSUPPORTED_SIGNATURE_ALGO
Definition: error.h:132
@ X509_SIGN_ALGO_SM2
Definition: x509_common.h:713
@ X509_SIGN_ALGO_ED25519
Definition: x509_common.h:714
@ X509_HASH_ALGO_SHAKE128_256
Definition: x509_common.h:739
const uint8_t MLDSA87_OID[9]
Definition: mldsa.c:51
const uint8_t RSASSA_PSS_SHAKE128_OID[8]
Definition: rsa.c:87
@ X509_KEY_TYPE_ED25519
Definition: x509_common.h:693
X509KeyType
Public Key types.
Definition: x509_common.h:685
@ X509_SIGN_ALGO_NONE
Definition: x509_common.h:708
X509KeyType x509GetPublicKeyType(const uint8_t *oid, size_t length)
Get the public key type that matches the specified OID.
Definition: x509_common.c:869
const uint8_t SHA384_OID[9]
Definition: sha384.c:47
@ X509_HASH_ALGO_SM3
Definition: x509_common.h:741
@ X509_KEY_TYPE_MLDSA65
Definition: x509_common.h:697
X509RsaPssParameters rsaPssParams
Definition: x509_common.h:1166
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:1163
@ 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:692
ASN.1 (Abstract Syntax Notation One)
@ X509_SIGN_ALGO_DSA
Definition: x509_common.h:711
@ X509_SIGN_ALGO_ED448
Definition: x509_common.h:715
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