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