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-2023 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.2.4
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)
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 
76 //Subject Directory Attributes OID (2.5.29.9)
77 const uint8_t X509_SUBJECT_DIR_ATTR_OID[3] = {0x55, 0x1D, 0x09};
78 //Subject Key Identifier OID (2.5.29.14)
79 const uint8_t X509_SUBJECT_KEY_ID_OID[3] = {0x55, 0x1D, 0x0E};
80 //Key Usage OID (2.5.29.15)
81 const uint8_t X509_KEY_USAGE_OID[3] = {0x55, 0x1D, 0x0F};
82 //Subject Alternative Name OID (2.5.29.17)
83 const uint8_t X509_SUBJECT_ALT_NAME_OID[3] = {0x55, 0x1D, 0x11};
84 //Issuer Alternative Name OID (2.5.29.18)
85 const uint8_t X509_ISSUER_ALT_NAME_OID[3] = {0x55, 0x1D, 0x12};
86 //Basic Constraints OID (2.5.29.19)
87 const uint8_t X509_BASIC_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x13};
88 //CRL Number OID (2.5.29.20)
89 const uint8_t X509_CRL_NUMBER_OID[3] = {0x55, 0x1D, 0x14};
90 //Reason Code OID (2.5.29.21)
91 const uint8_t X509_REASON_CODE_OID[3] = {0x55, 0x1D, 0x15};
92 //Invalidity Date OID (2.5.29.24)
93 const uint8_t X509_INVALIDITY_DATE_OID[3] = {0x55, 0x1D, 0x18};
94 //Delta CRL Indicator OID (2.5.29.27)
95 const uint8_t X509_DELTA_CRL_INDICATOR_OID[3] = {0x55, 0x1D, 0x1B};
96 //Issuing Distribution Point OID (2.5.29.28)
97 const uint8_t X509_ISSUING_DISTR_POINT_OID[3] = {0x55, 0x1D, 0x1C};
98 //Certificate Issuer OID (2.5.29.29)
99 const uint8_t X509_CERTIFICATE_ISSUER_OID[3] = {0x55, 0x1D, 0x1D};
100 //Name Constraints OID (2.5.29.30)
101 const uint8_t X509_NAME_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x1E};
102 //CRL Distribution Points OID (2.5.29.31)
103 const uint8_t X509_CRL_DISTR_POINTS_OID[3] = {0x55, 0x1D, 0x1F};
104 //Certificate Policies OID (2.5.29.32)
105 const uint8_t X509_CERTIFICATE_POLICIES_OID[3] = {0x55, 0x1D, 0x20};
106 //Policy Mappings OID (2.5.29.33)
107 const uint8_t X509_POLICY_MAPPINGS_OID[3] = {0x55, 0x1D, 0x21};
108 //Authority Key Identifier OID (2.5.29.35)
109 const uint8_t X509_AUTHORITY_KEY_ID_OID[3] = {0x55, 0x1D, 0x23};
110 //Policy Constraints OID (2.5.29.36)
111 const uint8_t X509_POLICY_CONSTRAINTS_OID[3] = {0x55, 0x1D, 0x24};
112 //Extended Key Usage OID (2.5.29.37)
113 const uint8_t X509_EXTENDED_KEY_USAGE_OID[3] = {0x55, 0x1D, 0x25};
114 //Freshest CRL OID (2.5.29.46)
115 const uint8_t X509_FRESHEST_CRL_OID[3] = {0x55, 0x1D, 0x2E};
116 //Inhibit Any-Policy OID (2.5.29.54)
117 const uint8_t X509_INHIBIT_ANY_POLICY_OID[3] = {0x55, 0x1D, 0x36};
118 
119 //Netscape Certificate Type OID (2.16.840.1.113730.1.1)
120 const uint8_t X509_NS_CERT_TYPE_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x86, 0xF8, 0x42, 0x01, 0x01};
121 
122 //Any Extended Key Usage OID (2.5.29.37.0)
123 const uint8_t X509_ANY_EXT_KEY_USAGE_OID[4] = {0x55, 0x1D, 0x25, 0x00};
124 //Key Purpose Server Auth OID (1.3.6.1.5.5.7.3.1)
125 const uint8_t X509_KP_SERVER_AUTH_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01};
126 //Key Purpose Client Auth OID (1.3.6.1.5.5.7.3.2)
127 const uint8_t X509_KP_CLIENT_AUTH_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02};
128 //Key Purpose Code Signing OID (1.3.6.1.5.5.7.3.3)
129 const uint8_t X509_KP_CODE_SIGNING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x03};
130 //Key Purpose Email Protection OID (1.3.6.1.5.5.7.3.4)
131 const uint8_t X509_KP_EMAIL_PROTECTION_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x04};
132 //Key Purpose IPsec End System OID (1.3.6.1.5.5.7.3.5)
133 const uint8_t X509_KP_IPSEC_END_SYSTEM_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x05};
134 //Key Purpose IPsec Tunnel OID (1.3.6.1.5.5.7.3.6)
135 const uint8_t X509_KP_IPSEC_TUNNEL_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x06};
136 //Key Purpose IPsec User OID (1.3.6.1.5.5.7.3.7)
137 const uint8_t X509_KP_IPSEC_USER_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x07};
138 //Key Purpose Time Stamping OID (1.3.6.1.5.5.7.3.8)
139 const uint8_t X509_KP_TIME_STAMPING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x08};
140 //Key Purpose OCSP Signing OID (1.3.6.1.5.5.7.3.9)
141 const uint8_t X509_KP_OCSP_SIGNING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x09};
142 //Key Purpose IPsec IKE OID (1.3.6.1.5.5.7.3.17)
143 const uint8_t X509_KP_IPSEC_IKE_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x11};
144 //Key Purpose Secure Shell Client (1.3.6.1.5.5.7.3.21)
145 const uint8_t X509_KP_SSH_CLIENT_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x15};
146 //Key Purpose Secure Shell Client (1.3.6.1.5.5.7.3.22)
147 const uint8_t X509_KP_SSH_SERVER_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x16};
148 //Key Purpose Document Signing (1.3.6.1.5.5.7.3.36)
149 const uint8_t X509_KP_DOC_SIGNING_OID[8] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x24};
150 
151 //PKCS #9 Challenge Password OID (1.2.840.113549.1.9.7)
152 const uint8_t X509_CHALLENGE_PASSWORD_OID[9] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x07};
153 //PKCS #9 Extension Request OID (1.2.840.113549.1.9.14)
154 const uint8_t X509_EXTENSION_REQUEST_OID[9] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x0E};
155 
156 
157 /**
158  * @brief Check whether a given signature algorithm is supported
159  * @param[in] signAlgo signature algorithm
160  * @return TRUE is the signature algorithm is supported, else FALSE
161  **/
162 
164 {
165  bool_t acceptable;
166 
167  //Invalid signature algorithm?
168  if(signAlgo == X509_SIGN_ALGO_NONE)
169  {
170  acceptable = FALSE;
171  }
172 #if (X509_RSA_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
173  //RSA signature algorithm?
174  else if(signAlgo == X509_SIGN_ALGO_RSA)
175  {
176  acceptable = TRUE;
177  }
178 #endif
179 #if (X509_RSA_PSS_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
180  //RSA-PSS signature algorithm?
181  else if(signAlgo == X509_SIGN_ALGO_RSA_PSS)
182  {
183  acceptable = TRUE;
184  }
185 #endif
186 #if (X509_DSA_SUPPORT == ENABLED && DSA_SUPPORT == ENABLED)
187  //DSA signature algorithm?
188  else if(signAlgo == X509_SIGN_ALGO_DSA)
189  {
190  acceptable = TRUE;
191  }
192 #endif
193 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
194  //ECDSA signature algorithm?
195  else if(signAlgo == X509_SIGN_ALGO_ECDSA)
196  {
197  acceptable = TRUE;
198  }
199 #endif
200 #if (X509_ED25519_SUPPORT == ENABLED && ED25519_SUPPORT == ENABLED)
201  //Ed25519 signature algorithm?
202  else if(signAlgo == X509_SIGN_ALGO_ED25519)
203  {
204  acceptable = TRUE;
205  }
206 #endif
207 #if (X509_ED448_SUPPORT == ENABLED && ED448_SUPPORT == ENABLED)
208  //Ed448 signature algorithm?
209  else if(signAlgo == X509_SIGN_ALGO_ED448)
210  {
211  acceptable = TRUE;
212  }
213 #endif
214  //Invalid signature algorithm?
215  else
216  {
217  acceptable = FALSE;
218  }
219 
220  //Return TRUE is the signature algorithm is supported
221  return acceptable;
222 }
223 
224 
225 /**
226  * @brief Check whether a given hash algorithm is supported
227  * @param[in] hashAlgo signature hash
228  * @return TRUE is the signature hash is supported, else FALSE
229  **/
230 
232 {
233  bool_t acceptable;
234 
235  //Invalid hash algorithm?
236  if(hashAlgo == X509_HASH_ALGO_NONE)
237  {
238  acceptable = FALSE;
239  }
240 #if (X509_MD5_SUPPORT == ENABLED && MD5_SUPPORT == ENABLED)
241  //MD5 hash algorithm?
242  else if(hashAlgo == X509_HASH_ALGO_MD5)
243  {
244  acceptable = TRUE;
245  }
246 #endif
247 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
248  //SHA-1 hash algorithm?
249  else if(hashAlgo == X509_HASH_ALGO_SHA1)
250  {
251  acceptable = TRUE;
252  }
253 #endif
254 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
255  //SHA-224 hash algorithm?
256  else if(hashAlgo == X509_HASH_ALGO_SHA224)
257  {
258  acceptable = TRUE;
259  }
260 #endif
261 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
262  //SHA-256 hash algorithm?
263  else if(hashAlgo == X509_HASH_ALGO_SHA256)
264  {
265  acceptable = TRUE;
266  }
267 #endif
268 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
269  //SHA-384 hash algorithm?
270  else if(hashAlgo == X509_HASH_ALGO_SHA384)
271  {
272  acceptable = TRUE;
273  }
274 #endif
275 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
276  //SHA-512 hash algorithm?
277  else if(hashAlgo == X509_HASH_ALGO_SHA512)
278  {
279  acceptable = TRUE;
280  }
281 #endif
282 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
283  //SHA3-224 hash algorithm?
284  else if(hashAlgo == X509_HASH_ALGO_SHA3_224)
285  {
286  acceptable = TRUE;
287  }
288 #endif
289 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
290  //SHA3-256 hash algorithm?
291  else if(hashAlgo == X509_HASH_ALGO_SHA3_256)
292  {
293  acceptable = TRUE;
294  }
295 #endif
296 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
297  //SHA3-384 hash algorithm?
298  else if(hashAlgo == X509_HASH_ALGO_SHA3_384)
299  {
300  acceptable = TRUE;
301  }
302 #endif
303 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
304  //SHA3-512 hash algorithm?
305  else if(hashAlgo == X509_HASH_ALGO_SHA3_512)
306  {
307  acceptable = TRUE;
308  }
309 #endif
310  //Invalid hash algorithm?
311  else
312  {
313  acceptable = FALSE;
314  }
315 
316  //Return TRUE is the hash algorithm is supported
317  return acceptable;
318 }
319 
320 
321 /**
322  * @brief Get the signature and hash algorithms that match the specified
323  * identifier
324  * @param[in] signAlgoId Signature algorithm identifier
325  * @param[out] signAlgo Signature algorithm
326  * @param[out] hashAlgo Hash algorithm
327  * @return Error code
328  **/
329 
331  X509SignatureAlgo *signAlgo, const HashAlgo **hashAlgo)
332 {
333  error_t error;
334  size_t oidLen;
335  const uint8_t *oid;
336 
337  //Initialize status code
338  error = NO_ERROR;
339 
340  //Point to the object identifier
341  oid = signAlgoId->oid;
342  oidLen = signAlgoId->oidLen;
343 
344 #if (X509_RSA_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
345 #if (X509_MD5_SUPPORT == ENABLED && MD5_SUPPORT == ENABLED)
346  //RSA with MD5 signature algorithm?
349  {
350  *signAlgo = X509_SIGN_ALGO_RSA;
351  *hashAlgo = MD5_HASH_ALGO;
352  }
353  else
354 #endif
355 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
356  //RSA with SHA-1 signature algorithm?
359  {
360  *signAlgo = X509_SIGN_ALGO_RSA;
361  *hashAlgo = SHA1_HASH_ALGO;
362  }
363  else
364 #endif
365 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
366  //RSA with SHA-224 signature algorithm?
369  {
370  *signAlgo = X509_SIGN_ALGO_RSA;
371  *hashAlgo = SHA224_HASH_ALGO;
372  }
373  else
374 #endif
375 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
376  //RSA with SHA-256 signature algorithm?
379  {
380  *signAlgo = X509_SIGN_ALGO_RSA;
381  *hashAlgo = SHA256_HASH_ALGO;
382  }
383  else
384 #endif
385 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
386  //RSA with SHA-384 signature algorithm?
389  {
390  *signAlgo = X509_SIGN_ALGO_RSA;
391  *hashAlgo = SHA384_HASH_ALGO;
392  }
393  else
394 #endif
395 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
396  //RSA with SHA-512 signature algorithm?
399  {
400  *signAlgo = X509_SIGN_ALGO_RSA;
401  *hashAlgo = SHA512_HASH_ALGO;
402  }
403  else
404 #endif
405 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
406  //RSA with SHA3-224 signature algorithm?
409  {
410  *signAlgo = X509_SIGN_ALGO_RSA;
411  *hashAlgo = SHA3_224_HASH_ALGO;
412  }
413  else
414 #endif
415 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
416  //RSA with SHA3-256 signature algorithm?
419  {
420  *signAlgo = X509_SIGN_ALGO_RSA;
421  *hashAlgo = SHA3_256_HASH_ALGO;
422  }
423  else
424 #endif
425 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
426  //RSA with SHA3-384 signature algorithm?
429  {
430  *signAlgo = X509_SIGN_ALGO_RSA;
431  *hashAlgo = SHA3_384_HASH_ALGO;
432  }
433  else
434 #endif
435 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
436  //RSA with SHA3-512 signature algorithm?
439  {
440  *signAlgo = X509_SIGN_ALGO_RSA;
441  *hashAlgo = SHA3_512_HASH_ALGO;
442  }
443  else
444 #endif
445 #endif
446 #if (X509_RSA_PSS_SUPPORT == ENABLED && RSA_SUPPORT == ENABLED)
447  //RSA-PSS signature algorithm
449  sizeof(RSASSA_PSS_OID)))
450  {
451  //Get the OID of the hash algorithm
452  oid = signAlgoId->rsaPssParams.hashAlgo;
453  oidLen = signAlgoId->rsaPssParams.hashAlgoLen;
454 
455 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
456  //SHA-1 hash algorithm identifier?
457  if(!oidComp(oid, oidLen, SHA1_OID, sizeof(SHA1_OID)))
458  {
459  //RSA-PSS with SHA-1 signature algorithm
460  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
461  *hashAlgo = SHA1_HASH_ALGO;
462  }
463  else
464 #endif
465 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
466  //SHA-224 hash algorithm identifier?
467  if(!oidComp(oid, oidLen, SHA224_OID, sizeof(SHA224_OID)))
468  {
469  //RSA-PSS with SHA-224 signature algorithm
470  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
471  *hashAlgo = SHA224_HASH_ALGO;
472  }
473  else
474 #endif
475 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
476  //SHA-256 hash algorithm identifier?
477  if(!oidComp(oid, oidLen, SHA256_OID, sizeof(SHA256_OID)))
478  {
479  //RSA-PSS with SHA-256 signature algorithm
480  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
481  *hashAlgo = SHA256_HASH_ALGO;
482  }
483  else
484 #endif
485 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
486  //SHA-384 hash algorithm identifier?
487  if(!oidComp(oid, oidLen, SHA384_OID, sizeof(SHA384_OID)))
488  {
489  //RSA-PSS with SHA-384 signature algorithm
490  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
491  *hashAlgo = SHA384_HASH_ALGO;
492  }
493  else
494 #endif
495 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
496  //SHA-512 hash algorithm identifier?
497  if(!oidComp(oid, oidLen, SHA512_OID, sizeof(SHA512_OID)))
498  {
499  //RSA-PSS with SHA-512 signature algorithm
500  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
501  *hashAlgo = SHA512_HASH_ALGO;
502  }
503  else
504 #endif
505 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
506  //SHA3-224 hash algorithm identifier?
507  if(!oidComp(oid, oidLen, SHA3_224_OID, sizeof(SHA3_224_OID)))
508  {
509  //RSA-PSS with SHA3-224 signature algorithm
510  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
511  *hashAlgo = SHA3_224_HASH_ALGO;
512  }
513  else
514 #endif
515 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
516  //SHA3-256 hash algorithm identifier?
517  if(!oidComp(oid, oidLen, SHA3_256_OID, sizeof(SHA3_256_OID)))
518  {
519  //RSA-PSS with SHA3-256 signature algorithm
520  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
521  *hashAlgo = SHA3_256_HASH_ALGO;
522  }
523  else
524 #endif
525 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
526  //SHA3-384 hash algorithm identifier?
527  if(!oidComp(oid, oidLen, SHA3_384_OID, sizeof(SHA3_384_OID)))
528  {
529  //RSA-PSS with SHA3-384 signature algorithm
530  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
531  *hashAlgo = SHA3_384_HASH_ALGO;
532  }
533  else
534 #endif
535 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
536  //SHA3-512 hash algorithm identifier?
537  if(!oidComp(oid, oidLen, SHA3_512_OID, sizeof(SHA3_512_OID)))
538  {
539  //RSA-PSS with SHA3-512 signature algorithm
540  *signAlgo = X509_SIGN_ALGO_RSA_PSS;
541  *hashAlgo = SHA3_512_HASH_ALGO;
542  }
543  else
544 #endif
545  //Unknown hash algorithm identifier?
546  {
547  //The specified signature algorithm is not supported
549  }
550  }
551  else
552 #endif
553 #if (X509_DSA_SUPPORT == ENABLED && DSA_SUPPORT == ENABLED)
554 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
555  //DSA with SHA-1 signature algorithm?
557  sizeof(DSA_WITH_SHA1_OID)))
558  {
559  *signAlgo = X509_SIGN_ALGO_DSA;
560  *hashAlgo = SHA1_HASH_ALGO;
561  }
562  else
563 #endif
564 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
565  //DSA with SHA-224 signature algorithm?
567  sizeof(DSA_WITH_SHA224_OID)))
568  {
569  *signAlgo = X509_SIGN_ALGO_DSA;
570  *hashAlgo = SHA224_HASH_ALGO;
571  }
572  else
573 #endif
574 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
575  //DSA with SHA-256 signature algorithm?
577  sizeof(DSA_WITH_SHA256_OID)))
578  {
579  *signAlgo = X509_SIGN_ALGO_DSA;
580  *hashAlgo = SHA256_HASH_ALGO;
581  }
582  else
583 #endif
584 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
585  //DSA with SHA-384 signature algorithm?
587  sizeof(DSA_WITH_SHA384_OID)))
588  {
589  *signAlgo = X509_SIGN_ALGO_DSA;
590  *hashAlgo = SHA384_HASH_ALGO;
591  }
592  else
593 #endif
594 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
595  //DSA with SHA-512 signature algorithm?
597  sizeof(DSA_WITH_SHA512_OID)))
598  {
599  *signAlgo = X509_SIGN_ALGO_DSA;
600  *hashAlgo = SHA512_HASH_ALGO;
601  }
602  else
603 #endif
604 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
605  //DSA with SHA3-224 signature algorithm?
607  sizeof(DSA_WITH_SHA3_224_OID)))
608  {
609  *signAlgo = X509_SIGN_ALGO_DSA;
610  *hashAlgo = SHA3_224_HASH_ALGO;
611  }
612  else
613 #endif
614 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
615  //DSA with SHA3-256 signature algorithm?
617  sizeof(DSA_WITH_SHA3_256_OID)))
618  {
619  *signAlgo = X509_SIGN_ALGO_DSA;
620  *hashAlgo = SHA3_256_HASH_ALGO;
621  }
622  else
623 #endif
624 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
625  //DSA with SHA3-384 signature algorithm?
627  sizeof(DSA_WITH_SHA3_384_OID)))
628  {
629  *signAlgo = X509_SIGN_ALGO_DSA;
630  *hashAlgo = SHA3_384_HASH_ALGO;
631  }
632  else
633 #endif
634 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
635  //DSA with SHA3-512 signature algorithm?
637  sizeof(DSA_WITH_SHA3_512_OID)))
638  {
639  *signAlgo = X509_SIGN_ALGO_DSA;
640  *hashAlgo = SHA3_512_HASH_ALGO;
641  }
642  else
643 #endif
644 #endif
645 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
646 #if (X509_SHA1_SUPPORT == ENABLED && SHA1_SUPPORT == ENABLED)
647  //ECDSA with SHA-1 signature algorithm?
649  sizeof(ECDSA_WITH_SHA1_OID)))
650  {
651  *signAlgo = X509_SIGN_ALGO_ECDSA;
652  *hashAlgo = SHA1_HASH_ALGO;
653  }
654  else
655 #endif
656 #if (X509_SHA224_SUPPORT == ENABLED && SHA224_SUPPORT == ENABLED)
657  //ECDSA with SHA-224 signature algorithm?
659  sizeof(ECDSA_WITH_SHA224_OID)))
660  {
661  *signAlgo = X509_SIGN_ALGO_ECDSA;
662  *hashAlgo = SHA224_HASH_ALGO;
663  }
664  else
665 #endif
666 #if (X509_SHA256_SUPPORT == ENABLED && SHA256_SUPPORT == ENABLED)
667  //ECDSA with SHA-256 signature algorithm?
669  sizeof(ECDSA_WITH_SHA256_OID)))
670  {
671  *signAlgo = X509_SIGN_ALGO_ECDSA;
672  *hashAlgo = SHA256_HASH_ALGO;
673  }
674  else
675 #endif
676 #if (X509_SHA384_SUPPORT == ENABLED && SHA384_SUPPORT == ENABLED)
677  //ECDSA with SHA-384 signature algorithm?
679  sizeof(ECDSA_WITH_SHA384_OID)))
680  {
681  *signAlgo = X509_SIGN_ALGO_ECDSA;
682  *hashAlgo = SHA384_HASH_ALGO;
683  }
684  else
685 #endif
686 #if (X509_SHA512_SUPPORT == ENABLED && SHA512_SUPPORT == ENABLED)
687  //ECDSA with SHA-512 signature algorithm?
689  sizeof(ECDSA_WITH_SHA512_OID)))
690  {
691  *signAlgo = X509_SIGN_ALGO_ECDSA;
692  *hashAlgo = SHA512_HASH_ALGO;
693  }
694  else
695 #endif
696 #if (X509_SHA3_224_SUPPORT == ENABLED && SHA3_224_SUPPORT == ENABLED)
697  //ECDSA with SHA3-224 signature algorithm?
699  sizeof(ECDSA_WITH_SHA3_224_OID)))
700  {
701  *signAlgo = X509_SIGN_ALGO_ECDSA;
702  *hashAlgo = SHA3_224_HASH_ALGO;
703  }
704  else
705 #endif
706 #if (X509_SHA3_256_SUPPORT == ENABLED && SHA3_256_SUPPORT == ENABLED)
707  //ECDSA with SHA3-256 signature algorithm?
709  sizeof(ECDSA_WITH_SHA3_256_OID)))
710  {
711  *signAlgo = X509_SIGN_ALGO_ECDSA;
712  *hashAlgo = SHA3_256_HASH_ALGO;
713  }
714  else
715 #endif
716 #if (X509_SHA3_384_SUPPORT == ENABLED && SHA3_384_SUPPORT == ENABLED)
717  //ECDSA with SHA3-384 signature algorithm?
719  sizeof(ECDSA_WITH_SHA3_384_OID)))
720  {
721  *signAlgo = X509_SIGN_ALGO_ECDSA;
722  *hashAlgo = SHA3_384_HASH_ALGO;
723  }
724  else
725 #endif
726 #if (X509_SHA3_512_SUPPORT == ENABLED && SHA3_512_SUPPORT == ENABLED)
727  //ECDSA with SHA3-512 signature algorithm?
729  sizeof(ECDSA_WITH_SHA3_512_OID)))
730  {
731  *signAlgo = X509_SIGN_ALGO_ECDSA;
732  *hashAlgo = SHA3_512_HASH_ALGO;
733  }
734  else
735 #endif
736 #endif
737 #if (X509_ED25519_SUPPORT == ENABLED && ED25519_SUPPORT == ENABLED)
738  //Ed25519 signature algorithm?
739  if(!oidComp(oid, oidLen, ED25519_OID, sizeof(ED25519_OID)))
740  {
741  *signAlgo = X509_SIGN_ALGO_ED25519;
742  *hashAlgo = NULL;
743  }
744  else
745 #endif
746 #if (X509_ED448_SUPPORT == ENABLED && ED448_SUPPORT == ENABLED)
747  //Ed448 signature algorithm?
748  if(!oidComp(oid, oidLen, ED448_OID, sizeof(ED448_OID)))
749  {
750  *signAlgo = X509_SIGN_ALGO_ED448;
751  *hashAlgo = NULL;
752  }
753  else
754 #endif
755  //Unknown signature algorithm?
756  {
758  }
759 
760  //Return status code
761  return error;
762 }
763 
764 
765 /**
766  * @brief Get the public key type that matches the specified OID
767  * @param[in] oid Object identifier
768  * @param[in] length OID length
769  * @return Public key type
770  **/
771 
773 {
774  X509KeyType keyType;
775 
776  //Invalid parameters?
777  if(oid == NULL || length == 0)
778  {
779  keyType = X509_KEY_TYPE_UNKNOWN;
780  }
781 #if (RSA_SUPPORT == ENABLED)
782  //RSA algorithm identifier?
784  {
785  keyType = X509_KEY_TYPE_RSA;
786  }
787  //RSA-PSS algorithm identifier?
788  else if(!oidComp(oid, length, RSASSA_PSS_OID, sizeof(RSASSA_PSS_OID)))
789  {
790  keyType = X509_KEY_TYPE_RSA_PSS;
791  }
792 #endif
793 #if (DSA_SUPPORT == ENABLED)
794  //DSA algorithm identifier?
795  else if(!oidComp(oid, length, DSA_OID, sizeof(DSA_OID)))
796  {
797  keyType = X509_KEY_TYPE_DSA;
798  }
799 #endif
800 #if (EC_SUPPORT == ENABLED)
801  //EC public key identifier?
803  {
804  keyType = X509_KEY_TYPE_EC;
805  }
806 #endif
807 #if (X25519_SUPPORT == ENABLED)
808  //X25519 algorithm identifier?
809  else if(!oidComp(oid, length, X25519_OID, sizeof(X25519_OID)))
810  {
811  keyType = X509_KEY_TYPE_X25519;
812  }
813 #endif
814 #if (ED25519_SUPPORT == ENABLED)
815  //Ed25519 algorithm identifier?
816  else if(!oidComp(oid, length, ED25519_OID, sizeof(ED25519_OID)))
817  {
818  keyType = X509_KEY_TYPE_ED25519;
819  }
820 #endif
821 #if (X448_SUPPORT == ENABLED)
822  //X448 algorithm identifier?
823  else if(!oidComp(oid, length, X448_OID, sizeof(X448_OID)))
824  {
825  keyType = X509_KEY_TYPE_X448;
826  }
827 #endif
828 #if (ED448_SUPPORT == ENABLED)
829  //Ed448 algorithm identifier?
830  else if(!oidComp(oid, length, ED448_OID, sizeof(ED448_OID)))
831  {
832  keyType = X509_KEY_TYPE_ED448;
833  }
834 #endif
835  //Unknown algorithm identifier?
836  else
837  {
838  keyType = X509_KEY_TYPE_UNKNOWN;
839  }
840 
841  //Return public key type
842  return keyType;
843 }
844 
845 
846 /**
847  * @brief Get the elliptic curve that matches the specified OID
848  * @param[in] oid Object identifier
849  * @param[in] length OID length
850  * @return Elliptic curve domain parameters
851  **/
852 
853 const EcCurveInfo *x509GetCurveInfo(const uint8_t *oid, size_t length)
854 {
855  const EcCurveInfo *curveInfo;
856 
857  //Default elliptic curve domain parameters
858  curveInfo = NULL;
859 
860 #if (X509_ECDSA_SUPPORT == ENABLED && ECDSA_SUPPORT == ENABLED)
861  //Invalid parameters?
862  if(oid == NULL || length == 0)
863  {
864  curveInfo = NULL;
865  }
866 #if (X509_SECP112R1_SUPPORT == ENABLED)
867  //secp112r1 elliptic curve?
868  else if(!oidComp(oid, length, SECP112R1_OID, sizeof(SECP112R1_OID)))
869  {
870  curveInfo = ecGetCurveInfo(oid, length);
871  }
872 #endif
873 #if (X509_SECP112R2_SUPPORT == ENABLED)
874  //secp112r2 elliptic curve?
875  else if(!oidComp(oid, length, SECP112R2_OID, sizeof(SECP112R2_OID)))
876  {
877  curveInfo = ecGetCurveInfo(oid, length);
878  }
879 #endif
880 #if (X509_SECP128R1_SUPPORT == ENABLED)
881  //secp128r1 elliptic curve?
882  else if(!oidComp(oid, length, SECP128R1_OID, sizeof(SECP128R1_OID)))
883  {
884  curveInfo = ecGetCurveInfo(oid, length);
885  }
886 #endif
887 #if (X509_SECP128R2_SUPPORT == ENABLED)
888  //secp128r2 elliptic curve?
889  else if(!oidComp(oid, length, SECP128R2_OID, sizeof(SECP128R2_OID)))
890  {
891  curveInfo = ecGetCurveInfo(oid, length);
892  }
893 #endif
894 #if (X509_SECP160K1_SUPPORT == ENABLED)
895  //secp160k1 elliptic curve?
896  else if(!oidComp(oid, length, SECP160K1_OID, sizeof(SECP160K1_OID)))
897  {
898  curveInfo = ecGetCurveInfo(oid, length);
899  }
900 #endif
901 #if (X509_SECP160R1_SUPPORT == ENABLED)
902  //secp160r1 elliptic curve?
903  else if(!oidComp(oid, length, SECP160R1_OID, sizeof(SECP160R1_OID)))
904  {
905  curveInfo = ecGetCurveInfo(oid, length);
906  }
907 #endif
908 #if (X509_SECP160R2_SUPPORT == ENABLED)
909  //secp160r2 elliptic curve?
910  else if(!oidComp(oid, length, SECP160R2_OID, sizeof(SECP160R2_OID)))
911  {
912  curveInfo = ecGetCurveInfo(oid, length);
913  }
914 #endif
915 #if (X509_SECP192K1_SUPPORT == ENABLED)
916  //secp192k1 elliptic curve?
917  else if(!oidComp(oid, length, SECP192K1_OID, sizeof(SECP192K1_OID)))
918  {
919  curveInfo = ecGetCurveInfo(oid, length);
920  }
921 #endif
922 #if (X509_SECP192R1_SUPPORT == ENABLED)
923  //secp192r1 elliptic curve?
924  else if(!oidComp(oid, length, SECP192R1_OID, sizeof(SECP192R1_OID)))
925  {
926  curveInfo = ecGetCurveInfo(oid, length);
927  }
928 #endif
929 #if (X509_SECP224K1_SUPPORT == ENABLED)
930  //secp224k1 elliptic curve?
931  else if(!oidComp(oid, length, SECP224K1_OID, sizeof(SECP224K1_OID)))
932  {
933  curveInfo = ecGetCurveInfo(oid, length);
934  }
935 #endif
936 #if (X509_SECP224R1_SUPPORT == ENABLED)
937  //secp224r1 elliptic curve?
938  else if(!oidComp(oid, length, SECP224R1_OID, sizeof(SECP224R1_OID)))
939  {
940  curveInfo = ecGetCurveInfo(oid, length);
941  }
942 #endif
943 #if (X509_SECP256K1_SUPPORT == ENABLED)
944  //secp256k1 elliptic curve?
945  else if(!oidComp(oid, length, SECP256K1_OID, sizeof(SECP256K1_OID)))
946  {
947  curveInfo = ecGetCurveInfo(oid, length);
948  }
949 #endif
950 #if (X509_SECP256R1_SUPPORT == ENABLED)
951  //secp256r1 elliptic curve?
952  else if(!oidComp(oid, length, SECP256R1_OID, sizeof(SECP256R1_OID)))
953  {
954  curveInfo = ecGetCurveInfo(oid, length);
955  }
956 #endif
957 #if (X509_SECP384R1_SUPPORT == ENABLED)
958  //secp384r1 elliptic curve?
959  else if(!oidComp(oid, length, SECP384R1_OID, sizeof(SECP384R1_OID)))
960  {
961  curveInfo = ecGetCurveInfo(oid, length);
962  }
963 #endif
964 #if (X509_SECP521R1_SUPPORT == ENABLED)
965  //secp521r1 elliptic curve?
966  else if(!oidComp(oid, length, SECP521R1_OID, sizeof(SECP521R1_OID)))
967  {
968  curveInfo = ecGetCurveInfo(oid, length);
969  }
970 #endif
971 #if (X509_BRAINPOOLP160R1_SUPPORT == ENABLED)
972  //brainpoolP160r1 elliptic curve?
974  {
975  curveInfo = ecGetCurveInfo(oid, length);
976  }
977 #endif
978 #if (X509_BRAINPOOLP192R1_SUPPORT == ENABLED)
979  //brainpoolP192r1 elliptic curve?
981  {
982  curveInfo = ecGetCurveInfo(oid, length);
983  }
984 #endif
985 #if (X509_BRAINPOOLP224R1_SUPPORT == ENABLED)
986  //brainpoolP224r1 elliptic curve?
988  {
989  curveInfo = ecGetCurveInfo(oid, length);
990  }
991 #endif
992 #if (X509_BRAINPOOLP256R1_SUPPORT == ENABLED)
993  //brainpoolP256r1 elliptic curve?
995  {
996  curveInfo = ecGetCurveInfo(oid, length);
997  }
998 #endif
999 #if (X509_BRAINPOOLP320R1_SUPPORT == ENABLED)
1000  //brainpoolP320r1 elliptic curve?
1002  {
1003  curveInfo = ecGetCurveInfo(oid, length);
1004  }
1005 #endif
1006 #if (X509_BRAINPOOLP384R1_SUPPORT == ENABLED)
1007  //brainpoolP384r1 elliptic curve?
1009  {
1010  curveInfo = ecGetCurveInfo(oid, length);
1011  }
1012 #endif
1013 #if (X509_BRAINPOOLP512R1_SUPPORT == ENABLED)
1014  //brainpoolP512r1 elliptic curve?
1016  {
1017  curveInfo = ecGetCurveInfo(oid, length);
1018  }
1019 #endif
1020 #if (X509_ED25519_SUPPORT == ENABLED)
1021  //Ed25519 elliptic curve?
1022  else if(!oidComp(oid, length, ED25519_OID, sizeof(ED25519_OID)))
1023  {
1024  curveInfo = ecGetCurveInfo(oid, length);
1025  }
1026 #endif
1027 #if (X509_ED448_SUPPORT == ENABLED)
1028  //Ed448 elliptic curve?
1029  else if(!oidComp(oid, length, ED448_OID, sizeof(ED448_OID)))
1030  {
1031  curveInfo = ecGetCurveInfo(oid, length);
1032  }
1033 #endif
1034  //Unknown elliptic curve?
1035  else
1036  {
1037  curveInfo = NULL;
1038  }
1039 #endif
1040 
1041  //Return the elliptic curve domain parameters, if any
1042  return curveInfo;
1043 }
1044 
1045 #endif
const uint8_t X509_POLICY_MAPPINGS_OID[3]
Definition: x509_common.c:107
uint8_t length
Definition: coap_common.h:193
#define SHA3_512_HASH_ALGO
Definition: sha3_512.h:47
#define SHA3_384_OID
Definition: sha3_384.h:45
X.509 common definitions.
@ X509_KEY_TYPE_RSA
Definition: x509_common.h:509
#define SHA3_224_OID
Definition: sha3_224.h:45
const uint8_t X509_CERTIFICATE_POLICIES_OID[3]
Definition: x509_common.c:105
const uint8_t * oid
Definition: x509_common.h:897
const uint8_t RSASSA_PKCS1_V1_5_WITH_SHA3_512_OID[9]
Definition: rsa.c:85
#define SHA256_HASH_ALGO
Definition: sha256.h:51
int bool_t
Definition: compiler_port.h:53
#define SHA512_OID
Definition: sha512.h:49
const EcCurveInfo * ecGetCurveInfo(const uint8_t *oid, size_t length)
Get the elliptic curve that matches the specified OID.
Definition: ec_curves.c:2172
const uint8_t X509_KP_DOC_SIGNING_OID[8]
Definition: x509_common.c:149
#define SHA1_HASH_ALGO
Definition: sha1.h:51
const uint8_t X509_KP_SERVER_AUTH_OID[8]
Definition: x509_common.c:125
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:163
bool_t x509IsHashAlgoSupported(X509HashAlgo hashAlgo)
Check whether a given hash algorithm is supported.
Definition: x509_common.c:231
const uint8_t X509_ISSUER_ALT_NAME_OID[3]
Definition: x509_common.c:85
#define SHA512_HASH_ALGO
Definition: sha512.h:51
const EcCurveInfo * x509GetCurveInfo(const uint8_t *oid, size_t length)
Get the elliptic curve that matches the specified OID.
Definition: x509_common.c:853
const uint8_t X25519_OID[3]
Definition: ec_curves.c:92
const uint8_t MD5_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:62
const uint8_t X509_SUBJECT_ALT_NAME_OID[3]
Definition: x509_common.c:83
const uint8_t SHA512_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:72
@ X509_KEY_TYPE_X448
Definition: x509_common.h:515
Signature algorithm identifier.
Definition: x509_common.h:896
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:83
const uint8_t X509_KP_CODE_SIGNING_OID[8]
Definition: x509_common.c:129
OID (Object Identifier)
#define TRUE
Definition: os_port.h:52
const uint8_t RSASSA_PKCS1_V1_5_WITH_SHA3_224_OID[9]
Definition: rsa.c:79
X509RsaPssParameters rsaPssParams
Definition: x509_common.h:900
const uint8_t ECDSA_WITH_SHA3_512_OID[9]
Definition: ecdsa.c:61
const uint8_t EC_PUBLIC_KEY_OID[7]
Definition: ec.c:43
const uint8_t X509_EXTENDED_KEY_USAGE_OID[3]
Definition: x509_common.c:113
const uint8_t X509_ANY_EXT_KEY_USAGE_OID[4]
Definition: x509_common.c:123
const uint8_t SECP224R1_OID[5]
Definition: ec_curves.c:68
const uint8_t BRAINPOOLP512R1_OID[9]
Definition: ec_curves.c:90
const uint8_t X509_INVALIDITY_DATE_OID[3]
Definition: x509_common.c:93
const uint8_t SECP160K1_OID[5]
Definition: ec_curves.c:56
const uint8_t X509_POLICY_CONSTRAINTS_OID[3]
Definition: x509_common.c:111
const uint8_t SECP256K1_OID[5]
Definition: ec_curves.c:70
const uint8_t ECDSA_WITH_SHA3_256_OID[9]
Definition: ecdsa.c:57
const uint8_t X509_KEY_USAGE_OID[3]
Definition: x509_common.c:81
const uint8_t X509_KP_TIME_STAMPING_OID[8]
Definition: x509_common.c:139
const uint8_t X509_CHALLENGE_PASSWORD_OID[9]
Definition: x509_common.c:152
const uint8_t X509_EXTENSION_REQUEST_OID[9]
Definition: x509_common.c:154
error_t x509GetSignHashAlgo(const X509SignatureAlgoId *signAlgoId, X509SignatureAlgo *signAlgo, const HashAlgo **hashAlgo)
Get the signature and hash algorithms that match the specified identifier.
Definition: x509_common.c:330
const uint8_t BRAINPOOLP384R1_OID[9]
Definition: ec_curves.c:88
const uint8_t X509_ISSUING_DISTR_POINT_OID[3]
Definition: x509_common.c:97
const uint8_t X509_NAME_CONSTRAINTS_OID[3]
Definition: x509_common.c:101
const uint8_t RSASSA_PSS_OID[9]
Definition: rsa.c:88
const uint8_t X509_KP_OCSP_SIGNING_OID[8]
Definition: x509_common.c:141
const uint8_t X509_COUNTRY_NAME_OID[3]
Definition: x509_common.c:52
const uint8_t ECDSA_WITH_SHA256_OID[8]
Definition: ecdsa.c:49
const uint8_t BRAINPOOLP320R1_OID[9]
Definition: ec_curves.c:86
const uint8_t SECP256R1_OID[8]
Definition: ec_curves.c:72
int_t oidComp(const uint8_t *oid1, size_t oidLen1, const uint8_t *oid2, size_t oidLen2)
Compare object identifiers.
Definition: oid.c:103
uint8_t oid[]
Definition: lldp_tlv.h:298
const uint8_t X509_INHIBIT_ANY_POLICY_OID[3]
Definition: x509_common.c:117
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:66
const uint8_t X509_DELTA_CRL_INDICATOR_OID[3]
Definition: x509_common.c:95
const uint8_t DSA_OID[7]
Definition: dsa.c:51
const uint8_t X509_BASIC_CONSTRAINTS_OID[3]
Definition: x509_common.c:87
const uint8_t RSASSA_PKCS1_V1_5_WITH_SHA3_256_OID[9]
Definition: rsa.c:81
#define SHA3_224_HASH_ALGO
Definition: sha3_224.h:47
const uint8_t X509_TITLE_OID[3]
Definition: x509_common.c:62
#define SHA256_OID
Definition: sha256.h:49
const uint8_t SHA384_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:70
const uint8_t SECP112R1_OID[5]
Definition: ec_curves.c:48
const uint8_t SECP521R1_OID[5]
Definition: ec_curves.c:76
@ X509_KEY_TYPE_EC
Definition: x509_common.h:512
#define FALSE
Definition: os_port.h:48
X509SignatureAlgo
Signature algorithms.
Definition: x509_common.h:525
Elliptic curve parameters.
Definition: ec_curves.h:293
const uint8_t BRAINPOOLP160R1_OID[9]
Definition: ec_curves.c:78
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:77
@ X509_SIGN_ALGO_ECDSA
Definition: x509_common.h:530
@ X509_HASH_ALGO_NONE
Definition: x509_common.h:542
const uint8_t X509_LOCALITY_NAME_OID[3]
Definition: x509_common.c:54
#define MD5_HASH_ALGO
Definition: md5.h:51
const uint8_t X509_REASON_CODE_OID[3]
Definition: x509_common.c:91
const uint8_t X509_KP_EMAIL_PROTECTION_OID[8]
Definition: x509_common.c:131
const uint8_t X509_SERIAL_NUMBER_OID[3]
Definition: x509_common.c:50
const uint8_t ECDSA_WITH_SHA384_OID[8]
Definition: ecdsa.c:51
const uint8_t X509_AUTHORITY_KEY_ID_OID[3]
Definition: x509_common.c:109
@ X509_HASH_ALGO_SHA1
Definition: x509_common.h:544
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.
const uint8_t X509_KP_IPSEC_USER_OID[8]
Definition: x509_common.c:137
@ X509_HASH_ALGO_SHA3_224
Definition: x509_common.h:549
const uint8_t SECP128R2_OID[5]
Definition: ec_curves.c:54
const uint8_t SECP160R1_OID[5]
Definition: ec_curves.c:58
@ X509_KEY_TYPE_RSA_PSS
Definition: x509_common.h:510
const uint8_t X509_KP_IPSEC_IKE_OID[8]
Definition: x509_common.c:143
@ X509_HASH_ALGO_SHA224
Definition: x509_common.h:545
const uint8_t X509_CRL_NUMBER_OID[3]
Definition: x509_common.c:89
const uint8_t X509_CERTIFICATE_ISSUER_OID[3]
Definition: x509_common.c:99
const uint8_t ECDSA_WITH_SHA3_224_OID[9]
Definition: ecdsa.c:55
X509HashAlgo
Hash algorithms.
Definition: x509_common.h:541
const uint8_t X509_KP_CLIENT_AUTH_OID[8]
Definition: x509_common.c:127
const uint8_t ECDSA_WITH_SHA1_OID[7]
Definition: ecdsa.c:45
const uint8_t ECDSA_WITH_SHA224_OID[8]
Definition: ecdsa.c:47
@ X509_SIGN_ALGO_RSA
Definition: x509_common.h:527
const uint8_t X509_CRL_DISTR_POINTS_OID[3]
Definition: x509_common.c:103
const uint8_t SHA256_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:68
const uint8_t SECP192R1_OID[8]
Definition: ec_curves.c:64
const uint8_t ED448_OID[3]
Definition: ec_curves.c:98
const uint8_t ECDSA_WITH_SHA512_OID[8]
Definition: ecdsa.c:53
const uint8_t SECP384R1_OID[5]
Definition: ec_curves.c:74
Collection of hash algorithms.
const uint8_t ED25519_OID[3]
Definition: ec_curves.c:96
const uint8_t RSA_ENCRYPTION_OID[9]
Definition: rsa.c:57
const uint8_t X448_OID[3]
Definition: ec_curves.c:94
const uint8_t DSA_WITH_SHA3_384_OID[9]
Definition: dsa.c:67
@ X509_HASH_ALGO_SHA3_512
Definition: x509_common.h:552
#define SHA3_512_OID
Definition: sha3_512.h:45
#define SHA384_HASH_ALGO
Definition: sha384.h:47
const uint8_t SECP192K1_OID[5]
Definition: ec_curves.c:62
const uint8_t X509_KP_SSH_SERVER_OID[8]
Definition: x509_common.c:147
const uint8_t DSA_WITH_SHA3_224_OID[9]
Definition: dsa.c:63
@ X509_HASH_ALGO_MD5
Definition: x509_common.h:543
#define SHA3_256_HASH_ALGO
Definition: sha3_256.h:47
const uint8_t X509_FRESHEST_CRL_OID[3]
Definition: x509_common.c:115
const uint8_t SECP112R2_OID[5]
Definition: ec_curves.c:50
@ X509_SIGN_ALGO_RSA_PSS
Definition: x509_common.h:528
@ X509_KEY_TYPE_ED448
Definition: x509_common.h:516
@ X509_HASH_ALGO_SHA3_256
Definition: x509_common.h:550
@ X509_HASH_ALGO_SHA3_384
Definition: x509_common.h:551
const uint8_t X509_NAME_OID[3]
Definition: x509_common.c:64
const uint8_t ECDSA_WITH_SHA3_384_OID[9]
Definition: ecdsa.c:59
@ X509_HASH_ALGO_SHA512
Definition: x509_common.h:548
const uint8_t X509_NS_CERT_TYPE_OID[9]
Definition: x509_common.c:120
@ X509_KEY_TYPE_DSA
Definition: x509_common.h:511
#define SHA1_OID
Definition: sha1.h:49
#define SHA224_OID
Definition: sha224.h:45
const uint8_t BRAINPOOLP224R1_OID[9]
Definition: ec_curves.c:82
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:297
@ X509_HASH_ALGO_SHA384
Definition: x509_common.h:547
@ X509_HASH_ALGO_SHA256
Definition: x509_common.h:546
const uint8_t BRAINPOOLP192R1_OID[9]
Definition: ec_curves.c:80
const uint8_t X509_KP_IPSEC_TUNNEL_OID[8]
Definition: x509_common.c:135
const uint8_t X509_ORGANIZATIONAL_UNIT_NAME_OID[3]
Definition: x509_common.c:60
const uint8_t SECP160R2_OID[5]
Definition: ec_curves.c:60
const uint8_t X509_SURNAME_OID[3]
Definition: x509_common.c:48
#define SHA224_HASH_ALGO
Definition: sha224.h:47
const uint8_t SHA224_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:66
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:79
Common interface for hash algorithms.
Definition: crypto.h:958
@ X509_KEY_TYPE_UNKNOWN
Definition: x509_common.h:508
const uint8_t X509_KP_IPSEC_END_SYSTEM_OID[8]
Definition: x509_common.c:133
@ ERROR_UNSUPPORTED_SIGNATURE_ALGO
Definition: error.h:132
@ X509_SIGN_ALGO_ED25519
Definition: x509_common.h:531
@ X509_KEY_TYPE_ED25519
Definition: x509_common.h:514
X509KeyType
Public Key types.
Definition: x509_common.h:507
@ X509_SIGN_ALGO_NONE
Definition: x509_common.h:526
X509KeyType x509GetPublicKeyType(const uint8_t *oid, size_t length)
Get the public key type that matches the specified OID.
Definition: x509_common.c:772
const uint8_t X509_STATE_OR_PROVINCE_NAME_OID[]
Definition: x509_common.c:56
#define SHA3_256_OID
Definition: sha3_256.h:45
#define SHA384_OID
Definition: sha384.h:45
const uint8_t SHA1_WITH_RSA_ENCRYPTION_OID[9]
Definition: rsa.c:64
#define SHA3_384_HASH_ALGO
Definition: sha3_384.h:47
@ NO_ERROR
Success.
Definition: error.h:44
const uint8_t SECP128R1_OID[5]
Definition: ec_curves.c:52
Debugging facilities.
@ X509_KEY_TYPE_X25519
Definition: x509_common.h:513
ASN.1 (Abstract Syntax Notation One)
@ X509_SIGN_ALGO_DSA
Definition: x509_common.h:529
const uint8_t * hashAlgo
Definition: x509_common.h:881
@ X509_SIGN_ALGO_ED448
Definition: x509_common.h:532
const uint8_t BRAINPOOLP256R1_OID[9]
Definition: ec_curves.c:84
const uint8_t X509_KP_SSH_CLIENT_OID[8]
Definition: x509_common.c:145