PolarSSL v1.3.9
x509_crt.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_X509_CRT_H
28 #define POLARSSL_X509_CRT_H
29 
30 #if !defined(POLARSSL_CONFIG_FILE)
31 #include "config.h"
32 #else
33 #include POLARSSL_CONFIG_FILE
34 #endif
35 
36 #include "x509.h"
37 
38 #include "x509_crl.h"
39 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
57 typedef struct _x509_crt
58 {
62  int version;
82  int ext_types;
83  int ca_istrue;
86  unsigned char key_usage;
90  unsigned char ns_cert_type;
96  void *sig_opts;
98  struct _x509_crt *next;
99 }
100 x509_crt;
101 
102 #define X509_CRT_VERSION_1 0
103 #define X509_CRT_VERSION_2 1
104 #define X509_CRT_VERSION_3 2
105 
106 #define X509_RFC5280_MAX_SERIAL_LEN 32
107 #define X509_RFC5280_UTC_TIME_LEN 15
108 
112 typedef struct _x509write_cert
113 {
114  int version;
124 }
126 
127 #if defined(POLARSSL_X509_CRT_PARSE_C)
128 
138 int x509_crt_parse_der( x509_crt *chain, const unsigned char *buf,
139  size_t buflen );
140 
155 int x509_crt_parse( x509_crt *chain, const unsigned char *buf, size_t buflen );
156 
157 #if defined(POLARSSL_FS_IO)
158 
171 int x509_crt_parse_file( x509_crt *chain, const char *path );
172 
191 int x509_crt_parse_path( x509_crt *chain, const char *path );
192 #endif /* POLARSSL_FS_IO */
193 
206 int x509_crt_info( char *buf, size_t size, const char *prefix,
207  const x509_crt *crt );
208 
245 int x509_crt_verify( x509_crt *crt,
246  x509_crt *trust_ca,
247  x509_crl *ca_crl,
248  const char *cn, int *flags,
249  int (*f_vrfy)(void *, x509_crt *, int, int *),
250  void *p_vrfy );
251 
252 #if defined(POLARSSL_X509_CHECK_KEY_USAGE)
253 
269 int x509_crt_check_key_usage( const x509_crt *crt, int usage );
270 #endif /* POLARSSL_X509_CHECK_KEY_USAGE) */
271 
272 #if defined(POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE)
273 
286  const char *usage_oid,
287  size_t usage_len );
288 #endif /* POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE) */
289 
290 #if defined(POLARSSL_X509_CRL_PARSE_C)
291 
300 int x509_crt_revoked( const x509_crt *crt, const x509_crl *crl );
301 #endif /* POLARSSL_X509_CRL_PARSE_C */
302 
308 void x509_crt_init( x509_crt *crt );
309 
315 void x509_crt_free( x509_crt *crt );
316 #endif /* POLARSSL_X509_CRT_PARSE_C */
317 
318 /* \} name */
319 /* \} addtogroup x509_module */
320 
321 #if defined(POLARSSL_X509_CRT_WRITE_C)
322 
328 
337 void x509write_crt_set_version( x509write_cert *ctx, int version );
338 
347 int x509write_crt_set_serial( x509write_cert *ctx, const mpi *serial );
348 
363 int x509write_crt_set_validity( x509write_cert *ctx, const char *not_before,
364  const char *not_after );
365 
379  const char *issuer_name );
380 
394  const char *subject_name );
395 
403 
411 
420 
435  const char *oid, size_t oid_len,
436  int critical,
437  const unsigned char *val, size_t val_len );
438 
451  int is_ca, int max_pathlen );
452 
453 #if defined(POLARSSL_SHA1_C)
454 
464 
475 #endif /* POLARSSL_SHA1_C */
476 
486 int x509write_crt_set_key_usage( x509write_cert *ctx, unsigned char key_usage );
487 
498  unsigned char ns_cert_type );
499 
506 
527 int x509write_crt_der( x509write_cert *ctx, unsigned char *buf, size_t size,
528  int (*f_rng)(void *, unsigned char *, size_t),
529  void *p_rng );
530 
531 #if defined(POLARSSL_PEM_WRITE_C)
532 
548 int x509write_crt_pem( x509write_cert *ctx, unsigned char *buf, size_t size,
549  int (*f_rng)(void *, unsigned char *, size_t),
550  void *p_rng );
551 #endif /* POLARSSL_PEM_WRITE_C */
552 #endif /* POLARSSL_X509_CRT_WRITE_C */
553 
554 #ifdef __cplusplus
555 }
556 #endif
557 
558 #endif /* x509_crt.h */