PolarSSL v1.3.1
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 #include "config.h"
31 
32 #include "x509.h"
33 
34 #include "x509_crl.h"
35 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
53 typedef struct _x509_crt
54 {
58  int version;
78  int ext_types;
79  int ca_istrue;
82  unsigned char key_usage;
86  unsigned char ns_cert_type;
92 
93  struct _x509_crt *next;
94 }
95 x509_crt;
96 
97 #define X509_CRT_VERSION_1 0
98 #define X509_CRT_VERSION_2 1
99 #define X509_CRT_VERSION_3 2
100 
101 #define X509_RFC5280_MAX_SERIAL_LEN 32
102 #define X509_RFC5280_UTC_TIME_LEN 15
103 
107 typedef struct _x509write_cert
108 {
109  int version;
119 }
121 
122 #if defined(POLARSSL_X509_CRT_PARSE_C)
123 
133 int x509_crt_parse_der( x509_crt *chain, const unsigned char *buf,
134  size_t buflen );
135 
150 int x509_crt_parse( x509_crt *chain, const unsigned char *buf, size_t buflen );
151 
152 #if defined(POLARSSL_FS_IO)
153 
166 int x509_crt_parse_file( x509_crt *chain, const char *path );
167 
181 int x509_crt_parse_path( x509_crt *chain, const char *path );
182 #endif /* POLARSSL_FS_IO */
183 
196 int x509_crt_info( char *buf, size_t size, const char *prefix,
197  const x509_crt *crt );
198 
235 int x509_crt_verify( x509_crt *crt,
236  x509_crt *trust_ca,
237  x509_crl *ca_crl,
238  const char *cn, int *flags,
239  int (*f_vrfy)(void *, x509_crt *, int, int *),
240  void *p_vrfy );
241 
242 #if defined(POLARSSL_X509_CRL_PARSE_C)
243 
252 int x509_crt_revoked( const x509_crt *crt, const x509_crl *crl );
253 #endif /* POLARSSL_X509_CRL_PARSE_C */
254 
260 void x509_crt_init( x509_crt *crt );
261 
267 void x509_crt_free( x509_crt *crt );
268 #endif /* POLARSSL_X509_CRT_PARSE_C */
269 
270 /* \} name */
271 /* \} addtogroup x509_module */
272 
273 #if defined(POLARSSL_X509_CRT_WRITE_C)
274 
280 
289 void x509write_crt_set_version( x509write_cert *ctx, int version );
290 
299 int x509write_crt_set_serial( x509write_cert *ctx, const mpi *serial );
300 
315 int x509write_crt_set_validity( x509write_cert *ctx, char *not_before,
316  char *not_after );
317 
330 int x509write_crt_set_issuer_name( x509write_cert *ctx, char *issuer_name );
331 
344 int x509write_crt_set_subject_name( x509write_cert *ctx, char *subject_name );
345 
353 
361 
370 
385  const char *oid, size_t oid_len,
386  int critical,
387  const unsigned char *val, size_t val_len );
388 
401  int is_ca, int max_pathlen );
402 
413 
424 
434 int x509write_crt_set_key_usage( x509write_cert *ctx, unsigned char key_usage );
435 
446  unsigned char ns_cert_type );
447 
454 
475 int x509write_crt_der( x509write_cert *ctx, unsigned char *buf, size_t size,
476  int (*f_rng)(void *, unsigned char *, size_t),
477  void *p_rng );
478 
479 #if defined(POLARSSL_PEM_WRITE_C)
480 
496 int x509write_crt_pem( x509write_cert *ctx, unsigned char *buf, size_t size,
497  int (*f_rng)(void *, unsigned char *, size_t),
498  void *p_rng );
499 #endif /* POLARSSL_PEM_WRITE_C */
500 #endif /* POLARSSL_X509_CRT_WRITE_C */
501 
502 #ifdef __cplusplus
503 }
504 #endif
505 
506 #endif /* x509_crt.h */