PolarSSL v1.3.1
compat-1.2.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_COMPAT_1_2_H
28 #define POLARSSL_COMPAT_1_2_H
29 
30 #include "config.h"
31 
32 // Comment out to disable prototype change warnings
33 #define SHOW_PROTOTYPE_CHANGE_WARNINGS
34 
35 #if defined _MSC_VER
36 // MSVC does not support #warning
37 #undef SHOW_PROTOTYPE_CHANGE_WARNINGS
38 #endif
39 
40 #if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
41 #warning "You can disable these warnings by commenting SHOW_PROTOTYPE_CHANGE_WARNINGS in compat-1.2.h"
42 #endif
43 
44 #if defined(POLARSSL_SHA256_C)
45 #define POLARSSL_SHA2_C
46 #include "sha256.h"
47 
48 /*
49  * SHA-2 -> SHA-256
50  */
52 
53 inline void sha2_starts( sha256_context *ctx, int is224 ) {
54  sha256_starts( ctx, is224 );
55 }
56 inline void sha2_update( sha256_context *ctx, const unsigned char *input,
57  size_t ilen ) {
58  sha256_update( ctx, input, ilen );
59 }
60 inline void sha2_finish( sha256_context *ctx, unsigned char output[32] ) {
61  sha256_finish( ctx, output );
62 }
63 inline int sha2_file( const char *path, unsigned char output[32], int is224 ) {
64  return sha256_file( path, output, is224 );
65 }
66 inline void sha2( const unsigned char *input, size_t ilen,
67  unsigned char output[32], int is224 ) {
68  sha256( input, ilen, output, is224 );
69 }
70 inline void sha2_hmac_starts( sha256_context *ctx, const unsigned char *key,
71  size_t keylen, int is224 ) {
72  sha256_hmac_starts( ctx, key, keylen, is224 );
73 }
74 inline void sha2_hmac_update( sha256_context *ctx, const unsigned char *input, size_t ilen ) {
75  sha256_hmac_update( ctx, input, ilen );
76 }
77 inline void sha2_hmac_finish( sha256_context *ctx, unsigned char output[32] ) {
78  sha256_hmac_finish( ctx, output );
79 }
80 inline void sha2_hmac_reset( sha256_context *ctx ) {
81  sha256_hmac_reset( ctx );
82 }
83 inline void sha2_hmac( const unsigned char *key, size_t keylen,
84  const unsigned char *input, size_t ilen,
85  unsigned char output[32], int is224 ) {
86  sha256_hmac( key, keylen, input, ilen, output, is224 );
87 }
88 inline int sha2_self_test( int verbose ) {
89  return sha256_self_test( verbose );
90 }
91 #endif /* POLARSSL_SHA256_C */
92 
93 #if defined(POLARSSL_SHA512_C)
94 #define POLARSSL_SHA4_C
95 #include "sha512.h"
96 
97 /*
98  * SHA-4 -> SHA-512
99  */
101 
102 inline void sha4_starts( sha512_context *ctx, int is384 ) {
103  sha512_starts( ctx, is384 );
104 }
105 inline void sha4_update( sha512_context *ctx, const unsigned char *input,
106  size_t ilen ) {
107  sha512_update( ctx, input, ilen );
108 }
109 inline void sha4_finish( sha512_context *ctx, unsigned char output[64] ) {
110  sha512_finish( ctx, output );
111 }
112 inline int sha4_file( const char *path, unsigned char output[64], int is384 ) {
113  return sha512_file( path, output, is384 );
114 }
115 inline void sha4( const unsigned char *input, size_t ilen,
116  unsigned char output[32], int is384 ) {
117  sha512( input, ilen, output, is384 );
118 }
119 inline void sha4_hmac_starts( sha512_context *ctx, const unsigned char *key,
120  size_t keylen, int is384 ) {
121  sha512_hmac_starts( ctx, key, keylen, is384 );
122 }
123 inline void sha4_hmac_update( sha512_context *ctx, const unsigned char *input, size_t ilen ) {
124  sha512_hmac_update( ctx, input, ilen );
125 }
126 inline void sha4_hmac_finish( sha512_context *ctx, unsigned char output[64] ) {
127  sha512_hmac_finish( ctx, output );
128 }
129 inline void sha4_hmac_reset( sha512_context *ctx ) {
130  sha512_hmac_reset( ctx );
131 }
132 inline void sha4_hmac( const unsigned char *key, size_t keylen,
133  const unsigned char *input, size_t ilen,
134  unsigned char output[64], int is384 ) {
135  sha512_hmac( key, keylen, input, ilen, output, is384 );
136 }
137 inline int sha4_self_test( int verbose ) {
138  return sha512_self_test( verbose );
139 }
140 #endif /* POLARSSL_SHA512_C */
141 
142 #if defined(POLARSSL_CIPHER_C)
143 #if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
144 #warning "cipher_reset() prototype changed. Manual change required if used"
145 #endif
146 #endif
147 
148 #if defined(POLARSSL_RSA_C)
149 #define SIG_RSA_RAW POLARSSL_MD_NONE
150 #define SIG_RSA_MD2 POLARSSL_MD_MD2
151 #define SIG_RSA_MD4 POLARSSL_MD_MD4
152 #define SIG_RSA_MD5 POLARSSL_MD_MD5
153 #define SIG_RSA_SHA1 POLARSSL_MD_SHA1
154 #define SIG_RSA_SHA224 POLARSSL_MD_SHA224
155 #define SIG_RSA_SHA256 POLARSSL_MD_SHA256
156 #define SIG_RSA_SHA384 POLARSSL_MD_SHA384
157 #define SIG_RSA_SHA512 POLARSSL_MD_SHA512
158 #if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
159 #warning "rsa_pkcs1_verify() prototype changed. Manual change required if used"
160 #warning "rsa_pkcs1_decrypt() prototype changed. Manual change required if used"
161 #endif
162 #endif
163 
164 #if defined(POLARSSL_DHM_C)
165 #if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
166 #warning "dhm_calc_secret() prototype changed. Manual change required if used"
167 #endif
168 #endif
169 
170 #if defined(POLARSSL_GCM_C)
171 #if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
172 #warning "gcm_init() prototype changed. Manual change required if used"
173 #endif
174 #endif
175 
176 #if defined(POLARSSL_SSL_CLI_C)
177 #if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
178 #warning "ssl_set_own_cert() prototype changed. Change to ssl_set_own_cert_rsa(). Manual change required if used"
179 #endif
180 #endif
181 
182 #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C)
183 #include "x509.h"
184 
185 #define POLARSSL_ERR_X509_CERT_INVALID_FORMAT POLARSSL_ERR_X509_INVALID_FORMAT
186 #define POLARSSL_ERR_X509_CERT_INVALID_VERSION POLARSSL_ERR_X509_INVALID_VERSION
187 #define POLARSSL_ERR_X509_CERT_INVALID_ALG POLARSSL_ERR_X509_INVALID_ALG
188 #define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG POLARSSL_ERR_X509_UNKNOWN_SIG_ALG
189 #define POLARSSL_ERR_X509_CERT_INVALID_NAME POLARSSL_ERR_X509_INVALID_NAME
190 #define POLARSSL_ERR_X509_CERT_INVALID_DATE POLARSSL_ERR_X509_INVALID_DATE
191 #define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS POLARSSL_ERR_X509_INVALID_EXTENSIONS
192 #define POLARSSL_ERR_X509_CERT_SIG_MISMATCH POLARSSL_ERR_X509_SIG_MISMATCH
193 #define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE POLARSSL_ERR_X509_INVALID_SIGNATURE
194 #define POLARSSL_ERR_X509_CERT_INVALID_SERIAL POLARSSL_ERR_X509_INVALID_SERIAL
195 #define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION POLARSSL_ERR_X509_UNKNOWN_VERSION
196 
197 inline int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial ) {
198  return x509_serial_gets( buf, size, serial );
199 }
200 inline int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn ) {
201  return x509_dn_gets( buf, size, dn );
202 }
203 inline int x509parse_time_expired( const x509_time *time ) {
204  return x509_time_expired( time );
205 }
206 #endif /* POLARSSL_X509_USE_C || POLARSSL_X509_CREATE_C */
207 
208 #if defined(POLARSSL_X509_CRT_PARSE_C)
209 #define POLARSSL_X509_PARSE_C
210 #include "x509_crt.h"
212 
213 inline int x509parse_crt_der( x509_cert *chain, const unsigned char *buf,
214  size_t buflen ) {
215  return x509_crt_parse_der( chain, buf, buflen );
216 }
217 inline int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen ) {
218  return x509_crt_parse( chain, buf, buflen );
219 }
220 inline int x509parse_crtfile( x509_cert *chain, const char *path ) {
221  return x509_crt_parse_file( chain, path );
222 }
223 inline int x509parse_crtpath( x509_cert *chain, const char *path ) {
224  return x509_crt_parse_path( chain, path );
225 }
226 inline int x509parse_cert_info( char *buf, size_t size, const char *prefix,
227  const x509_cert *crt ) {
228  return x509_crt_info( buf, size, prefix, crt );
229 }
230 inline int x509parse_verify( x509_cert *crt, x509_cert *trust_ca,
231  x509_crl *ca_crl, const char *cn, int *flags,
232  int (*f_vrfy)(void *, x509_cert *, int, int *),
233  void *p_vrfy ) {
234  return x509_crt_verify( crt, trust_ca, ca_crl, cn, flags, f_vrfy, p_vrfy );
235 }
236 inline int x509parse_revoked( const x509_cert *crt, const x509_crl *crl ) {
237  return x509_crt_revoked( crt, crl );
238 }
239 inline void x509_free( x509_cert *crt ) {
240  x509_crt_free( crt );
241 }
242 #endif /* POLARSSL_X509_CRT_PARSE_C */
243 
244 #if defined(POLARSSL_X509_CRL_PARSE_C)
245 #define POLARSSL_X509_PARSE_C
246 #include "x509_crl.h"
247 inline int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen ) {
248  return x509_crl_parse( chain, buf, buflen );
249 }
250 inline int x509parse_crlfile( x509_crl *chain, const char *path ) {
251  return x509_crl_parse_file( chain, path );
252 }
253 inline int x509parse_crl_info( char *buf, size_t size, const char *prefix,
254  const x509_crl *crl ) {
255  return x509_crl_info( buf, size, prefix, crl );
256 }
257 #endif /* POLARSSL_X509_CRL_PARSE_C */
258 
259 #if defined(POLARSSL_X509_CSR_PARSE_C)
260 #define POLARSSL_X509_PARSE_C
261 #include "x509_csr.h"
262 inline int x509parse_csr( x509_csr *csr, const unsigned char *buf, size_t buflen ) {
263  return x509_csr_parse( csr, buf, buflen );
264 }
265 inline int x509parse_csrfile( x509_csr *csr, const char *path ) {
266  return x509_csr_parse_file( csr, path );
267 }
268 inline int x509parse_csr_info( char *buf, size_t size, const char *prefix,
269  const x509_csr *csr ) {
270  return x509_csr_info( buf, size, prefix, csr );
271 }
272 #endif /* POLARSSL_X509_CSR_PARSE_C */
273 
274 #if defined(POLARSSL_SSL_TLS_C)
275 #include "ssl_ciphersuites.h"
276 
277 #define ssl_default_ciphersuites ssl_list_ciphersuites()
278 #endif
279 
280 #if defined(POLARSSL_PK_PARSE_C) && defined(POLARSSL_RSA_C)
281 #include "rsa.h"
282 #include "pk.h"
283 
284 #define POLARSSL_ERR_X509_PASSWORD_MISMATCH POLARSSL_ERR_PK_PASSWORD_MISMATCH
285 #define POLARSSL_ERR_X509_KEY_INVALID_FORMAT POLARSSL_ERR_PK_KEY_INVALID_FORMAT
286 #define POLARSSL_ERR_X509_UNKNOWN_PK_ALG POLARSSL_ERR_PK_UNKNOWN_PK_ALG
287 #define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY POLARSSL_ERR_PK_INVALID_PUBKEY
288 
289 #if defined(POLARSSL_FS_IO)
290 inline int x509parse_keyfile( rsa_context *rsa, const char *path,
291  const char *pwd ) {
292  int ret;
293  pk_context pk;
294  pk_init( &pk );
295  ret = pk_parse_keyfile( &pk, path, pwd );
296  if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
298  if( ret == 0 )
299  rsa_copy( rsa, pk_rsa( pk ) );
300  else
301  rsa_free( rsa );
302  pk_free( &pk );
303  return( ret );
304 }
305 inline int x509parse_public_keyfile( rsa_context *rsa, const char *path ) {
306  int ret;
307  pk_context pk;
308  pk_init( &pk );
309  ret = pk_parse_public_keyfile( &pk, path );
310  if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
312  if( ret == 0 )
313  rsa_copy( rsa, pk_rsa( pk ) );
314  else
315  rsa_free( rsa );
316  pk_free( &pk );
317  return( ret );
318 }
319 #endif /* POLARSSL_FS_IO */
320 
321 inline int x509parse_key( rsa_context *rsa, const unsigned char *key,
322  size_t keylen,
323  const unsigned char *pwd, size_t pwdlen ) {
324  int ret;
325  pk_context pk;
326  pk_init( &pk );
327  ret = pk_parse_key( &pk, key, keylen, pwd, pwdlen );
328  if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
330  if( ret == 0 )
331  rsa_copy( rsa, pk_rsa( pk ) );
332  else
333  rsa_free( rsa );
334  pk_free( &pk );
335  return( ret );
336 }
337 
339  const unsigned char *key, size_t keylen )
340 {
341  int ret;
342  pk_context pk;
343  pk_init( &pk );
344  ret = pk_parse_public_key( &pk, key, keylen );
345  if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
347  if( ret == 0 )
348  rsa_copy( rsa, pk_rsa( pk ) );
349  else
350  rsa_free( rsa );
351  pk_free( &pk );
352  return( ret );
353 }
354 #endif /* POLARSSL_PK_PARSE_C && POLARSSL_RSA_C */
355 
356 #if defined(POLARSSL_PK_WRITE_C) && defined(POLARSSL_RSA_C)
357 #include "pk.h"
358 inline int x509_write_pubkey_der( unsigned char *buf, size_t len, rsa_context *rsa ) {
359  int ret;
360  pk_context ctx;
361  if( ( ret = pk_init_ctx( &ctx, pk_info_from_type( POLARSSL_PK_RSA ) ) ) != 0 ) return( ret );
362  if( ( ret = rsa_copy( pk_rsa( ctx ), rsa ) ) != 0 ) return( ret );
363  ret = pk_write_pubkey_der( &ctx, buf, len );
364  pk_free( &ctx );
365  return( ret );
366 }
367 inline int x509_write_key_der( unsigned char *buf, size_t len, rsa_context *rsa ) {
368  int ret;
369  pk_context ctx;
370  if( ( ret = pk_init_ctx( &ctx, pk_info_from_type( POLARSSL_PK_RSA ) ) ) != 0 ) return( ret );
371  if( ( ret = rsa_copy( pk_rsa( ctx ), rsa ) ) != 0 ) return( ret );
372  ret = pk_write_key_der( &ctx, buf, len );
373  pk_free( &ctx );
374  return( ret );
375 }
376 #endif /* POLARSSL_PK_WRITE_C && POLARSSL_RSA_C */
377 #endif /* compat-1.2.h */
void sha2_hmac_reset(sha256_context *ctx)
Definition: compat-1.2.h:80
void sha256_hmac_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 HMAC process buffer.
int sha4_self_test(int verbose)
Definition: compat-1.2.h:137
void sha512_hmac_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 HMAC process buffer.
int x509_time_expired(const x509_time *time)
Check a given x509_time against the system time and check if it is valid.
void sha4_hmac_finish(sha512_context *ctx, unsigned char output[64])
Definition: compat-1.2.h:126
int sha4_file(const char *path, unsigned char output[64], int is384)
Definition: compat-1.2.h:112
const pk_info_t * pk_info_from_type(pk_type_t pk_type)
Return information associated with the given PK type.
int rsa_copy(rsa_context *dst, const rsa_context *src)
Copy the components of an RSA context.
int sha256_file(const char *path, unsigned char output[32], int is224)
Output = SHA-256( file contents )
int x509parse_serial_gets(char *buf, size_t size, const x509_buf *serial)
Definition: compat-1.2.h:197
void sha256_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 process buffer.
void sha256(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = SHA-256( input buffer )
int x509parse_verify(x509_cert *crt, x509_cert *trust_ca, x509_crl *ca_crl, const char *cn, int *flags, int(*f_vrfy)(void *, x509_cert *, int, int *), void *p_vrfy)
Definition: compat-1.2.h:230
void sha2_starts(sha256_context *ctx, int is224)
Definition: compat-1.2.h:53
int pk_write_key_der(pk_context *pk, unsigned char *buf, size_t size)
Write a private key to a PKCS#1 or SEC1 DER structure Note: data is written at the end of the buffer!...
sha256_context sha2_context
Definition: compat-1.2.h:51
int x509parse_crlfile(x509_crl *chain, const char *path)
Definition: compat-1.2.h:250
int x509parse_crtpath(x509_cert *chain, const char *path)
Definition: compat-1.2.h:223
void sha4_hmac_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
Definition: compat-1.2.h:123
int sha2_self_test(int verbose)
Definition: compat-1.2.h:88
void sha256_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = HMAC-SHA-256( hmac key, input buffer )
Container for date and time (precision in seconds).
Definition: x509.h:172
int x509_crt_parse(x509_crt *chain, const unsigned char *buf, size_t buflen)
Parse one or more certificates and add them to the chained list.
void x509_crt_free(x509_crt *crt)
Unallocate all certificate data.
Configuration options (set of defines)
int x509parse_cert_info(char *buf, size_t size, const char *prefix, const x509_cert *crt)
Definition: compat-1.2.h:226
void sha4(const unsigned char *input, size_t ilen, unsigned char output[32], int is384)
Definition: compat-1.2.h:115
void sha2_hmac_starts(sha256_context *ctx, const unsigned char *key, size_t keylen, int is224)
Definition: compat-1.2.h:70
sha512_context sha4_context
Definition: compat-1.2.h:100
int x509_crt_parse_der(x509_crt *chain, const unsigned char *buf, size_t buflen)
Parse a single DER formatted certificate and add it to the chained list.
int x509parse_csrfile(x509_csr *csr, const char *path)
Definition: compat-1.2.h:265
SSL Ciphersuites for PolarSSL.
int x509_crl_parse_file(x509_crl *chain, const char *path)
Load one or more CRLs and add them to the chained list.
Public Key abstraction layer.
int x509_crl_parse(x509_crl *chain, const unsigned char *buf, size_t buflen)
Parse one or more CRLs and add them to the chained list.
int x509_crl_info(char *buf, size_t size, const char *prefix, const x509_crl *crl)
Returns an informational string about the CRL.
void sha256_hmac_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 HMAC final digest.
void rsa_free(rsa_context *ctx)
Free the components of an RSA key.
void sha256_hmac_starts(sha256_context *ctx, const unsigned char *key, size_t keylen, int is224)
SHA-256 HMAC context setup.
RSA context structure.
Definition: rsa.h:77
int x509parse_public_keyfile(rsa_context *rsa, const char *path)
Definition: compat-1.2.h:305
x509_crt x509_cert
Definition: compat-1.2.h:211
Container for an X.509 certificate.
Definition: x509_crt.h:53
int x509parse_crtfile(x509_cert *chain, const char *path)
Definition: compat-1.2.h:220
int x509_dn_gets(char *buf, size_t size, const x509_name *dn)
Store the certificate DN in printable form into buf; no more than size characters will be written...
int sha256_self_test(int verbose)
Checkup routine.
int sha2_file(const char *path, unsigned char output[32], int is224)
Definition: compat-1.2.h:63
void sha256_starts(sha256_context *ctx, int is224)
SHA-256 context setup.
SHA-512 context structure.
Definition: sha512.h:55
void sha512_hmac_finish(sha512_context *ctx, unsigned char output[64])
SHA-512 HMAC final digest.
void sha4_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Definition: compat-1.2.h:132
X.509 certificate signing request parsing and writing.
void sha2_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
Definition: compat-1.2.h:56
int x509parse_csr_info(char *buf, size_t size, const char *prefix, const x509_csr *csr)
Definition: compat-1.2.h:268
void sha512_starts(sha512_context *ctx, int is384)
SHA-512 context setup.
int sha512_self_test(int verbose)
Checkup routine.
int x509_crt_verify(x509_crt *crt, x509_crt *trust_ca, x509_crl *ca_crl, const char *cn, int *flags, int(*f_vrfy)(void *, x509_crt *, int, int *), void *p_vrfy)
Verify the certificate signature.
int pk_can_do(pk_context *ctx, pk_type_t type)
Tell if a context can do the operation given by type.
void sha512(const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = SHA-512( input buffer )
int sha512_file(const char *path, unsigned char output[64], int is384)
Output = SHA-512( file contents )
int x509_write_key_der(unsigned char *buf, size_t len, rsa_context *rsa)
Definition: compat-1.2.h:367
int x509_write_pubkey_der(unsigned char *buf, size_t len, rsa_context *rsa)
Definition: compat-1.2.h:358
X.509 certificate parsing and writing.
void sha4_starts(sha512_context *ctx, int is384)
Definition: compat-1.2.h:102
int pk_parse_public_keyfile(pk_context *ctx, const char *path)
Load and parse a public key.
X.509 generic defines and structures.
int pk_write_pubkey_der(pk_context *key, unsigned char *buf, size_t size)
Write a public key to a SubjectPublicKeyInfo DER structure Note: data is written at the end of the bu...
int x509parse_csr(x509_csr *csr, const unsigned char *buf, size_t buflen)
Definition: compat-1.2.h:262
int x509parse_time_expired(const x509_time *time)
Definition: compat-1.2.h:203
int pk_init_ctx(pk_context *ctx, const pk_info_t *info)
Initialize a PK context with the information given and allocates the type-specific PK subcontext...
void sha512_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = HMAC-SHA-512( hmac key, input buffer )
void sha256_hmac_reset(sha256_context *ctx)
SHA-256 HMAC context reset.
int x509parse_revoked(const x509_cert *crt, const x509_crl *crl)
Definition: compat-1.2.h:236
void sha512_finish(sha512_context *ctx, unsigned char output[64])
SHA-512 final digest.
void sha2(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Definition: compat-1.2.h:66
int x509_crt_revoked(const x509_crt *crt, const x509_crl *crl)
Verify the certificate revocation status.
int x509_csr_parse(x509_csr *csr, const unsigned char *buf, size_t buflen)
Load a Certificate Signing Request (CSR)
Container for a sequence or list of 'named' ASN.1 data items.
Definition: asn1.h:148
Type-length-value structure that allows for ASN1 using DER.
Definition: asn1.h:116
The RSA public-key cryptosystem.
#define pk_rsa(pk)
Quick access to an RSA context inside a PK context.
Definition: pk.h:69
int x509parse_crt_der(x509_cert *chain, const unsigned char *buf, size_t buflen)
Definition: compat-1.2.h:213
void sha4_finish(sha512_context *ctx, unsigned char output[64])
Definition: compat-1.2.h:109
void sha2_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Definition: compat-1.2.h:83
#define POLARSSL_ERR_PK_TYPE_MISMATCH
Type mismatch, eg attempt to encrypt with an ECDSA key.
Definition: pk.h:48
void pk_free(pk_context *ctx)
Free a pk_context.
int pk_parse_public_key(pk_context *ctx, const unsigned char *key, size_t keylen)
Parse a public key.
int x509parse_dn_gets(char *buf, size_t size, const x509_name *dn)
Definition: compat-1.2.h:200
void sha2_finish(sha256_context *ctx, unsigned char output[32])
Definition: compat-1.2.h:60
void sha2_hmac_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
Definition: compat-1.2.h:74
X.509 certificate revocation list parsing.
void pk_init(pk_context *ctx)
Initialize a pk_context (as NONE)
int x509parse_public_key(rsa_context *rsa, const unsigned char *key, size_t keylen)
Definition: compat-1.2.h:338
void sha2_hmac_finish(sha256_context *ctx, unsigned char output[32])
Definition: compat-1.2.h:77
Certificate revocation list structure.
Definition: x509_crl.h:69
SHA-384 and SHA-512 cryptographic hash function.
int x509parse_crt(x509_cert *chain, const unsigned char *buf, size_t buflen)
Definition: compat-1.2.h:217
int x509_csr_info(char *buf, size_t size, const char *prefix, const x509_csr *csr)
Returns an informational string about the CSR.
int pk_parse_key(pk_context *ctx, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen)
Parse a private key.
void sha256_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 final digest.
void sha512_hmac_starts(sha512_context *ctx, const unsigned char *key, size_t keylen, int is384)
SHA-512 HMAC context setup.
int x509parse_keyfile(rsa_context *rsa, const char *path, const char *pwd)
Definition: compat-1.2.h:290
int x509_crt_parse_path(x509_crt *chain, const char *path)
Load one or more certificate files from a path and add them to the chained list.
int x509parse_crl(x509_crl *chain, const unsigned char *buf, size_t buflen)
Definition: compat-1.2.h:247
Certificate Signing Request (CSR) structure.
Definition: x509_csr.h:50
void sha512_hmac_reset(sha512_context *ctx)
SHA-512 HMAC context reset.
SHA-256 context structure.
Definition: sha256.h:54
int x509parse_key(rsa_context *rsa, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen)
Definition: compat-1.2.h:321
int x509_csr_parse_file(x509_csr *csr, const char *path)
Load a Certificate Signing Request (CSR)
void sha4_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
Definition: compat-1.2.h:105
int pk_parse_keyfile(pk_context *ctx, const char *path, const char *password)
Load and parse a private key.
void sha4_hmac_reset(sha512_context *ctx)
Definition: compat-1.2.h:129
int x509_crt_info(char *buf, size_t size, const char *prefix, const x509_crt *crt)
Returns an informational string about the certificate.
void sha4_hmac_starts(sha512_context *ctx, const unsigned char *key, size_t keylen, int is384)
Definition: compat-1.2.h:119
SHA-224 and SHA-256 cryptographic hash function.
int x509parse_crl_info(char *buf, size_t size, const char *prefix, const x509_crl *crl)
Definition: compat-1.2.h:253
void sha512_update(sha512_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 process buffer.
int x509_serial_gets(char *buf, size_t size, const x509_buf *serial)
Store the certificate serial in printable form into buf; no more than size characters will be written...
Public key container.
Definition: pk.h:177
void x509_free(x509_cert *crt)
Definition: compat-1.2.h:239
int x509_crt_parse_file(x509_crt *chain, const char *path)
Load one or more certificates and add them to the chained list.