PolarSSL v1.3.4
oid.c
Go to the documentation of this file.
1 
28 #include "polarssl/config.h"
29 
30 #if defined(POLARSSL_OID_C)
31 
32 #include "polarssl/oid.h"
33 #include "polarssl/rsa.h"
34 
35 #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C)
36 #include "polarssl/x509.h"
37 #endif
38 
39 #include <stdio.h>
40 
41 /*
42  * Macro to automatically add the size of #define'd OIDs
43  */
44 #define ADD_LEN(s) s, OID_SIZE(s)
45 
46 /*
47  * Macro to generate an internal function for oid_XXX_from_asn1() (used by
48  * the other functions)
49  */
50 #define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \
51 static const TYPE_T * oid_ ## NAME ## _from_asn1( const asn1_buf *oid ) \
52 { \
53  const TYPE_T *p = LIST; \
54  const oid_descriptor_t *cur = (const oid_descriptor_t *) p; \
55  if( p == NULL || oid == NULL ) return( NULL ); \
56  while( cur->asn1 != NULL ) { \
57  if( cur->asn1_len == oid->len && \
58  memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \
59  return( p ); \
60  } \
61  p++; \
62  cur = (const oid_descriptor_t *) p; \
63  } \
64  return( NULL ); \
65 }
66 
67 /*
68  * Macro to generate a function for retrieving a single attribute from the
69  * descriptor of an oid_descriptor_t wrapper.
70  */
71 #define FN_OID_GET_DESCRIPTOR_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) \
72 int FN_NAME( const asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
73 { \
74  const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
75  if( data == NULL ) return ( POLARSSL_ERR_OID_NOT_FOUND ); \
76  *ATTR1 = data->descriptor.ATTR1; \
77  return( 0 ); \
78 }
79 
80 /*
81  * Macro to generate a function for retrieving a single attribute from an
82  * oid_descriptor_t wrapper.
83  */
84 #define FN_OID_GET_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) \
85 int FN_NAME( const asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
86 { \
87  const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
88  if( data == NULL ) return ( POLARSSL_ERR_OID_NOT_FOUND ); \
89  *ATTR1 = data->ATTR1; \
90  return( 0 ); \
91 }
92 
93 /*
94  * Macro to generate a function for retrieving two attributes from an
95  * oid_descriptor_t wrapper.
96  */
97 #define FN_OID_GET_ATTR2(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1, \
98  ATTR2_TYPE, ATTR2) \
99 int FN_NAME( const asn1_buf *oid, ATTR1_TYPE * ATTR1, ATTR2_TYPE * ATTR2 ) \
100 { \
101  const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
102  if( data == NULL ) return ( POLARSSL_ERR_OID_NOT_FOUND ); \
103  *ATTR1 = data->ATTR1; \
104  *ATTR2 = data->ATTR2; \
105  return( 0 ); \
106 }
107 
108 /*
109  * Macro to generate a function for retrieving the OID based on a single
110  * attribute from a oid_descriptor_t wrapper.
111  */
112 #define FN_OID_GET_OID_BY_ATTR1(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1) \
113 int FN_NAME( ATTR1_TYPE ATTR1, const char **oid, size_t *olen ) \
114 { \
115  const TYPE_T *cur = LIST; \
116  while( cur->descriptor.asn1 != NULL ) { \
117  if( cur->ATTR1 == ATTR1 ) { \
118  *oid = cur->descriptor.asn1; \
119  *olen = cur->descriptor.asn1_len; \
120  return( 0 ); \
121  } \
122  cur++; \
123  } \
124  return( POLARSSL_ERR_OID_NOT_FOUND ); \
125 }
126 
127 /*
128  * Macro to generate a function for retrieving the OID based on two
129  * attributes from a oid_descriptor_t wrapper.
130  */
131 #define FN_OID_GET_OID_BY_ATTR2(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1, \
132  ATTR2_TYPE, ATTR2) \
133 int FN_NAME( ATTR1_TYPE ATTR1, ATTR2_TYPE ATTR2, const char **oid , \
134  size_t *olen ) \
135 { \
136  const TYPE_T *cur = LIST; \
137  while( cur->descriptor.asn1 != NULL ) { \
138  if( cur->ATTR1 == ATTR1 && cur->ATTR2 == ATTR2 ) { \
139  *oid = cur->descriptor.asn1; \
140  *olen = cur->descriptor.asn1_len; \
141  return( 0 ); \
142  } \
143  cur++; \
144  } \
145  return( POLARSSL_ERR_OID_NOT_FOUND ); \
146 }
147 
148 /*
149  * For X520 attribute types
150  */
151 typedef struct {
152  oid_descriptor_t descriptor;
153  const char *short_name;
154 } oid_x520_attr_t;
155 
156 static const oid_x520_attr_t oid_x520_attr_type[] =
157 {
158  {
159  { ADD_LEN( OID_AT_CN ), "id-at-commonName", "Common Name" },
160  "CN",
161  },
162  {
163  { ADD_LEN( OID_AT_COUNTRY ), "id-at-countryName", "Country" },
164  "C",
165  },
166  {
167  { ADD_LEN( OID_AT_LOCALITY ), "id-at-locality", "Locality" },
168  "L",
169  },
170  {
171  { ADD_LEN( OID_AT_STATE ), "id-at-state", "State" },
172  "ST",
173  },
174  {
175  { ADD_LEN( OID_AT_ORGANIZATION ),"id-at-organizationName", "Organization" },
176  "O",
177  },
178  {
179  { ADD_LEN( OID_AT_ORG_UNIT ), "id-at-organizationalUnitName", "Org Unit" },
180  "OU",
181  },
182  {
183  { ADD_LEN( OID_PKCS9_EMAIL ), "emailAddress", "E-mail address" },
184  "emailAddress",
185  },
186  {
187  { ADD_LEN( OID_AT_SERIAL_NUMBER ),"id-at-serialNumber", "Serial number" },
188  "serialNumber",
189  },
190  {
191  { ADD_LEN( OID_AT_POSTAL_ADDRESS ),"id-at-postalAddress", "Postal address" },
192  "postalAddress",
193  },
194  {
195  { ADD_LEN( OID_AT_POSTAL_CODE ), "id-at-postalCode", "Postal code" },
196  "postalCode",
197  },
198  {
199  { NULL, 0, NULL, NULL },
200  NULL,
201  }
202 };
203 
204 FN_OID_TYPED_FROM_ASN1(oid_x520_attr_t, x520_attr, oid_x520_attr_type);
205 FN_OID_GET_ATTR1(oid_get_attr_short_name, oid_x520_attr_t, x520_attr, const char *, short_name);
206 
207 #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C)
208 /*
209  * For X509 extensions
210  */
211 typedef struct {
212  oid_descriptor_t descriptor;
213  int ext_type;
214 } oid_x509_ext_t;
215 
216 static const oid_x509_ext_t oid_x509_ext[] =
217 {
218  {
219  { ADD_LEN( OID_BASIC_CONSTRAINTS ), "id-ce-basicConstraints", "Basic Constraints" },
221  },
222  {
223  { ADD_LEN( OID_KEY_USAGE ), "id-ce-keyUsage", "Key Usage" },
225  },
226  {
227  { ADD_LEN( OID_EXTENDED_KEY_USAGE ), "id-ce-keyUsage", "Extended Key Usage" },
229  },
230  {
231  { ADD_LEN( OID_SUBJECT_ALT_NAME ), "id-ce-subjectAltName", "Subject Alt Name" },
233  },
234  {
235  { ADD_LEN( OID_NS_CERT_TYPE ), "id-netscape-certtype", "Netscape Certificate Type" },
237  },
238  {
239  { NULL, 0, NULL, NULL },
240  0,
241  },
242 };
243 
244 FN_OID_TYPED_FROM_ASN1(oid_x509_ext_t, x509_ext, oid_x509_ext);
245 FN_OID_GET_ATTR1(oid_get_x509_ext_type, oid_x509_ext_t, x509_ext, int, ext_type);
246 
247 static const oid_descriptor_t oid_ext_key_usage[] =
248 {
249  { ADD_LEN( OID_SERVER_AUTH ), "id-kp-serverAuth", "TLS Web Server Authentication" },
250  { ADD_LEN( OID_CLIENT_AUTH ), "id-kp-clientAuth", "TLS Web Client Authentication" },
251  { ADD_LEN( OID_CODE_SIGNING ), "id-kp-codeSigning", "Code Signing" },
252  { ADD_LEN( OID_EMAIL_PROTECTION ), "id-kp-emailProtection", "E-mail Protection" },
253  { ADD_LEN( OID_TIME_STAMPING ), "id-kp-timeStamping", "Time Stamping" },
254  { ADD_LEN( OID_OCSP_SIGNING ), "id-kp-OCSPSigning", "OCSP Signing" },
255  { NULL, 0, NULL, NULL },
256 };
257 
258 FN_OID_TYPED_FROM_ASN1(oid_descriptor_t, ext_key_usage, oid_ext_key_usage);
259 FN_OID_GET_ATTR1(oid_get_extended_key_usage, oid_descriptor_t, ext_key_usage, const char *, description);
260 #endif /* POLARSSL_X509_USE_C || POLARSSL_X509_CREATE_C */
261 
262 #if defined(POLARSSL_MD_C)
263 /*
264  * For SignatureAlgorithmIdentifier
265  */
266 typedef struct {
267  oid_descriptor_t descriptor;
268  md_type_t md_alg;
269  pk_type_t pk_alg;
270 } oid_sig_alg_t;
271 
272 static const oid_sig_alg_t oid_sig_alg[] =
273 {
274  {
275  { ADD_LEN( OID_PKCS1_MD2 ), "md2WithRSAEncryption", "RSA with MD2" },
277  },
278  {
279  { ADD_LEN( OID_PKCS1_MD4 ), "md4WithRSAEncryption", "RSA with MD4" },
281  },
282  {
283  { ADD_LEN( OID_PKCS1_MD5 ), "md5WithRSAEncryption", "RSA with MD5" },
285  },
286  {
287  { ADD_LEN( OID_PKCS1_SHA1 ), "sha-1WithRSAEncryption", "RSA with SHA1" },
289  },
290  {
291  { ADD_LEN( OID_PKCS1_SHA224 ), "sha224WithRSAEncryption", "RSA with SHA-224" },
293  },
294  {
295  { ADD_LEN( OID_PKCS1_SHA256 ), "sha256WithRSAEncryption", "RSA with SHA-256" },
297  },
298  {
299  { ADD_LEN( OID_PKCS1_SHA384 ), "sha384WithRSAEncryption", "RSA with SHA-384" },
301  },
302  {
303  { ADD_LEN( OID_PKCS1_SHA512 ), "sha512WithRSAEncryption", "RSA with SHA-512" },
305  },
306  {
307  { ADD_LEN( OID_RSA_SHA_OBS ), "sha-1WithRSAEncryption", "RSA with SHA1" },
309  },
310  {
311  { ADD_LEN( OID_ECDSA_SHA1 ), "ecdsa-with-SHA1", "ECDSA with SHA1" },
313  },
314  {
315  { ADD_LEN( OID_ECDSA_SHA224 ), "ecdsa-with-SHA224", "ECDSA with SHA224" },
317  },
318  {
319  { ADD_LEN( OID_ECDSA_SHA256 ), "ecdsa-with-SHA256", "ECDSA with SHA256" },
321  },
322  {
323  { ADD_LEN( OID_ECDSA_SHA384 ), "ecdsa-with-SHA384", "ECDSA with SHA384" },
325  },
326  {
327  { ADD_LEN( OID_ECDSA_SHA512 ), "ecdsa-with-SHA512", "ECDSA with SHA512" },
329  },
330  {
331  { NULL, 0, NULL, NULL },
332  0, 0,
333  },
334 };
335 
336 FN_OID_TYPED_FROM_ASN1(oid_sig_alg_t, sig_alg, oid_sig_alg);
337 FN_OID_GET_DESCRIPTOR_ATTR1(oid_get_sig_alg_desc, oid_sig_alg_t, sig_alg, const char *, description);
338 FN_OID_GET_ATTR2(oid_get_sig_alg, oid_sig_alg_t, sig_alg, md_type_t, md_alg, pk_type_t, pk_alg);
339 FN_OID_GET_OID_BY_ATTR2(oid_get_oid_by_sig_alg, oid_sig_alg_t, oid_sig_alg, pk_type_t, pk_alg, md_type_t, md_alg);
340 #endif /* POLARSSL_MD_C */
341 
342 /*
343  * For PublicKeyInfo (PKCS1, RFC 5480)
344  */
345 typedef struct {
346  oid_descriptor_t descriptor;
347  pk_type_t pk_alg;
348 } oid_pk_alg_t;
349 
350 static const oid_pk_alg_t oid_pk_alg[] =
351 {
352  {
353  { ADD_LEN( OID_PKCS1_RSA ), "rsaEncryption", "RSA" },
355  },
356  {
357  { ADD_LEN( OID_EC_ALG_UNRESTRICTED ), "id-ecPublicKey", "Generic EC key" },
359  },
360  {
361  { ADD_LEN( OID_EC_ALG_ECDH ), "id-ecDH", "EC key for ECDH" },
363  },
364  {
365  { NULL, 0, NULL, NULL },
366  0,
367  },
368 };
369 
370 FN_OID_TYPED_FROM_ASN1(oid_pk_alg_t, pk_alg, oid_pk_alg);
371 FN_OID_GET_ATTR1(oid_get_pk_alg, oid_pk_alg_t, pk_alg, pk_type_t, pk_alg);
372 FN_OID_GET_OID_BY_ATTR1(oid_get_oid_by_pk_alg, oid_pk_alg_t, oid_pk_alg, pk_type_t, pk_alg);
373 
374 #if defined(POLARSSL_ECP_C)
375 /*
376  * For namedCurve (RFC 5480)
377  */
378 typedef struct {
379  oid_descriptor_t descriptor;
380  ecp_group_id grp_id;
381 } oid_ecp_grp_t;
382 
383 static const oid_ecp_grp_t oid_ecp_grp[] =
384 {
385  {
386  { ADD_LEN( OID_EC_GRP_SECP192R1 ), "secp192r1", "secp192r1" },
388  },
389  {
390  { ADD_LEN( OID_EC_GRP_SECP224R1 ), "secp224r1", "secp224r1" },
392  },
393  {
394  { ADD_LEN( OID_EC_GRP_SECP256R1 ), "secp256r1", "secp256r1" },
396  },
397  {
398  { ADD_LEN( OID_EC_GRP_SECP384R1 ), "secp384r1", "secp384r1" },
400  },
401  {
402  { ADD_LEN( OID_EC_GRP_SECP521R1 ), "secp521r1", "secp521r1" },
404  },
405  {
406  { ADD_LEN( OID_EC_GRP_SECP192K1 ), "secp192k1", "secp192k1" },
408  },
409  {
410  { ADD_LEN( OID_EC_GRP_SECP224K1 ), "secp224k1", "secp224k1" },
412  },
413  {
414  { ADD_LEN( OID_EC_GRP_SECP256K1 ), "secp256k1", "secp256k1" },
416  },
417  {
418  { ADD_LEN( OID_EC_GRP_BP256R1 ), "brainpoolP256r1","brainpool256r1" },
420  },
421  {
422  { ADD_LEN( OID_EC_GRP_BP384R1 ), "brainpoolP384r1","brainpool384r1" },
424  },
425  {
426  { ADD_LEN( OID_EC_GRP_BP512R1 ), "brainpoolP512r1","brainpool512r1" },
428  },
429  {
430  { NULL, 0, NULL, NULL },
431  0,
432  },
433 };
434 
435 FN_OID_TYPED_FROM_ASN1(oid_ecp_grp_t, grp_id, oid_ecp_grp);
436 FN_OID_GET_ATTR1(oid_get_ec_grp, oid_ecp_grp_t, grp_id, ecp_group_id, grp_id);
437 FN_OID_GET_OID_BY_ATTR1(oid_get_oid_by_ec_grp, oid_ecp_grp_t, oid_ecp_grp, ecp_group_id, grp_id);
438 #endif /* POLARSSL_ECP_C */
439 
440 #if defined(POLARSSL_CIPHER_C)
441 /*
442  * For PKCS#5 PBES2 encryption algorithm
443  */
444 typedef struct {
445  oid_descriptor_t descriptor;
446  cipher_type_t cipher_alg;
447 } oid_cipher_alg_t;
448 
449 static const oid_cipher_alg_t oid_cipher_alg[] =
450 {
451  {
452  { ADD_LEN( OID_DES_CBC ), "desCBC", "DES-CBC" },
454  },
455  {
456  { ADD_LEN( OID_DES_EDE3_CBC ), "des-ede3-cbc", "DES-EDE3-CBC" },
458  },
459  {
460  { NULL, 0, NULL, NULL },
461  0,
462  },
463 };
464 
465 FN_OID_TYPED_FROM_ASN1(oid_cipher_alg_t, cipher_alg, oid_cipher_alg);
466 FN_OID_GET_ATTR1(oid_get_cipher_alg, oid_cipher_alg_t, cipher_alg, cipher_type_t, cipher_alg);
467 #endif /* POLARSSL_CIPHER_C */
468 
469 #if defined(POLARSSL_MD_C)
470 /*
471  * For digestAlgorithm
472  */
473 typedef struct {
474  oid_descriptor_t descriptor;
475  md_type_t md_alg;
476 } oid_md_alg_t;
477 
478 static const oid_md_alg_t oid_md_alg[] =
479 {
480  {
481  { ADD_LEN( OID_DIGEST_ALG_MD2 ), "id-md2", "MD2" },
483  },
484  {
485  { ADD_LEN( OID_DIGEST_ALG_MD4 ), "id-md4", "MD4" },
487  },
488  {
489  { ADD_LEN( OID_DIGEST_ALG_MD5 ), "id-md5", "MD5" },
491  },
492  {
493  { ADD_LEN( OID_DIGEST_ALG_SHA1 ), "id-sha1", "SHA-1" },
495  },
496  {
497  { ADD_LEN( OID_DIGEST_ALG_SHA1 ), "id-sha1", "SHA-1" },
499  },
500  {
501  { ADD_LEN( OID_DIGEST_ALG_SHA224 ), "id-sha224", "SHA-224" },
503  },
504  {
505  { ADD_LEN( OID_DIGEST_ALG_SHA256 ), "id-sha256", "SHA-256" },
507  },
508  {
509  { ADD_LEN( OID_DIGEST_ALG_SHA384 ), "id-sha384", "SHA-384" },
511  },
512  {
513  { ADD_LEN( OID_DIGEST_ALG_SHA512 ), "id-sha512", "SHA-512" },
515  },
516  {
517  { NULL, 0, NULL, NULL },
518  0,
519  },
520 };
521 
522 FN_OID_TYPED_FROM_ASN1(oid_md_alg_t, md_alg, oid_md_alg);
523 FN_OID_GET_ATTR1(oid_get_md_alg, oid_md_alg_t, md_alg, md_type_t, md_alg);
524 FN_OID_GET_OID_BY_ATTR1(oid_get_oid_by_md, oid_md_alg_t, oid_md_alg, md_type_t, md_alg);
525 #endif /* POLARSSL_MD_C */
526 
527 #if defined(POLARSSL_PKCS12_C)
528 /*
529  * For PKCS#12 PBEs
530  */
531 typedef struct {
532  oid_descriptor_t descriptor;
533  md_type_t md_alg;
534  cipher_type_t cipher_alg;
535 } oid_pkcs12_pbe_alg_t;
536 
537 static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[] =
538 {
539  {
540  { ADD_LEN( OID_PKCS12_PBE_SHA1_DES3_EDE_CBC ), "pbeWithSHAAnd3-KeyTripleDES-CBC", "PBE with SHA1 and 3-Key 3DES" },
542  },
543  {
544  { ADD_LEN( OID_PKCS12_PBE_SHA1_DES2_EDE_CBC ), "pbeWithSHAAnd2-KeyTripleDES-CBC", "PBE with SHA1 and 2-Key 3DES" },
546  },
547  {
548  { NULL, 0, NULL, NULL },
549  0, 0,
550  },
551 };
552 
553 FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg);
554 FN_OID_GET_ATTR2(oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, md_type_t, md_alg, cipher_type_t, cipher_alg);
555 #endif /* POLARSSL_PKCS12_C */
556 
557 #if defined(_MSC_VER) && !defined snprintf && !defined(EFIX64) && \
558  !defined(EFI32)
559 #include <stdarg.h>
560 
561 #if !defined vsnprintf
562 #define vsnprintf _vsnprintf
563 #endif // vsnprintf
564 
565 /*
566  * Windows _snprintf and _vsnprintf are not compatible to linux versions.
567  * Result value is not size of buffer needed, but -1 if no fit is possible.
568  *
569  * This fuction tries to 'fix' this by at least suggesting enlarging the
570  * size by 20.
571  */
572 static int compat_snprintf(char *str, size_t size, const char *format, ...)
573 {
574  va_list ap;
575  int res = -1;
576 
577  va_start( ap, format );
578 
579  res = vsnprintf( str, size, format, ap );
580 
581  va_end( ap );
582 
583  // No quick fix possible
584  if ( res < 0 )
585  return( (int) size + 20 );
586 
587  return res;
588 }
589 
590 #define snprintf compat_snprintf
591 #endif
592 
593 #define POLARSSL_ERR_DEBUG_BUF_TOO_SMALL -2
594 
595 #define SAFE_SNPRINTF() \
596 { \
597  if( ret == -1 ) \
598  return( -1 ); \
599  \
600  if ( (unsigned int) ret > n ) { \
601  p[n - 1] = '\0'; \
602  return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL;\
603  } \
604  \
605  n -= (unsigned int) ret; \
606  p += (unsigned int) ret; \
607 }
608 
609 /* Return the x.y.z.... style numeric string for the given OID */
610 int oid_get_numeric_string( char *buf, size_t size,
611  const asn1_buf *oid )
612 {
613  int ret;
614  size_t i, n;
615  unsigned int value;
616  char *p;
617 
618  p = buf;
619  n = size;
620 
621  /* First byte contains first two dots */
622  if( oid->len > 0 )
623  {
624  ret = snprintf( p, n, "%d.%d", oid->p[0] / 40, oid->p[0] % 40 );
625  SAFE_SNPRINTF();
626  }
627 
628  value = 0;
629  for( i = 1; i < oid->len; i++ )
630  {
631  /* Prevent overflow in value. */
632  if ( ( ( value << 7 ) >> 7 ) != value )
633  return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL );
634 
635  value <<= 7;
636  value += oid->p[i] & 0x7F;
637 
638  if( !( oid->p[i] & 0x80 ) )
639  {
640  /* Last byte */
641  ret = snprintf( p, n, ".%d", value );
642  SAFE_SNPRINTF();
643  value = 0;
644  }
645  }
646 
647  return( (int) ( size - n ) );
648 }
649 
650 #endif /* POLARSSL_OID_C */
#define OID_EC_GRP_BP256R1
Definition: oid.h:310
#define OID_EXTENDED_KEY_USAGE
id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 }
Definition: oid.h:130
#define OID_EC_ALG_UNRESTRICTED
Definition: oid.h:258
#define OID_DIGEST_ALG_SHA384
id-sha384 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) cso...
Definition: oid.h:206
#define OID_PKCS1_SHA224
sha224WithRSAEncryption ::= { pkcs-1 14 }
Definition: oid.h:187
#define EXT_KEY_USAGE
Definition: x509.h:114
#define OID_EC_GRP_SECP192R1
Definition: oid.h:271
int oid_get_numeric_string(char *buf, size_t size, const asn1_buf *oid)
Translate an ASN.1 OID into its numeric representation (e.g.
int oid_get_oid_by_ec_grp(ecp_group_id grp_id, const char **oid, size_t *olen)
Translate EC group identifier into NamedCurve OID.
#define OID_EC_GRP_SECP521R1
Definition: oid.h:287
#define EXT_BASIC_CONSTRAINTS
Definition: x509.h:120
#define OID_PKCS1_MD2
md2WithRSAEncryption ::= { pkcs-1 2 }
Definition: oid.h:183
#define OID_ECDSA_SHA1
Definition: oid.h:326
int oid_get_oid_by_pk_alg(pk_type_t pk_alg, const char **oid, size_t *olen)
Translate pk_type into PublicKeyAlgorithm OID.
int oid_get_pk_alg(const asn1_buf *oid, pk_type_t *pk_alg)
Translate PublicKeyAlgorithm OID into pk_type.
#define OID_DIGEST_ALG_MD5
id-md5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 5 } ...
Definition: oid.h:201
int oid_get_x509_ext_type(const asn1_buf *oid, int *ext_type)
Translate an X.509 extension OID into local values.
Configuration options (set of defines)
#define OID_EC_GRP_BP512R1
Definition: oid.h:316
int oid_get_md_alg(const asn1_buf *oid, md_type_t *md_alg)
Translate hash algorithm OID into md_type.
#define OID_SUBJECT_ALT_NAME
id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 }
Definition: oid.h:124
#define OID_PKCS1_MD4
md4WithRSAEncryption ::= { pkcs-1 3 }
Definition: oid.h:184
#define OID_EC_ALG_ECDH
Definition: oid.h:263
#define OID_PKCS1_MD5
md5WithRSAEncryption ::= { pkcs-1 4 }
Definition: oid.h:185
Base OID descriptor structure.
Definition: oid.h:355
Object Identifier (OID) database.
#define OID_AT_CN
id-at-commonName AttributeType:= {id-at 3}
Definition: oid.h:106
#define OID_DIGEST_ALG_MD2
id-md2 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 2 } ...
Definition: oid.h:199
#define OID_SERVER_AUTH
id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 }
Definition: oid.h:162
md_type_t
Definition: md.h:51
#define OID_EC_GRP_SECP256R1
Definition: oid.h:279
#define OID_PKCS12_PBE_SHA1_DES2_EDE_CBC
pbeWithSHAAnd2-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 4}
Definition: oid.h:248
#define OID_PKCS1_SHA512
sha512WithRSAEncryption ::= { pkcs-1 13 }
Definition: oid.h:190
#define OID_DIGEST_ALG_SHA1
id-sha1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 26 ...
Definition: oid.h:202
#define OID_DIGEST_ALG_SHA256
id-sha256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) cso...
Definition: oid.h:204
cipher_type_t
Definition: cipher.h:75
#define OID_EC_GRP_SECP256K1
Definition: oid.h:299
int oid_get_cipher_alg(const asn1_buf *oid, cipher_type_t *cipher_alg)
Translate encryption algorithm OID into cipher_type.
#define OID_ECDSA_SHA512
Definition: oid.h:346
#define OID_AT_POSTAL_ADDRESS
id-at-postalAddress AttributeType:= {id-at 16}
Definition: oid.h:113
#define OID_AT_ORGANIZATION
id-at-organizationName AttributeType:= {id-at 10}
Definition: oid.h:111
unsigned char * p
ASN1 data, e.g.
Definition: asn1.h:120
int oid_get_sig_alg_desc(const asn1_buf *oid, const char **desc)
Translate SignatureAlgorithm OID into description.
#define OID_EC_GRP_SECP224R1
Definition: oid.h:275
#define OID_DES_EDE3_CBC
des-ede3-cbc OBJECT IDENTIFIER ::= { iso(1) member-body(2) – us(840) rsadsi(113549) encryptionAlgor...
Definition: oid.h:216
#define EXT_NS_CERT_TYPE
Definition: x509.h:128
#define OID_PKCS1_SHA384
sha384WithRSAEncryption ::= { pkcs-1 12 }
Definition: oid.h:189
#define OID_ECDSA_SHA224
Definition: oid.h:331
#define OID_BASIC_CONSTRAINTS
id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 }
Definition: oid.h:127
#define OID_PKCS1_SHA256
sha256WithRSAEncryption ::= { pkcs-1 11 }
Definition: oid.h:188
#define OID_DIGEST_ALG_SHA512
id-sha512 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) cso...
Definition: oid.h:208
#define OID_AT_ORG_UNIT
id-at-organizationalUnitName AttributeType:= {id-at 11}
Definition: oid.h:112
#define OID_AT_POSTAL_CODE
id-at-postalCode AttributeType:= {id-at 17}
Definition: oid.h:114
pk_type_t
Public key types.
Definition: pk.h:90
#define OID_PKCS9_EMAIL
emailAddress AttributeType ::= { pkcs-9 1 }
Definition: oid.h:194
#define OID_EC_GRP_SECP224K1
Definition: oid.h:295
int oid_get_pkcs12_pbe_alg(const asn1_buf *oid, md_type_t *md_alg, cipher_type_t *cipher_alg)
Translate PKCS#12 PBE algorithm OID into md_type and cipher_type.
#define EXT_EXTENDED_KEY_USAGE
Definition: x509.h:123
X.509 generic defines and structures.
#define OID_DIGEST_ALG_MD4
id-md4 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 4 } ...
Definition: oid.h:200
#define OID_AT_LOCALITY
id-at-locality AttributeType:= {id-at 7}
Definition: oid.h:109
#define OID_OCSP_SIGNING
id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 }
Definition: oid.h:167
#define OID_ECDSA_SHA256
Definition: oid.h:336
Type-length-value structure that allows for ASN1 using DER.
Definition: asn1.h:116
The RSA public-key cryptosystem.
#define OID_CODE_SIGNING
id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 }
Definition: oid.h:164
#define OID_EC_GRP_BP384R1
Definition: oid.h:313
int oid_get_ec_grp(const asn1_buf *oid, ecp_group_id *grp_id)
Translate NamedCurve OID into an EC group identifier.
size_t len
ASN1 length, e.g.
Definition: asn1.h:119
ecp_group_id
Domain parameters (curve, subgroup and generator) identifiers.
Definition: ecp.h:56
#define OID_PKCS1_SHA1
sha1WithRSAEncryption ::= { pkcs-1 5 }
Definition: oid.h:186
#define OID_AT_SERIAL_NUMBER
id-at-serialNumber AttributeType:= {id-at 5}
Definition: oid.h:107
int oid_get_oid_by_md(md_type_t md_alg, const char **oid, size_t *olen)
Translate md_type into hash algorithm OID.
#define OID_DIGEST_ALG_SHA224
id-sha224 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) cso...
Definition: oid.h:203
#define OID_DES_CBC
desCBC OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 7 } ...
Definition: oid.h:215
#define OID_CLIENT_AUTH
id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 }
Definition: oid.h:163
#define OID_EC_GRP_SECP192K1
Definition: oid.h:291
#define OID_TIME_STAMPING
id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 }
Definition: oid.h:166
#define OID_ECDSA_SHA384
Definition: oid.h:341
int oid_get_sig_alg(const asn1_buf *oid, md_type_t *md_alg, pk_type_t *pk_alg)
Translate SignatureAlgorithm OID into md_type and pk_type.
int oid_get_attr_short_name(const asn1_buf *oid, const char **short_name)
Translate an X.509 attribute type OID into the short name (e.g.
#define OID_AT_STATE
id-at-state AttributeType:= {id-at 8}
Definition: oid.h:110
#define OID_PKCS1_RSA
rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 }
Definition: oid.h:182
#define OID_NS_CERT_TYPE
Definition: oid.h:139
int oid_get_extended_key_usage(const asn1_buf *oid, const char **desc)
Translate Extended Key Usage OID into description.
#define OID_EMAIL_PROTECTION
id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 }
Definition: oid.h:165
#define OID_AT_COUNTRY
id-at-countryName AttributeType:= {id-at 6}
Definition: oid.h:108
#define OID_PKCS12_PBE_SHA1_DES3_EDE_CBC
pbeWithSHAAnd3-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3}
Definition: oid.h:247
#define OID_RSA_SHA_OBS
Definition: oid.h:192
#define OID_EC_GRP_SECP384R1
Definition: oid.h:283
int oid_get_oid_by_sig_alg(pk_type_t pk_alg, md_type_t md_alg, const char **oid, size_t *olen)
Translate md_type and pk_type into SignatureAlgorithm OID.
#define OID_KEY_USAGE
id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }
Definition: oid.h:121
#define EXT_SUBJECT_ALT_NAME
Definition: x509.h:117