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