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