27 #ifndef POLARSSL_COMPAT_1_2_H
28 #define POLARSSL_COMPAT_1_2_H
30 #if !defined(POLARSSL_CONFIG_FILE)
33 #include POLARSSL_CONFIG_FILE
37 #define SHOW_PROTOTYPE_CHANGE_WARNINGS
39 #if defined(_MSC_VER) && !defined(inline)
40 #define inline _inline
42 #if defined(__ARMCC_VERSION) && !defined(inline)
43 #define inline __inline
49 #undef SHOW_PROTOTYPE_CHANGE_WARNINGS
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"
56 #if defined(POLARSSL_SHA256_C)
57 #define POLARSSL_SHA2_C
75 static inline int sha2_file(
const char *path,
unsigned char output[32],
int is224 ) {
78 static inline void sha2(
const unsigned char *input,
size_t ilen,
79 unsigned char output[32],
int is224 ) {
80 sha256( input, ilen, output, is224 );
83 size_t keylen,
int is224 ) {
95 static 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 );
105 #if defined(POLARSSL_SHA512_C)
106 #define POLARSSL_SHA4_C
124 static inline int sha4_file(
const char *path,
unsigned char output[64],
int is384 ) {
127 static inline void sha4(
const unsigned char *input,
size_t ilen,
128 unsigned char output[32],
int is384 ) {
129 sha512( input, ilen, output, is384 );
132 size_t keylen,
int is384 ) {
144 static 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 );
154 #if defined(POLARSSL_CIPHER_C)
155 #if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
156 #warning "cipher_reset() prototype changed. Manual change required if used"
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"
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"
182 #if defined(POLARSSL_GCM_C)
183 #if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
184 #warning "gcm_init() prototype changed. Manual change required if used"
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"
194 #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C)
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
220 #if defined(POLARSSL_X509_CRT_PARSE_C)
221 #define POLARSSL_X509_PARSE_C
243 x509_crl *ca_crl,
const char *cn,
int *flags,
244 int (*f_vrfy)(
void *,
x509_cert *,
int,
int *),
246 return x509_crt_verify( crt, trust_ca, ca_crl, cn, flags, f_vrfy, p_vrfy );
256 #if defined(POLARSSL_X509_CRL_PARSE_C)
257 #define POLARSSL_X509_PARSE_C
271 #if defined(POLARSSL_X509_CSR_PARSE_C)
272 #define POLARSSL_X509_PARSE_C
286 #if defined(POLARSSL_SSL_TLS_C)
289 #define ssl_default_ciphersuites ssl_list_ciphersuites()
292 #if defined(POLARSSL_PK_PARSE_C) && defined(POLARSSL_RSA_C)
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
301 #if defined(POLARSSL_FS_IO)
335 const unsigned char *pwd,
size_t pwdlen ) {
351 const unsigned char *key,
size_t keylen )
368 #if defined(POLARSSL_PK_WRITE_C) && defined(POLARSSL_RSA_C)
374 if( ( ret =
rsa_copy(
pk_rsa( ctx ), rsa ) ) != 0 )
return( ret );
383 if( ( ret =
rsa_copy(
pk_rsa( ctx ), rsa ) ) != 0 )
return( ret );