mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 17:35:38 +01:00
Rm obsolete things (compat-1.2, openssl, etc)
This commit is contained in:
parent
e4d4890350
commit
34be402270
@ -1,386 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file compat-1.2.h
|
|
||||||
*
|
|
||||||
* \brief Backwards compatibility header for PolarSSL-1.2 from PolarSSL-1.3
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2013, ARM Limited, All Rights Reserved
|
|
||||||
*
|
|
||||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
#ifndef POLARSSL_COMPAT_1_2_H
|
|
||||||
#define POLARSSL_COMPAT_1_2_H
|
|
||||||
|
|
||||||
#if !defined(POLARSSL_CONFIG_FILE)
|
|
||||||
#include "config.h"
|
|
||||||
#else
|
|
||||||
#include POLARSSL_CONFIG_FILE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Comment out to disable prototype change warnings
|
|
||||||
#define SHOW_PROTOTYPE_CHANGE_WARNINGS
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(inline)
|
|
||||||
#define inline _inline
|
|
||||||
#else
|
|
||||||
#if defined(__ARMCC_VERSION) && !defined(inline)
|
|
||||||
#define inline __inline
|
|
||||||
#endif /* __ARMCC_VERSION */
|
|
||||||
#endif /* _MSC_VER */
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
// MSVC does not support #warning
|
|
||||||
#undef SHOW_PROTOTYPE_CHANGE_WARNINGS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
|
|
||||||
#warning "You can disable these warnings by commenting SHOW_PROTOTYPE_CHANGE_WARNINGS in compat-1.2.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_SHA256_C)
|
|
||||||
#define POLARSSL_SHA2_C
|
|
||||||
#include "sha256.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SHA-2 -> SHA-256
|
|
||||||
*/
|
|
||||||
typedef sha256_context sha2_context;
|
|
||||||
|
|
||||||
static inline void sha2_starts( sha256_context *ctx, int is224 ) {
|
|
||||||
sha256_starts( ctx, is224 );
|
|
||||||
}
|
|
||||||
static inline void sha2_update( sha256_context *ctx, const unsigned char *input,
|
|
||||||
size_t ilen ) {
|
|
||||||
sha256_update( ctx, input, ilen );
|
|
||||||
}
|
|
||||||
static inline void sha2_finish( sha256_context *ctx, unsigned char output[32] ) {
|
|
||||||
sha256_finish( ctx, output );
|
|
||||||
}
|
|
||||||
static inline int sha2_file( const char *path, unsigned char output[32], int is224 ) {
|
|
||||||
return sha256_file( path, output, is224 );
|
|
||||||
}
|
|
||||||
static inline void sha2( const unsigned char *input, size_t ilen,
|
|
||||||
unsigned char output[32], int is224 ) {
|
|
||||||
sha256( input, ilen, output, is224 );
|
|
||||||
}
|
|
||||||
static inline void sha2_hmac_starts( sha256_context *ctx, const unsigned char *key,
|
|
||||||
size_t keylen, int is224 ) {
|
|
||||||
sha256_hmac_starts( ctx, key, keylen, is224 );
|
|
||||||
}
|
|
||||||
static inline void sha2_hmac_update( sha256_context *ctx, const unsigned char *input, size_t ilen ) {
|
|
||||||
sha256_hmac_update( ctx, input, ilen );
|
|
||||||
}
|
|
||||||
static inline void sha2_hmac_finish( sha256_context *ctx, unsigned char output[32] ) {
|
|
||||||
sha256_hmac_finish( ctx, output );
|
|
||||||
}
|
|
||||||
static inline void sha2_hmac_reset( sha256_context *ctx ) {
|
|
||||||
sha256_hmac_reset( ctx );
|
|
||||||
}
|
|
||||||
static inline void sha2_hmac( const unsigned char *key, size_t keylen,
|
|
||||||
const unsigned char *input, size_t ilen,
|
|
||||||
unsigned char output[32], int is224 ) {
|
|
||||||
sha256_hmac( key, keylen, input, ilen, output, is224 );
|
|
||||||
}
|
|
||||||
static inline int sha2_self_test( int verbose ) {
|
|
||||||
return sha256_self_test( verbose );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_SHA256_C */
|
|
||||||
|
|
||||||
#if defined(POLARSSL_SHA512_C)
|
|
||||||
#define POLARSSL_SHA4_C
|
|
||||||
#include "sha512.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SHA-4 -> SHA-512
|
|
||||||
*/
|
|
||||||
typedef sha512_context sha4_context;
|
|
||||||
|
|
||||||
static inline void sha4_starts( sha512_context *ctx, int is384 ) {
|
|
||||||
sha512_starts( ctx, is384 );
|
|
||||||
}
|
|
||||||
static inline void sha4_update( sha512_context *ctx, const unsigned char *input,
|
|
||||||
size_t ilen ) {
|
|
||||||
sha512_update( ctx, input, ilen );
|
|
||||||
}
|
|
||||||
static inline void sha4_finish( sha512_context *ctx, unsigned char output[64] ) {
|
|
||||||
sha512_finish( ctx, output );
|
|
||||||
}
|
|
||||||
static inline int sha4_file( const char *path, unsigned char output[64], int is384 ) {
|
|
||||||
return sha512_file( path, output, is384 );
|
|
||||||
}
|
|
||||||
static inline void sha4( const unsigned char *input, size_t ilen,
|
|
||||||
unsigned char output[32], int is384 ) {
|
|
||||||
sha512( input, ilen, output, is384 );
|
|
||||||
}
|
|
||||||
static inline void sha4_hmac_starts( sha512_context *ctx, const unsigned char *key,
|
|
||||||
size_t keylen, int is384 ) {
|
|
||||||
sha512_hmac_starts( ctx, key, keylen, is384 );
|
|
||||||
}
|
|
||||||
static inline void sha4_hmac_update( sha512_context *ctx, const unsigned char *input, size_t ilen ) {
|
|
||||||
sha512_hmac_update( ctx, input, ilen );
|
|
||||||
}
|
|
||||||
static inline void sha4_hmac_finish( sha512_context *ctx, unsigned char output[64] ) {
|
|
||||||
sha512_hmac_finish( ctx, output );
|
|
||||||
}
|
|
||||||
static inline void sha4_hmac_reset( sha512_context *ctx ) {
|
|
||||||
sha512_hmac_reset( ctx );
|
|
||||||
}
|
|
||||||
static inline void sha4_hmac( const unsigned char *key, size_t keylen,
|
|
||||||
const unsigned char *input, size_t ilen,
|
|
||||||
unsigned char output[64], int is384 ) {
|
|
||||||
sha512_hmac( key, keylen, input, ilen, output, is384 );
|
|
||||||
}
|
|
||||||
static inline int sha4_self_test( int verbose ) {
|
|
||||||
return sha512_self_test( verbose );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_SHA512_C */
|
|
||||||
|
|
||||||
#if defined(POLARSSL_CIPHER_C)
|
|
||||||
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
|
|
||||||
#warning "cipher_reset() prototype changed. Manual change required if used"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_RSA_C)
|
|
||||||
#define SIG_RSA_RAW POLARSSL_MD_NONE
|
|
||||||
#define SIG_RSA_MD2 POLARSSL_MD_MD2
|
|
||||||
#define SIG_RSA_MD4 POLARSSL_MD_MD4
|
|
||||||
#define SIG_RSA_MD5 POLARSSL_MD_MD5
|
|
||||||
#define SIG_RSA_SHA1 POLARSSL_MD_SHA1
|
|
||||||
#define SIG_RSA_SHA224 POLARSSL_MD_SHA224
|
|
||||||
#define SIG_RSA_SHA256 POLARSSL_MD_SHA256
|
|
||||||
#define SIG_RSA_SHA384 POLARSSL_MD_SHA384
|
|
||||||
#define SIG_RSA_SHA512 POLARSSL_MD_SHA512
|
|
||||||
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
|
|
||||||
#warning "rsa_pkcs1_verify() prototype changed. Manual change required if used"
|
|
||||||
#warning "rsa_pkcs1_decrypt() prototype changed. Manual change required if used"
|
|
||||||
#endif
|
|
||||||
#endif /* POLARSSL_RSA_C */
|
|
||||||
|
|
||||||
#if defined(POLARSSL_DHM_C)
|
|
||||||
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
|
|
||||||
#warning "dhm_calc_secret() prototype changed. Manual change required if used"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_GCM_C)
|
|
||||||
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
|
|
||||||
#warning "gcm_init() prototype changed. Manual change required if used"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_SSL_CLI_C)
|
|
||||||
#if defined(SHOW_PROTOTYPE_CHANGE_WARNINGS)
|
|
||||||
#warning "ssl_set_own_cert() prototype changed. Change to ssl_set_own_cert_rsa(). Manual change required if used"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C)
|
|
||||||
#include "x509.h"
|
|
||||||
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_FORMAT POLARSSL_ERR_X509_INVALID_FORMAT
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_VERSION POLARSSL_ERR_X509_INVALID_VERSION
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_ALG POLARSSL_ERR_X509_INVALID_ALG
|
|
||||||
#define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG POLARSSL_ERR_X509_UNKNOWN_SIG_ALG
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_NAME POLARSSL_ERR_X509_INVALID_NAME
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_DATE POLARSSL_ERR_X509_INVALID_DATE
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS POLARSSL_ERR_X509_INVALID_EXTENSIONS
|
|
||||||
#define POLARSSL_ERR_X509_CERT_SIG_MISMATCH POLARSSL_ERR_X509_SIG_MISMATCH
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE POLARSSL_ERR_X509_INVALID_SIGNATURE
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_SERIAL POLARSSL_ERR_X509_INVALID_SERIAL
|
|
||||||
#define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION POLARSSL_ERR_X509_UNKNOWN_VERSION
|
|
||||||
|
|
||||||
static inline int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial ) {
|
|
||||||
return x509_serial_gets( buf, size, serial );
|
|
||||||
}
|
|
||||||
static inline int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn ) {
|
|
||||||
return x509_dn_gets( buf, size, dn );
|
|
||||||
}
|
|
||||||
static inline int x509parse_time_expired( const x509_time *time ) {
|
|
||||||
return x509_time_expired( time );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_X509_USE_C || POLARSSL_X509_CREATE_C */
|
|
||||||
|
|
||||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
|
||||||
#define POLARSSL_X509_PARSE_C
|
|
||||||
#include "x509_crt.h"
|
|
||||||
typedef x509_crt x509_cert;
|
|
||||||
|
|
||||||
static inline int x509parse_crt_der( x509_cert *chain, const unsigned char *buf,
|
|
||||||
size_t buflen ) {
|
|
||||||
return x509_crt_parse_der( chain, buf, buflen );
|
|
||||||
}
|
|
||||||
static inline int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen ) {
|
|
||||||
return x509_crt_parse( chain, buf, buflen );
|
|
||||||
}
|
|
||||||
static inline int x509parse_crtfile( x509_cert *chain, const char *path ) {
|
|
||||||
return x509_crt_parse_file( chain, path );
|
|
||||||
}
|
|
||||||
static inline int x509parse_crtpath( x509_cert *chain, const char *path ) {
|
|
||||||
return x509_crt_parse_path( chain, path );
|
|
||||||
}
|
|
||||||
static inline int x509parse_cert_info( char *buf, size_t size, const char *prefix,
|
|
||||||
const x509_cert *crt ) {
|
|
||||||
return x509_crt_info( buf, size, prefix, crt );
|
|
||||||
}
|
|
||||||
static inline 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 ) {
|
|
||||||
return x509_crt_verify( crt, trust_ca, ca_crl, cn, flags, f_vrfy, p_vrfy );
|
|
||||||
}
|
|
||||||
static inline int x509parse_revoked( const x509_cert *crt, const x509_crl *crl ) {
|
|
||||||
return x509_crt_revoked( crt, crl );
|
|
||||||
}
|
|
||||||
static inline void x509_free( x509_cert *crt ) {
|
|
||||||
x509_crt_free( crt );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
|
||||||
|
|
||||||
#if defined(POLARSSL_X509_CRL_PARSE_C)
|
|
||||||
#define POLARSSL_X509_PARSE_C
|
|
||||||
#include "x509_crl.h"
|
|
||||||
static inline int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen ) {
|
|
||||||
return x509_crl_parse( chain, buf, buflen );
|
|
||||||
}
|
|
||||||
static inline int x509parse_crlfile( x509_crl *chain, const char *path ) {
|
|
||||||
return x509_crl_parse_file( chain, path );
|
|
||||||
}
|
|
||||||
static inline int x509parse_crl_info( char *buf, size_t size, const char *prefix,
|
|
||||||
const x509_crl *crl ) {
|
|
||||||
return x509_crl_info( buf, size, prefix, crl );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_X509_CRL_PARSE_C */
|
|
||||||
|
|
||||||
#if defined(POLARSSL_X509_CSR_PARSE_C)
|
|
||||||
#define POLARSSL_X509_PARSE_C
|
|
||||||
#include "x509_csr.h"
|
|
||||||
static inline int x509parse_csr( x509_csr *csr, const unsigned char *buf, size_t buflen ) {
|
|
||||||
return x509_csr_parse( csr, buf, buflen );
|
|
||||||
}
|
|
||||||
static inline int x509parse_csrfile( x509_csr *csr, const char *path ) {
|
|
||||||
return x509_csr_parse_file( csr, path );
|
|
||||||
}
|
|
||||||
static inline int x509parse_csr_info( char *buf, size_t size, const char *prefix,
|
|
||||||
const x509_csr *csr ) {
|
|
||||||
return x509_csr_info( buf, size, prefix, csr );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_X509_CSR_PARSE_C */
|
|
||||||
|
|
||||||
#if defined(POLARSSL_SSL_TLS_C)
|
|
||||||
#include "ssl_ciphersuites.h"
|
|
||||||
|
|
||||||
#define ssl_default_ciphersuites ssl_list_ciphersuites()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_PK_PARSE_C) && defined(POLARSSL_RSA_C)
|
|
||||||
#include "rsa.h"
|
|
||||||
#include "pk.h"
|
|
||||||
|
|
||||||
#define POLARSSL_ERR_X509_PASSWORD_MISMATCH POLARSSL_ERR_PK_PASSWORD_MISMATCH
|
|
||||||
#define POLARSSL_ERR_X509_KEY_INVALID_FORMAT POLARSSL_ERR_PK_KEY_INVALID_FORMAT
|
|
||||||
#define POLARSSL_ERR_X509_UNKNOWN_PK_ALG POLARSSL_ERR_PK_UNKNOWN_PK_ALG
|
|
||||||
#define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY POLARSSL_ERR_PK_INVALID_PUBKEY
|
|
||||||
|
|
||||||
#if defined(POLARSSL_FS_IO)
|
|
||||||
static inline int x509parse_keyfile( rsa_context *rsa, const char *path,
|
|
||||||
const char *pwd ) {
|
|
||||||
int ret;
|
|
||||||
pk_context pk;
|
|
||||||
pk_init( &pk );
|
|
||||||
ret = pk_parse_keyfile( &pk, path, pwd );
|
|
||||||
if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
|
|
||||||
ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
|
|
||||||
if( ret == 0 )
|
|
||||||
rsa_copy( rsa, pk_rsa( pk ) );
|
|
||||||
else
|
|
||||||
rsa_free( rsa );
|
|
||||||
pk_free( &pk );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
static inline int x509parse_public_keyfile( rsa_context *rsa, const char *path ) {
|
|
||||||
int ret;
|
|
||||||
pk_context pk;
|
|
||||||
pk_init( &pk );
|
|
||||||
ret = pk_parse_public_keyfile( &pk, path );
|
|
||||||
if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
|
|
||||||
ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
|
|
||||||
if( ret == 0 )
|
|
||||||
rsa_copy( rsa, pk_rsa( pk ) );
|
|
||||||
else
|
|
||||||
rsa_free( rsa );
|
|
||||||
pk_free( &pk );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_FS_IO */
|
|
||||||
|
|
||||||
static inline int x509parse_key( rsa_context *rsa, const unsigned char *key,
|
|
||||||
size_t keylen,
|
|
||||||
const unsigned char *pwd, size_t pwdlen ) {
|
|
||||||
int ret;
|
|
||||||
pk_context pk;
|
|
||||||
pk_init( &pk );
|
|
||||||
ret = pk_parse_key( &pk, key, keylen, pwd, pwdlen );
|
|
||||||
if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
|
|
||||||
ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
|
|
||||||
if( ret == 0 )
|
|
||||||
rsa_copy( rsa, pk_rsa( pk ) );
|
|
||||||
else
|
|
||||||
rsa_free( rsa );
|
|
||||||
pk_free( &pk );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int x509parse_public_key( rsa_context *rsa,
|
|
||||||
const unsigned char *key, size_t keylen )
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
pk_context pk;
|
|
||||||
pk_init( &pk );
|
|
||||||
ret = pk_parse_public_key( &pk, key, keylen );
|
|
||||||
if( ret == 0 && ! pk_can_do( &pk, POLARSSL_PK_RSA ) )
|
|
||||||
ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
|
|
||||||
if( ret == 0 )
|
|
||||||
rsa_copy( rsa, pk_rsa( pk ) );
|
|
||||||
else
|
|
||||||
rsa_free( rsa );
|
|
||||||
pk_free( &pk );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_PK_PARSE_C && POLARSSL_RSA_C */
|
|
||||||
|
|
||||||
#if defined(POLARSSL_PK_WRITE_C) && defined(POLARSSL_RSA_C)
|
|
||||||
#include "pk.h"
|
|
||||||
static inline int x509_write_pubkey_der( unsigned char *buf, size_t len, rsa_context *rsa ) {
|
|
||||||
int ret;
|
|
||||||
pk_context ctx;
|
|
||||||
if( ( ret = pk_init_ctx( &ctx, pk_info_from_type( POLARSSL_PK_RSA ) ) ) != 0 ) return( ret );
|
|
||||||
if( ( ret = rsa_copy( pk_rsa( ctx ), rsa ) ) != 0 ) return( ret );
|
|
||||||
ret = pk_write_pubkey_der( &ctx, buf, len );
|
|
||||||
pk_free( &ctx );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
static inline int x509_write_key_der( unsigned char *buf, size_t len, rsa_context *rsa ) {
|
|
||||||
int ret;
|
|
||||||
pk_context ctx;
|
|
||||||
if( ( ret = pk_init_ctx( &ctx, pk_info_from_type( POLARSSL_PK_RSA ) ) ) != 0 ) return( ret );
|
|
||||||
if( ( ret = rsa_copy( pk_rsa( ctx ), rsa ) ) != 0 ) return( ret );
|
|
||||||
ret = pk_write_key_der( &ctx, buf, len );
|
|
||||||
pk_free( &ctx );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_PK_WRITE_C && POLARSSL_RSA_C */
|
|
||||||
#endif /* compat-1.2.h */
|
|
@ -1,137 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file openssl.h
|
|
||||||
*
|
|
||||||
* \brief OpenSSL wrapper (definitions, inline functions).
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2010, ARM Limited, All Rights Reserved
|
|
||||||
*
|
|
||||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* OpenSSL wrapper contributed by David Barett
|
|
||||||
*/
|
|
||||||
#ifndef POLARSSL_OPENSSL_H
|
|
||||||
#define POLARSSL_OPENSSL_H
|
|
||||||
|
|
||||||
#include "aes.h"
|
|
||||||
#include "md5.h"
|
|
||||||
#include "rsa.h"
|
|
||||||
#include "sha1.h"
|
|
||||||
|
|
||||||
#define AES_SIZE 16
|
|
||||||
#define AES_BLOCK_SIZE 16
|
|
||||||
#define AES_KEY aes_context
|
|
||||||
#define MD5_CTX md5_context
|
|
||||||
#define SHA_CTX sha1_context
|
|
||||||
|
|
||||||
#define SHA1_Init( CTX ) \
|
|
||||||
sha1_starts( (CTX) )
|
|
||||||
#define SHA1_Update( CTX, BUF, LEN ) \
|
|
||||||
sha1_update( (CTX), (unsigned char *)(BUF), (LEN) )
|
|
||||||
#define SHA1_Final( OUT, CTX ) \
|
|
||||||
sha1_finish( (CTX), (OUT) )
|
|
||||||
|
|
||||||
#define MD5_Init( CTX ) \
|
|
||||||
md5_starts( (CTX) )
|
|
||||||
#define MD5_Update( CTX, BUF, LEN ) \
|
|
||||||
md5_update( (CTX), (unsigned char *)(BUF), (LEN) )
|
|
||||||
#define MD5_Final( OUT, CTX ) \
|
|
||||||
md5_finish( (CTX), (OUT) )
|
|
||||||
|
|
||||||
#define AES_set_encrypt_key( KEY, KEYSIZE, CTX ) \
|
|
||||||
aes_setkey_enc( (CTX), (KEY), (KEYSIZE) )
|
|
||||||
#define AES_set_decrypt_key( KEY, KEYSIZE, CTX ) \
|
|
||||||
aes_setkey_dec( (CTX), (KEY), (KEYSIZE) )
|
|
||||||
#define AES_cbc_encrypt( INPUT, OUTPUT, LEN, CTX, IV, MODE ) \
|
|
||||||
aes_crypt_cbc( (CTX), (MODE), (LEN), (IV), (INPUT), (OUTPUT) )
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RSA stuff follows. TODO: needs cleanup
|
|
||||||
*/
|
|
||||||
inline int __RSA_Passthrough( void *output, void *input, int size )
|
|
||||||
{
|
|
||||||
memcpy( output, input, size );
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline rsa_context* d2i_RSA_PUBKEY( void *ignore, unsigned char **bufptr,
|
|
||||||
int len )
|
|
||||||
{
|
|
||||||
unsigned char *buffer = *(unsigned char **) bufptr;
|
|
||||||
rsa_context *rsa;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Not a general-purpose parser: only parses public key from *exactly*
|
|
||||||
* openssl genrsa -out privkey.pem 512 (or 1024)
|
|
||||||
* openssl rsa -in privkey.pem -out privatekey.der -outform der
|
|
||||||
* openssl rsa -in privkey.pem -out pubkey.der -outform der -pubout
|
|
||||||
*
|
|
||||||
* TODO: make a general-purpose parse
|
|
||||||
*/
|
|
||||||
if( ignore != 0 || ( len != 94 && len != 162 ) )
|
|
||||||
return( 0 );
|
|
||||||
|
|
||||||
rsa = (rsa_context *) malloc( sizeof( rsa_rsa ) );
|
|
||||||
if( rsa == NULL )
|
|
||||||
return( 0 );
|
|
||||||
|
|
||||||
memset( rsa, 0, sizeof( rsa_context ) );
|
|
||||||
|
|
||||||
if( ( len == 94 &&
|
|
||||||
mpi_read_binary( &rsa->N, &buffer[ 25], 64 ) == 0 &&
|
|
||||||
mpi_read_binary( &rsa->E, &buffer[ 91], 3 ) == 0 ) ||
|
|
||||||
( len == 162 &&
|
|
||||||
mpi_read_binary( &rsa->N, &buffer[ 29], 128 ) == 0 ) &&
|
|
||||||
mpi_read_binary( &rsa->E, &buffer[159], 3 ) == 0 )
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* key read successfully
|
|
||||||
*/
|
|
||||||
rsa->len = ( mpi_msb( &rsa->N ) + 7 ) >> 3;
|
|
||||||
return( rsa );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memset( rsa, 0, sizeof( rsa_context ) );
|
|
||||||
free( rsa );
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RSA rsa_context
|
|
||||||
#define RSA_PKCS1_PADDING 1 /* ignored; always encrypt with this */
|
|
||||||
#define RSA_size( CTX ) (CTX)->len
|
|
||||||
#define RSA_free( CTX ) rsa_free( CTX )
|
|
||||||
#define ERR_get_error( ) "ERR_get_error() not supported"
|
|
||||||
#define RSA_blinding_off( IGNORE )
|
|
||||||
|
|
||||||
#define d2i_RSAPrivateKey( a, b, c ) new rsa_context /* TODO: C++ bleh */
|
|
||||||
|
|
||||||
inline int RSA_public_decrypt ( int size, unsigned char* input, unsigned char* output, RSA* key, int ignore ) { int outsize=size; if( !rsa_pkcs1_decrypt( key, RSA_PUBLIC, &outsize, input, output ) ) return outsize; else return -1; }
|
|
||||||
inline int RSA_private_decrypt( int size, unsigned char* input, unsigned char* output, RSA* key, int ignore ) { int outsize=size; if( !rsa_pkcs1_decrypt( key, RSA_PRIVATE, &outsize, input, output ) ) return outsize; else return -1; }
|
|
||||||
inline int RSA_public_encrypt ( int size, unsigned char* input, unsigned char* output, RSA* key, int ignore ) { if( !rsa_pkcs1_encrypt( key, RSA_PUBLIC, size, input, output ) ) return RSA_size(key); else return -1; }
|
|
||||||
inline int RSA_private_encrypt( int size, unsigned char* input, unsigned char* output, RSA* key, int ignore ) { if( !rsa_pkcs1_encrypt( key, RSA_PRIVATE, size, input, output ) ) return RSA_size(key); else return -1; }
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* openssl.h */
|
|
2
programs/.gitignore
vendored
2
programs/.gitignore
vendored
@ -43,10 +43,8 @@ ssl/ssl_server2
|
|||||||
ssl/mini_client
|
ssl/mini_client
|
||||||
test/benchmark
|
test/benchmark
|
||||||
test/ecp-bench
|
test/ecp-bench
|
||||||
test/o_p_test
|
|
||||||
test/selftest
|
test/selftest
|
||||||
test/ssl_cert_test
|
test/ssl_cert_test
|
||||||
test/ssl_test
|
|
||||||
test/udp_proxy
|
test/udp_proxy
|
||||||
util/pem2der
|
util/pem2der
|
||||||
util/strerror
|
util/strerror
|
||||||
|
@ -54,16 +54,11 @@ APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \
|
|||||||
random/gen_random_havege$(EXEXT) \
|
random/gen_random_havege$(EXEXT) \
|
||||||
random/gen_random_ctr_drbg$(EXEXT) \
|
random/gen_random_ctr_drbg$(EXEXT) \
|
||||||
test/ssl_cert_test$(EXEXT) test/benchmark$(EXEXT) \
|
test/ssl_cert_test$(EXEXT) test/benchmark$(EXEXT) \
|
||||||
test/selftest$(EXEXT) test/ssl_test$(EXEXT) \
|
test/selftest$(EXEXT) test/udp_proxy$(EXEXT) \
|
||||||
test/udp_proxy$(EXEXT) \
|
|
||||||
util/pem2der$(EXEXT) util/strerror$(EXEXT) \
|
util/pem2der$(EXEXT) util/strerror$(EXEXT) \
|
||||||
x509/cert_app$(EXEXT) x509/crl_app$(EXEXT) \
|
x509/cert_app$(EXEXT) x509/crl_app$(EXEXT) \
|
||||||
x509/cert_req$(EXEXT)
|
x509/cert_req$(EXEXT)
|
||||||
|
|
||||||
ifdef OPENSSL
|
|
||||||
APPS += test/o_p_test
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef PTHREAD
|
ifdef PTHREAD
|
||||||
APPS += ssl/ssl_pthread_server
|
APPS += ssl/ssl_pthread_server
|
||||||
endif
|
endif
|
||||||
@ -240,18 +235,10 @@ test/selftest$(EXEXT): test/selftest.c ../library/libmbedtls.a
|
|||||||
echo " CC test/selftest.c"
|
echo " CC test/selftest.c"
|
||||||
$(CC) $(CFLAGS) $(OFLAGS) test/selftest.c $(LDFLAGS) -o $@
|
$(CC) $(CFLAGS) $(OFLAGS) test/selftest.c $(LDFLAGS) -o $@
|
||||||
|
|
||||||
test/ssl_test$(EXEXT): test/ssl_test.c ../library/libmbedtls.a
|
|
||||||
echo " CC test/ssl_test.c"
|
|
||||||
$(CC) $(CFLAGS) $(OFLAGS) test/ssl_test.c $(LDFLAGS) -o $@
|
|
||||||
|
|
||||||
test/udp_proxy$(EXEXT): test/udp_proxy.c ../library/libmbedtls.a
|
test/udp_proxy$(EXEXT): test/udp_proxy.c ../library/libmbedtls.a
|
||||||
echo " CC test/udp_proxy.c"
|
echo " CC test/udp_proxy.c"
|
||||||
$(CC) $(CFLAGS) $(OFLAGS) test/udp_proxy.c $(LDFLAGS) -o $@
|
$(CC) $(CFLAGS) $(OFLAGS) test/udp_proxy.c $(LDFLAGS) -o $@
|
||||||
|
|
||||||
test/o_p_test$(EXEXT): test/o_p_test.c ../library/libmbedtls.a
|
|
||||||
echo " CC test/o_p_test.c"
|
|
||||||
$(CC) $(CFLAGS) $(OFLAGS) test/o_p_test.c $(LDFLAGS) -o $@ -lssl -lcrypto
|
|
||||||
|
|
||||||
util/pem2der$(EXEXT): util/pem2der.c ../library/libmbedtls.a
|
util/pem2der$(EXEXT): util/pem2der.c ../library/libmbedtls.a
|
||||||
echo " CC util/pem2der.c"
|
echo " CC util/pem2der.c"
|
||||||
$(CC) $(CFLAGS) $(OFLAGS) util/pem2der.c $(LDFLAGS) -o $@
|
$(CC) $(CFLAGS) $(OFLAGS) util/pem2der.c $(LDFLAGS) -o $@
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
FIND_PACKAGE(OpenSSL)
|
|
||||||
|
|
||||||
set(libs
|
set(libs
|
||||||
mbedtls
|
mbedtls
|
||||||
)
|
)
|
||||||
@ -18,26 +16,12 @@ target_link_libraries(selftest ${libs})
|
|||||||
add_executable(benchmark benchmark.c)
|
add_executable(benchmark benchmark.c)
|
||||||
target_link_libraries(benchmark ${libs})
|
target_link_libraries(benchmark ${libs})
|
||||||
|
|
||||||
add_executable(ssl_test ssl_test.c)
|
|
||||||
target_link_libraries(ssl_test ${libs})
|
|
||||||
|
|
||||||
add_executable(ssl_cert_test ssl_cert_test.c)
|
add_executable(ssl_cert_test ssl_cert_test.c)
|
||||||
target_link_libraries(ssl_cert_test ${libs})
|
target_link_libraries(ssl_cert_test ${libs})
|
||||||
|
|
||||||
add_executable(udp_proxy udp_proxy.c)
|
add_executable(udp_proxy udp_proxy.c)
|
||||||
target_link_libraries(udp_proxy ${libs})
|
target_link_libraries(udp_proxy ${libs})
|
||||||
|
|
||||||
install(TARGETS selftest benchmark ssl_test ssl_cert_test udp_proxy
|
install(TARGETS selftest benchmark ssl_cert_test udp_proxy
|
||||||
DESTINATION "bin"
|
DESTINATION "bin"
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||||
|
|
||||||
if(OPENSSL_FOUND)
|
|
||||||
add_executable(o_p_test o_p_test.c)
|
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
||||||
target_link_libraries(o_p_test ${libs} ${OPENSSL_LIBRARIES})
|
|
||||||
|
|
||||||
install(TARGETS o_p_test
|
|
||||||
DESTINATION "bin"
|
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
|
||||||
endif(OPENSSL_FOUND)
|
|
||||||
|
|
||||||
|
@ -1,278 +0,0 @@
|
|||||||
/*
|
|
||||||
* Test application that shows some mbed TLS and OpenSSL compatibility
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011-2012 ARM Limited, All Rights Reserved
|
|
||||||
*
|
|
||||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(POLARSSL_CONFIG_FILE)
|
|
||||||
#include "polarssl/config.h"
|
|
||||||
#else
|
|
||||||
#include POLARSSL_CONFIG_FILE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_PLATFORM_C)
|
|
||||||
#include "polarssl/platform.h"
|
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
|
||||||
#define polarssl_printf printf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_BIGNUM_C) && defined(POLARSSL_RSA_C) && \
|
|
||||||
defined(POLARSSL_PK_PARSE_C) && defined(POLARSSL_FS_IO)
|
|
||||||
#include <openssl/rsa.h>
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
|
||||||
#include <openssl/engine.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <openssl/pem.h>
|
|
||||||
#include <openssl/bio.h>
|
|
||||||
|
|
||||||
#include "polarssl/pk.h"
|
|
||||||
#include "polarssl/x509.h"
|
|
||||||
#include "polarssl/entropy.h"
|
|
||||||
#include "polarssl/ctr_drbg.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_RSA_C) || \
|
|
||||||
!defined(POLARSSL_PK_PARSE_C) || !defined(POLARSSL_FS_IO)
|
|
||||||
int main( void )
|
|
||||||
{
|
|
||||||
polarssl_printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
|
|
||||||
"POLARSSL_PK_PARSE_C and/or POLARSSL_FS_IO not defined.\n");
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int main( int argc, char *argv[] )
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
FILE *key_file;
|
|
||||||
size_t olen;
|
|
||||||
pk_context p_pk;
|
|
||||||
rsa_context *p_rsa;
|
|
||||||
RSA *o_rsa;
|
|
||||||
entropy_context entropy;
|
|
||||||
ctr_drbg_context ctr_drbg;
|
|
||||||
unsigned char input[1024];
|
|
||||||
unsigned char p_pub_encrypted[512];
|
|
||||||
unsigned char o_pub_encrypted[512];
|
|
||||||
unsigned char p_pub_decrypted[512];
|
|
||||||
unsigned char o_pub_decrypted[512];
|
|
||||||
unsigned char p_priv_encrypted[512];
|
|
||||||
unsigned char o_priv_encrypted[512];
|
|
||||||
unsigned char p_priv_decrypted[512];
|
|
||||||
unsigned char o_priv_decrypted[512];
|
|
||||||
const char *pers = "o_p_test_example";
|
|
||||||
|
|
||||||
entropy_init( &entropy );
|
|
||||||
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
|
|
||||||
(const unsigned char *) pers,
|
|
||||||
strlen( pers ) ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
ERR_load_crypto_strings();
|
|
||||||
|
|
||||||
ret = 1;
|
|
||||||
|
|
||||||
if( argc != 3 )
|
|
||||||
{
|
|
||||||
polarssl_printf( "usage: o_p_test <keyfile with private_key> <string of max 100 characters>\n" );
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
polarssl_printf( "\n" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
polarssl_printf( " . Reading private key from %s into mbed TLS ...", argv[1] );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
pk_init( &p_pk );
|
|
||||||
if( pk_parse_keyfile( &p_pk, argv[1], NULL ) != 0 )
|
|
||||||
{
|
|
||||||
ret = 1;
|
|
||||||
polarssl_printf( " failed\n ! Could not load key.\n\n" );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !pk_can_do( &p_pk, POLARSSL_PK_RSA ) )
|
|
||||||
{
|
|
||||||
ret = 1;
|
|
||||||
polarssl_printf( " failed\n ! Key is not an RSA key\n" );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
p_rsa = pk_rsa( p_pk );
|
|
||||||
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
polarssl_printf( " . Reading private key from %s into OpenSSL ...", argv[1] );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
key_file = fopen( argv[1], "r" );
|
|
||||||
o_rsa = PEM_read_RSAPrivateKey(key_file, 0, 0, 0);
|
|
||||||
fclose(key_file);
|
|
||||||
if( o_rsa == NULL )
|
|
||||||
{
|
|
||||||
ret = 1;
|
|
||||||
polarssl_printf( " failed\n ! Could not load key.\n\n" );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
polarssl_printf( "\n" );
|
|
||||||
|
|
||||||
if( strlen( argv[1] ) > 100 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " Input data larger than 100 characters.\n\n" );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy( input, argv[2], strlen( argv[2] ) );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the RSA encryption with public key.
|
|
||||||
*/
|
|
||||||
polarssl_printf( " . Generating the RSA encrypted value with mbed TLS (RSA_PUBLIC) ..." );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( ( ret = rsa_pkcs1_encrypt( p_rsa, ctr_drbg_random, &ctr_drbg, RSA_PUBLIC, strlen( argv[2] ), input, p_pub_encrypted ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " failed\n ! rsa_pkcs1_encrypt returned %d\n\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
polarssl_printf( " . Generating the RSA encrypted value with OpenSSL (PUBLIC) ..." );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( ( ret = RSA_public_encrypt( strlen( argv[2] ), input, o_pub_encrypted, o_rsa, RSA_PKCS1_PADDING ) ) == -1 )
|
|
||||||
{
|
|
||||||
unsigned long code = ERR_get_error();
|
|
||||||
polarssl_printf( " failed\n ! RSA_public_encrypt returned %d %s\n\n", ret, ERR_error_string( code, NULL ) );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the RSA encryption with private key.
|
|
||||||
*/
|
|
||||||
polarssl_printf( " . Generating the RSA encrypted value with mbed TLS (RSA_PRIVATE) ..." );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( ( ret = rsa_pkcs1_encrypt( p_rsa, ctr_drbg_random, &ctr_drbg, RSA_PRIVATE, strlen( argv[2] ), input, p_priv_encrypted ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " failed\n ! rsa_pkcs1_encrypt returned %d\n\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
polarssl_printf( " . Generating the RSA encrypted value with OpenSSL (PRIVATE) ..." );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( ( ret = RSA_private_encrypt( strlen( argv[2] ), input, o_priv_encrypted, o_rsa, RSA_PKCS1_PADDING ) ) == -1 )
|
|
||||||
{
|
|
||||||
unsigned long code = ERR_get_error();
|
|
||||||
polarssl_printf( " failed\n ! RSA_private_encrypt returned %d %s\n\n", ret, ERR_error_string( code, NULL ) );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
polarssl_printf( "\n" );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the RSA decryption with private key.
|
|
||||||
*/
|
|
||||||
polarssl_printf( " . Generating the RSA decrypted value for OpenSSL (PUBLIC) with mbed TLS (PRIVATE) ..." );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( ( ret = rsa_pkcs1_decrypt( p_rsa, ctr_drbg_random, &ctr_drbg, RSA_PRIVATE, &olen, o_pub_encrypted, p_pub_decrypted, 1024 ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " failed\n ! rsa_pkcs1_decrypt returned %d\n\n", ret );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
polarssl_printf( " . Generating the RSA decrypted value for mbed TLS (PUBLIC) with OpenSSL (PRIVATE) ..." );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( ( ret = RSA_private_decrypt( p_rsa->len, p_pub_encrypted, o_pub_decrypted, o_rsa, RSA_PKCS1_PADDING ) ) == -1 )
|
|
||||||
{
|
|
||||||
unsigned long code = ERR_get_error();
|
|
||||||
polarssl_printf( " failed\n ! RSA_private_decrypt returned %d %s\n\n", ret, ERR_error_string( code, NULL ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the RSA decryption with public key.
|
|
||||||
*/
|
|
||||||
polarssl_printf( " . Generating the RSA decrypted value for OpenSSL (PRIVATE) with mbed TLS (PUBLIC) ..." );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( ( ret = rsa_pkcs1_decrypt( p_rsa, NULL, NULL, RSA_PUBLIC, &olen, o_priv_encrypted, p_priv_decrypted, 1024 ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " failed\n ! rsa_pkcs1_decrypt returned %d\n\n", ret );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
polarssl_printf( " . Generating the RSA decrypted value for mbed TLS (PRIVATE) with OpenSSL (PUBLIC) ..." );
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( ( ret = RSA_public_decrypt( p_rsa->len, p_priv_encrypted, o_priv_decrypted, o_rsa, RSA_PKCS1_PADDING ) ) == -1 )
|
|
||||||
{
|
|
||||||
unsigned long code = ERR_get_error();
|
|
||||||
polarssl_printf( " failed\n ! RSA_public_decrypt returned %d %s\n\n", ret, ERR_error_string( code, NULL ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
polarssl_printf( " passed\n");
|
|
||||||
|
|
||||||
polarssl_printf( "\n" );
|
|
||||||
polarssl_printf( "String value (OpenSSL Public Encrypt, mbed TLS Private Decrypt): '%s'\n", p_pub_decrypted );
|
|
||||||
polarssl_printf( "String value (mbed TLS Public Encrypt, OpenSSL Private Decrypt): '%s'\n", o_pub_decrypted );
|
|
||||||
polarssl_printf( "String value (OpenSSL Private Encrypt, mbed TLS Public Decrypt): '%s'\n", p_priv_decrypted );
|
|
||||||
polarssl_printf( "String value (mbed TLS Private Encrypt, OpenSSL Public Decrypt): '%s'\n", o_priv_decrypted );
|
|
||||||
|
|
||||||
exit:
|
|
||||||
ctr_drbg_free( &ctr_drbg );
|
|
||||||
entropy_free( &entropy );
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
polarssl_printf( " + Press Enter to exit this program.\n" );
|
|
||||||
fflush( stdout ); getchar();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_BIGNUM_C && POLARSSL_RSA_C &&
|
|
||||||
POLARSSL_PK_PARSE_C && POLARSSL_FS_IO */
|
|
@ -1,635 +0,0 @@
|
|||||||
/*
|
|
||||||
* SSL/TLS stress testing program
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2013, ARM Limited, All Rights Reserved
|
|
||||||
*
|
|
||||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(POLARSSL_CONFIG_FILE)
|
|
||||||
#include "polarssl/config.h"
|
|
||||||
#else
|
|
||||||
#include POLARSSL_CONFIG_FILE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_PLATFORM_C)
|
|
||||||
#include "polarssl/platform.h"
|
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
|
||||||
#define polarssl_free free
|
|
||||||
#define polarssl_malloc malloc
|
|
||||||
#define polarssl_fprintf fprintf
|
|
||||||
#define polarssl_printf printf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_BIGNUM_C) && defined(POLARSSL_ENTROPY_C) && \
|
|
||||||
defined(POLARSSL_SSL_TLS_C) && defined(POLARSSL_SSL_SRV_C) && \
|
|
||||||
defined(POLARSSL_SSL_CLI_C) && defined(POLARSSL_NET_C) && \
|
|
||||||
defined(POLARSSL_RSA_C) && defined(POLARSSL_CTR_DRBG_C) && \
|
|
||||||
defined(POLARSSL_X509_CRT_PARSE_C)
|
|
||||||
#include "polarssl/net.h"
|
|
||||||
#include "polarssl/ssl.h"
|
|
||||||
#include "polarssl/entropy.h"
|
|
||||||
#include "polarssl/ctr_drbg.h"
|
|
||||||
#include "polarssl/certs.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(POLARSSL_TIMING_C)
|
|
||||||
#include "polarssl/timing.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define OPMODE_NONE 0
|
|
||||||
#define OPMODE_CLIENT 1
|
|
||||||
#define OPMODE_SERVER 2
|
|
||||||
|
|
||||||
#define IOMODE_BLOCK 0
|
|
||||||
#define IOMODE_NONBLOCK 1
|
|
||||||
|
|
||||||
#define COMMAND_READ 1
|
|
||||||
#define COMMAND_WRITE 2
|
|
||||||
#define COMMAND_BOTH 3
|
|
||||||
|
|
||||||
#define DFL_OPMODE OPMODE_NONE
|
|
||||||
#define DFL_IOMODE IOMODE_BLOCK
|
|
||||||
#define DFL_SERVER_NAME "localhost"
|
|
||||||
#define DFL_SERVER_PORT 4433
|
|
||||||
#define DFL_COMMAND COMMAND_READ
|
|
||||||
#define DFL_BUFFER_SIZE 1024
|
|
||||||
#define DFL_MAX_BYTES 0
|
|
||||||
#define DFL_DEBUG_LEVEL 0
|
|
||||||
#define DFL_CONN_TIMEOUT 0
|
|
||||||
#define DFL_MAX_CONNECTIONS 0
|
|
||||||
#define DFL_SESSION_REUSE 1
|
|
||||||
#define DFL_SESSION_LIFETIME 86400
|
|
||||||
#define DFL_FORCE_CIPHER 0
|
|
||||||
|
|
||||||
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_ENTROPY_C) || \
|
|
||||||
!defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_SRV_C) || \
|
|
||||||
!defined(POLARSSL_SSL_CLI_C) || !defined(POLARSSL_NET_C) || \
|
|
||||||
!defined(POLARSSL_RSA_C) || !defined(POLARSSL_CTR_DRBG_C) || \
|
|
||||||
!defined(POLARSSL_X509_CRT_PARSE_C)
|
|
||||||
int main( void )
|
|
||||||
{
|
|
||||||
polarssl_printf("POLARSSL_BIGNUM_C and/or POLARSSL_ENTROPY_C and/or "
|
|
||||||
"POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or "
|
|
||||||
"POLARSSL_SSL_CLI_C and/or POLARSSL_NET_C and/or "
|
|
||||||
"POLARSSL_RSA_C and/or POLARSSL_CTR_DRBG_C and/or "
|
|
||||||
"POLARSSL_X509_CRT_PARSE_C not defined.\n");
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
int server_fd = -1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* global options
|
|
||||||
*/
|
|
||||||
struct options
|
|
||||||
{
|
|
||||||
int opmode; /* operation mode (client or server) */
|
|
||||||
int iomode; /* I/O mode (blocking or non-blocking) */
|
|
||||||
const char *server_name; /* hostname of the server (client only) */
|
|
||||||
int server_port; /* port on which the ssl service runs */
|
|
||||||
int command; /* what to do: read or write operation */
|
|
||||||
int buffer_size; /* size of the send/receive buffer */
|
|
||||||
int max_bytes; /* max. # of bytes before a reconnect */
|
|
||||||
int debug_level; /* level of debugging */
|
|
||||||
#if defined(POLARSSL_TIMING_C)
|
|
||||||
int conn_timeout; /* max. delay before a reconnect */
|
|
||||||
#endif
|
|
||||||
int max_connections; /* max. number of reconnections */
|
|
||||||
int session_reuse; /* flag to reuse the keying material */
|
|
||||||
int session_lifetime; /* if reached, session data is expired */
|
|
||||||
int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Although this PRNG has good statistical properties (eg. passes
|
|
||||||
* DIEHARD), it is not cryptographically secure.
|
|
||||||
*/
|
|
||||||
static unsigned long int lcppm5( unsigned long int *state )
|
|
||||||
{
|
|
||||||
unsigned long int u, v;
|
|
||||||
|
|
||||||
u = v = state[4] ^ 1;
|
|
||||||
state[u & 3] ^= u;
|
|
||||||
u ^= (v << 12) ^ (v >> 12);
|
|
||||||
u ^= v * state[0]; v >>= 8;
|
|
||||||
u ^= v * state[1]; v >>= 8;
|
|
||||||
u ^= v * state[2]; v >>= 8;
|
|
||||||
u ^= v * state[3];
|
|
||||||
u &= 0xFFFFFFFF;
|
|
||||||
state[4] = u;
|
|
||||||
|
|
||||||
return( u );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void my_debug( void *ctx, int level, const char *str )
|
|
||||||
{
|
|
||||||
if( level < ((struct options *) ctx)->debug_level )
|
|
||||||
polarssl_fprintf( stderr, "%s", str );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* perform a single SSL connection
|
|
||||||
*/
|
|
||||||
static int ssl_test( struct options *opt )
|
|
||||||
{
|
|
||||||
int ret = 1, i;
|
|
||||||
int client_fd = -1;
|
|
||||||
int bytes_to_read;
|
|
||||||
int bytes_to_write;
|
|
||||||
int offset_to_read = 0;
|
|
||||||
int offset_to_write = 0;
|
|
||||||
|
|
||||||
long int nb_read;
|
|
||||||
long int nb_written;
|
|
||||||
|
|
||||||
unsigned long read_state[5];
|
|
||||||
unsigned long write_state[5];
|
|
||||||
|
|
||||||
unsigned char *read_buf = NULL;
|
|
||||||
unsigned char *write_buf = NULL;
|
|
||||||
|
|
||||||
const char *pers = "ssl_test";
|
|
||||||
|
|
||||||
#if defined(POLARSSL_TIMING_C)
|
|
||||||
struct hr_time t;
|
|
||||||
#endif
|
|
||||||
entropy_context entropy;
|
|
||||||
ctr_drbg_context ctr_drbg;
|
|
||||||
ssl_context ssl;
|
|
||||||
x509_crt srvcert;
|
|
||||||
pk_context pkey;
|
|
||||||
|
|
||||||
memset( &ssl, 0, sizeof(ssl_context) );
|
|
||||||
entropy_init( &entropy );
|
|
||||||
x509_crt_init( &srvcert );
|
|
||||||
pk_init( &pkey );
|
|
||||||
|
|
||||||
if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
|
|
||||||
(const unsigned char *) pers,
|
|
||||||
strlen( pers ) ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! ctr_drbg_init returned %d\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(POLARSSL_TIMING_C)
|
|
||||||
get_timer( &t, 1 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memset( read_state, 0, sizeof( read_state ) );
|
|
||||||
memset( write_state, 0, sizeof( write_state ) );
|
|
||||||
|
|
||||||
|
|
||||||
if( opt->opmode == OPMODE_CLIENT )
|
|
||||||
{
|
|
||||||
if( ( ret = net_connect( &client_fd, opt->server_name,
|
|
||||||
opt->server_port, NET_PROTO_TCP ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! net_connect returned %d\n\n", ret );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( ret = ssl_init( &ssl ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! ssl_init returned %d\n\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssl_set_endpoint( &ssl, SSL_IS_CLIENT );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( opt->opmode == OPMODE_SERVER )
|
|
||||||
{
|
|
||||||
#if !defined(POLARSSL_CERTS_C)
|
|
||||||
polarssl_printf("POLARSSL_CERTS_C not defined.\n");
|
|
||||||
goto exit;
|
|
||||||
#else
|
|
||||||
ret = x509_crt_parse( &srvcert, (const unsigned char *) test_srv_crt,
|
|
||||||
strlen( test_srv_crt ) );
|
|
||||||
if( ret != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! x509_crt_parse returned %d\n\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_list,
|
|
||||||
strlen( test_ca_list ) );
|
|
||||||
if( ret != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! x509_crt_parse returned %d\n\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = pk_parse_key( &pkey, (const unsigned char *) test_srv_key,
|
|
||||||
strlen( test_srv_key ), NULL, 0 );
|
|
||||||
if( ret != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! pk_parse_key returned %d\n\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( server_fd < 0 )
|
|
||||||
{
|
|
||||||
if( ( ret = net_bind( &server_fd, NULL,
|
|
||||||
opt->server_port, NET_PROTO_TCP ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! net_bind returned %d\n\n", ret );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( ret = net_accept( server_fd, &client_fd, NULL ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! net_accept returned %d\n\n", ret );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( ret = ssl_init( &ssl ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! ssl_init returned %d\n\n", ret );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
ssl_set_endpoint( &ssl, SSL_IS_SERVER );
|
|
||||||
ssl_set_ca_chain( &ssl, srvcert.next, NULL, NULL );
|
|
||||||
if( ( ret = ssl_set_own_cert( &ssl, &srvcert, &pkey ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " failed\n ! ssl_set_own_cert returned %d\n\n", ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ssl_set_authmode( &ssl, SSL_VERIFY_NONE );
|
|
||||||
|
|
||||||
ssl_set_rng( &ssl, ctr_drbg_random, &ctr_drbg );
|
|
||||||
ssl_set_dbg( &ssl, my_debug, opt );
|
|
||||||
ssl_set_bio( &ssl, net_recv, &client_fd,
|
|
||||||
net_send, &client_fd );
|
|
||||||
|
|
||||||
if( opt->force_ciphersuite[0] != DFL_FORCE_CIPHER )
|
|
||||||
ssl_set_ciphersuites( &ssl, opt->force_ciphersuite );
|
|
||||||
|
|
||||||
if( opt->iomode == IOMODE_NONBLOCK )
|
|
||||||
{
|
|
||||||
if( ( ret = net_set_nonblock( client_fd ) ) != 0 )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! net_set_nonblock returned %d\n\n", ret );
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
read_buf = polarssl_malloc( opt->buffer_size );
|
|
||||||
write_buf = polarssl_malloc( opt->buffer_size );
|
|
||||||
|
|
||||||
if( read_buf == NULL || write_buf == NULL )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! polarssl_malloc(%d bytes) failed\n\n", opt->buffer_size );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
nb_read = bytes_to_read = 0;
|
|
||||||
nb_written = bytes_to_write = 0;
|
|
||||||
|
|
||||||
while( 1 )
|
|
||||||
{
|
|
||||||
if( opt->command & COMMAND_WRITE )
|
|
||||||
{
|
|
||||||
if( bytes_to_write == 0 )
|
|
||||||
{
|
|
||||||
while( bytes_to_write == 0 )
|
|
||||||
bytes_to_write = rand() % opt->buffer_size;
|
|
||||||
|
|
||||||
for( i = 0; i < bytes_to_write; i++ )
|
|
||||||
write_buf[i] = (unsigned char) lcppm5( write_state );
|
|
||||||
|
|
||||||
offset_to_write = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ssl_write( &ssl, write_buf + offset_to_write,
|
|
||||||
bytes_to_write );
|
|
||||||
|
|
||||||
if( ret >= 0 )
|
|
||||||
{
|
|
||||||
nb_written += ret;
|
|
||||||
bytes_to_write -= ret;
|
|
||||||
offset_to_write += ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY ||
|
|
||||||
ret == POLARSSL_ERR_NET_CONN_RESET )
|
|
||||||
{
|
|
||||||
ret = 0;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ret < 0 && ret != POLARSSL_ERR_NET_WANT_READ &&
|
|
||||||
ret != POLARSSL_ERR_NET_WANT_WRITE )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! ssl_write returned %d\n\n", ret );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( opt->command & COMMAND_READ )
|
|
||||||
{
|
|
||||||
while( bytes_to_read == 0 )
|
|
||||||
{
|
|
||||||
bytes_to_read = rand() % opt->buffer_size;
|
|
||||||
offset_to_read = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = ssl_read( &ssl, read_buf + offset_to_read,
|
|
||||||
bytes_to_read );
|
|
||||||
|
|
||||||
if( ret > 0 )
|
|
||||||
{
|
|
||||||
for( i = 0; i < ret; i++ )
|
|
||||||
{
|
|
||||||
if( read_buf[offset_to_read + i] !=
|
|
||||||
(unsigned char) lcppm5( read_state ) )
|
|
||||||
{
|
|
||||||
ret = 1;
|
|
||||||
polarssl_printf( " ! plaintext mismatch\n\n" );
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nb_read += ret;
|
|
||||||
bytes_to_read -= ret;
|
|
||||||
offset_to_read += ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ret == 0 ||
|
|
||||||
ret == POLARSSL_ERR_SSL_CONN_EOF ||
|
|
||||||
ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY ||
|
|
||||||
ret == POLARSSL_ERR_NET_CONN_RESET )
|
|
||||||
{
|
|
||||||
ret = 0;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ret < 0 && ret != POLARSSL_ERR_NET_WANT_READ &&
|
|
||||||
ret != POLARSSL_ERR_NET_WANT_WRITE )
|
|
||||||
{
|
|
||||||
polarssl_printf( " ! ssl_read returned %d\n\n", ret );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
if( opt->max_bytes != 0 &&
|
|
||||||
( opt->max_bytes <= nb_read ||
|
|
||||||
opt->max_bytes <= nb_written ) )
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(POLARSSL_TIMING_C)
|
|
||||||
if( opt->conn_timeout != 0 &&
|
|
||||||
opt->conn_timeout <= (int) get_timer( &t, 0 ) )
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
|
||||||
|
|
||||||
fflush( stdout );
|
|
||||||
|
|
||||||
if( read_buf != NULL )
|
|
||||||
free( read_buf );
|
|
||||||
|
|
||||||
if( write_buf != NULL )
|
|
||||||
free( write_buf );
|
|
||||||
|
|
||||||
ssl_close_notify( &ssl );
|
|
||||||
x509_crt_free( &srvcert );
|
|
||||||
pk_free( &pkey );
|
|
||||||
ssl_free( &ssl );
|
|
||||||
ctr_drbg_free( &ctr_drbg );
|
|
||||||
entropy_free( &entropy );
|
|
||||||
|
|
||||||
if( client_fd != -1 )
|
|
||||||
net_close( client_fd );
|
|
||||||
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(POLARSSL_TIMING_C)
|
|
||||||
#define USAGE_TIMING \
|
|
||||||
" conn_timeout=%%d (ms) default: 0 (no timeout)\n"
|
|
||||||
#else
|
|
||||||
#define USAGE_TIMING ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define USAGE \
|
|
||||||
"\n usage: ssl_test opmode=<> command=<>...\n" \
|
|
||||||
"\n acceptable parameters:\n" \
|
|
||||||
" opmode=client/server default: <none>\n" \
|
|
||||||
" iomode=block/nonblock default: block\n" \
|
|
||||||
" server_name=%%s default: localhost\n" \
|
|
||||||
" server_port=%%d default: 4433\n" \
|
|
||||||
" command=read/write/both default: read\n" \
|
|
||||||
" buffer_size=%%d (bytes) default: 1024\n" \
|
|
||||||
" max_bytes=%%d (bytes) default: 0 (no limit)\n" \
|
|
||||||
" debug_level=%%d default: 0 (disabled)\n" \
|
|
||||||
USAGE_TIMING \
|
|
||||||
" max_connections=%%d default: 0 (no limit)\n" \
|
|
||||||
" session_reuse=on/off default: on (enabled)\n" \
|
|
||||||
" session_lifetime=%%d (s) default: 86400\n" \
|
|
||||||
" force_ciphersuite=<name> default: all enabled\n" \
|
|
||||||
" acceptable ciphersuite names:\n"
|
|
||||||
|
|
||||||
int main( int argc, char *argv[] )
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
const int *list;
|
|
||||||
int ret = 1;
|
|
||||||
int nb_conn;
|
|
||||||
char *p, *q;
|
|
||||||
struct options opt;
|
|
||||||
|
|
||||||
if( argc == 1 )
|
|
||||||
{
|
|
||||||
usage:
|
|
||||||
polarssl_printf( USAGE );
|
|
||||||
|
|
||||||
list = ssl_list_ciphersuites();
|
|
||||||
while( *list )
|
|
||||||
{
|
|
||||||
polarssl_printf(" %s\n", ssl_get_ciphersuite_name( *list ) );
|
|
||||||
list++;
|
|
||||||
}
|
|
||||||
polarssl_printf("\n");
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
opt.opmode = DFL_OPMODE;
|
|
||||||
opt.iomode = DFL_IOMODE;
|
|
||||||
opt.server_name = DFL_SERVER_NAME;
|
|
||||||
opt.server_port = DFL_SERVER_PORT;
|
|
||||||
opt.command = DFL_COMMAND;
|
|
||||||
opt.buffer_size = DFL_BUFFER_SIZE;
|
|
||||||
opt.max_bytes = DFL_MAX_BYTES;
|
|
||||||
opt.debug_level = DFL_DEBUG_LEVEL;
|
|
||||||
#if defined(POLARSSL_TIMING_C)
|
|
||||||
opt.conn_timeout = DFL_CONN_TIMEOUT;
|
|
||||||
#endif
|
|
||||||
opt.max_connections = DFL_MAX_CONNECTIONS;
|
|
||||||
opt.session_reuse = DFL_SESSION_REUSE;
|
|
||||||
opt.session_lifetime = DFL_SESSION_LIFETIME;
|
|
||||||
opt.force_ciphersuite[0] = DFL_FORCE_CIPHER;
|
|
||||||
|
|
||||||
for( i = 1; i < argc; i++ )
|
|
||||||
{
|
|
||||||
p = argv[i];
|
|
||||||
if( ( q = strchr( p, '=' ) ) == NULL )
|
|
||||||
continue;
|
|
||||||
*q++ = '\0';
|
|
||||||
|
|
||||||
if( strcmp( p, "opmode" ) == 0 )
|
|
||||||
{
|
|
||||||
if( strcmp( q, "client" ) == 0 )
|
|
||||||
opt.opmode = OPMODE_CLIENT;
|
|
||||||
else
|
|
||||||
if( strcmp( q, "server" ) == 0 )
|
|
||||||
opt.opmode = OPMODE_SERVER;
|
|
||||||
else goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( strcmp( p, "iomode" ) == 0 )
|
|
||||||
{
|
|
||||||
if( strcmp( q, "block" ) == 0 )
|
|
||||||
opt.iomode = IOMODE_BLOCK;
|
|
||||||
else
|
|
||||||
if( strcmp( q, "nonblock" ) == 0 )
|
|
||||||
opt.iomode = IOMODE_NONBLOCK;
|
|
||||||
else goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( strcmp( p, "server_name" ) == 0 )
|
|
||||||
opt.server_name = q;
|
|
||||||
|
|
||||||
if( strcmp( p, "server_port" ) == 0 )
|
|
||||||
{
|
|
||||||
opt.server_port = atoi( q );
|
|
||||||
if( opt.server_port < 1 || opt.server_port > 65535 )
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( strcmp( p, "command" ) == 0 )
|
|
||||||
{
|
|
||||||
if( strcmp( q, "read" ) == 0 )
|
|
||||||
opt.command = COMMAND_READ;
|
|
||||||
else
|
|
||||||
if( strcmp( q, "write" ) == 0 )
|
|
||||||
opt.command = COMMAND_WRITE;
|
|
||||||
else
|
|
||||||
if( strcmp( q, "both" ) == 0 )
|
|
||||||
{
|
|
||||||
opt.iomode = IOMODE_NONBLOCK;
|
|
||||||
opt.command = COMMAND_BOTH;
|
|
||||||
}
|
|
||||||
else goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( strcmp( p, "buffer_size" ) == 0 )
|
|
||||||
{
|
|
||||||
opt.buffer_size = atoi( q );
|
|
||||||
if( opt.buffer_size < 1 || opt.buffer_size > 1048576 )
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( strcmp( p, "max_bytes" ) == 0 )
|
|
||||||
opt.max_bytes = atoi( q );
|
|
||||||
|
|
||||||
if( strcmp( p, "debug_level" ) == 0 )
|
|
||||||
opt.debug_level = atoi( q );
|
|
||||||
#if defined(POLARSSL_TIMING_C)
|
|
||||||
if( strcmp( p, "conn_timeout" ) == 0 )
|
|
||||||
opt.conn_timeout = atoi( q );
|
|
||||||
#endif
|
|
||||||
if( strcmp( p, "max_connections" ) == 0 )
|
|
||||||
opt.max_connections = atoi( q );
|
|
||||||
|
|
||||||
if( strcmp( p, "session_reuse" ) == 0 )
|
|
||||||
{
|
|
||||||
if( strcmp( q, "on" ) == 0 )
|
|
||||||
opt.session_reuse = 1;
|
|
||||||
else
|
|
||||||
if( strcmp( q, "off" ) == 0 )
|
|
||||||
opt.session_reuse = 0;
|
|
||||||
else
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( strcmp( p, "session_lifetime" ) == 0 )
|
|
||||||
opt.session_lifetime = atoi( q );
|
|
||||||
|
|
||||||
if( strcmp( p, "force_ciphersuite" ) == 0 )
|
|
||||||
{
|
|
||||||
opt.force_ciphersuite[0] = -1;
|
|
||||||
|
|
||||||
opt.force_ciphersuite[0] = ssl_get_ciphersuite_id( q );
|
|
||||||
|
|
||||||
if( opt.force_ciphersuite[0] <= 0 )
|
|
||||||
goto usage;
|
|
||||||
|
|
||||||
opt.force_ciphersuite[1] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( opt.opmode )
|
|
||||||
{
|
|
||||||
case OPMODE_CLIENT:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case OPMODE_SERVER:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
nb_conn = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
nb_conn++;
|
|
||||||
ret = ssl_test( &opt );
|
|
||||||
if( opt.max_connections != 0 &&
|
|
||||||
opt.max_connections <= nb_conn )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while( ret == 0 );
|
|
||||||
|
|
||||||
exit:
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
polarssl_printf( " Press Enter to exit this program.\n" );
|
|
||||||
fflush( stdout ); getchar();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return( ret );
|
|
||||||
}
|
|
||||||
#endif /* POLARSSL_BIGNUM_C && POLARSSL_ENTROPY_C && POLARSSL_SSL_TLS_C &&
|
|
||||||
POLARSSL_SSL_SRV_C && POLARSSL_SSL_CLI_C && POLARSSL_NET_C &&
|
|
||||||
POLARSSL_RSA_C && POLARSSL_CTR_DRBG_C */
|
|
@ -163,6 +163,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_fork_server", "ssl_fork
|
|||||||
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mini_client", "mini_client.vcxproj", "{C4FE29EA-266D-5295-4840-976B9B5B3843}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_mail_client", "ssl_mail_client.vcxproj", "{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_mail_client", "ssl_mail_client.vcxproj", "{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
||||||
@ -198,11 +203,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "selftest", "selftest.vcxpro
|
|||||||
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_test", "ssl_test.vcxproj", "{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udp_proxy", "udp_proxy.vcxproj", "{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udp_proxy", "udp_proxy.vcxproj", "{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
{46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554}
|
||||||
@ -505,6 +505,14 @@ Global
|
|||||||
{918CD402-047D-8467-E11C-E1132053F916}.Release|Win32.Build.0 = Release|Win32
|
{918CD402-047D-8467-E11C-E1132053F916}.Release|Win32.Build.0 = Release|Win32
|
||||||
{918CD402-047D-8467-E11C-E1132053F916}.Release|x64.ActiveCfg = Release|x64
|
{918CD402-047D-8467-E11C-E1132053F916}.Release|x64.ActiveCfg = Release|x64
|
||||||
{918CD402-047D-8467-E11C-E1132053F916}.Release|x64.Build.0 = Release|x64
|
{918CD402-047D-8467-E11C-E1132053F916}.Release|x64.Build.0 = Release|x64
|
||||||
|
{C4FE29EA-266D-5295-4840-976B9B5B3843}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{C4FE29EA-266D-5295-4840-976B9B5B3843}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{C4FE29EA-266D-5295-4840-976B9B5B3843}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{C4FE29EA-266D-5295-4840-976B9B5B3843}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{C4FE29EA-266D-5295-4840-976B9B5B3843}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{C4FE29EA-266D-5295-4840-976B9B5B3843}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{C4FE29EA-266D-5295-4840-976B9B5B3843}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{C4FE29EA-266D-5295-4840-976B9B5B3843}.Release|x64.Build.0 = Release|x64
|
||||||
{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|Win32.ActiveCfg = Debug|Win32
|
{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|Win32.Build.0 = Debug|Win32
|
{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|x64.ActiveCfg = Debug|x64
|
{7C4863A1-941A-C5AE-E1F9-30F062E4B2FD}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
@ -561,14 +569,6 @@ Global
|
|||||||
{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|Win32.Build.0 = Release|Win32
|
{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|Win32.Build.0 = Release|Win32
|
||||||
{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|x64.ActiveCfg = Release|x64
|
{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|x64.ActiveCfg = Release|x64
|
||||||
{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|x64.Build.0 = Release|x64
|
{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}.Release|x64.Build.0 = Release|x64
|
||||||
{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}.Release|x64.Build.0 = Release|x64
|
|
||||||
{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|Win32.ActiveCfg = Debug|Win32
|
{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|Win32.Build.0 = Debug|Win32
|
{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|x64.ActiveCfg = Debug|x64
|
{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
@ -157,7 +157,6 @@
|
|||||||
<ClInclude Include="..\..\include\polarssl\check_config.h" />
|
<ClInclude Include="..\..\include\polarssl\check_config.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\cipher.h" />
|
<ClInclude Include="..\..\include\polarssl\cipher.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\cipher_wrap.h" />
|
<ClInclude Include="..\..\include\polarssl\cipher_wrap.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\compat-1.2.h" />
|
|
||||||
<ClInclude Include="..\..\include\polarssl\config.h" />
|
<ClInclude Include="..\..\include\polarssl\config.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\ctr_drbg.h" />
|
<ClInclude Include="..\..\include\polarssl\ctr_drbg.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\debug.h" />
|
<ClInclude Include="..\..\include\polarssl\debug.h" />
|
||||||
@ -181,7 +180,6 @@
|
|||||||
<ClInclude Include="..\..\include\polarssl\memory_buffer_alloc.h" />
|
<ClInclude Include="..\..\include\polarssl\memory_buffer_alloc.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\net.h" />
|
<ClInclude Include="..\..\include\polarssl\net.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\oid.h" />
|
<ClInclude Include="..\..\include\polarssl\oid.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\openssl.h" />
|
|
||||||
<ClInclude Include="..\..\include\polarssl\padlock.h" />
|
<ClInclude Include="..\..\include\polarssl\padlock.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\pbkdf2.h" />
|
<ClInclude Include="..\..\include\polarssl\pbkdf2.h" />
|
||||||
<ClInclude Include="..\..\include\polarssl\pem.h" />
|
<ClInclude Include="..\..\include\polarssl\pem.h" />
|
||||||
|
@ -1,169 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="..\..\programs\test\ssl_test.c" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="mbedTLS.vcxproj">
|
|
||||||
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{DDD0BF0A-779A-DEFD-6A1C-FA2164AE9A34}</ProjectGuid>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<RootNamespace>ssl_test</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
<PlatformToolset>Windows7.1SDK</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ShowProgress>NotSet</ShowProgress>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<ShowProgress>NotSet</ShowProgress>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
<ProjectReference>
|
|
||||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>
|
|
||||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>
|
|
||||||
<AdditionalDependencies>%(AdditionalDependencies);</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -425,10 +425,6 @@ SOURCE=..\..\include\polarssl\cipher_wrap.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\include\polarssl\compat-1.2.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\include\polarssl\config.h
|
SOURCE=..\..\include\polarssl\config.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@ -521,10 +517,6 @@ SOURCE=..\..\include\polarssl\oid.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\include\polarssl\openssl.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\include\polarssl\padlock.h
|
SOURCE=..\..\include\polarssl\padlock.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -483,6 +483,21 @@ Package=<4>
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "mini_client"=.\mini_client.dsp - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
Begin Project Dependency
|
||||||
|
Project_Dep_Name mbedtls
|
||||||
|
End Project Dependency
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
Project: "ssl_mail_client"=.\ssl_mail_client.dsp - Package Owner=<4>
|
Project: "ssl_mail_client"=.\ssl_mail_client.dsp - Package Owner=<4>
|
||||||
|
|
||||||
Package=<5>
|
Package=<5>
|
||||||
@ -588,21 +603,6 @@ Package=<4>
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
Project: "ssl_test"=.\ssl_test.dsp - Package Owner=<4>
|
|
||||||
|
|
||||||
Package=<5>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
Package=<4>
|
|
||||||
{{{
|
|
||||||
Begin Project Dependency
|
|
||||||
Project_Dep_Name mbedtls
|
|
||||||
End Project Dependency
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
Project: "udp_proxy"=.\udp_proxy.dsp - Package Owner=<4>
|
Project: "udp_proxy"=.\udp_proxy.dsp - Package Owner=<4>
|
||||||
|
|
||||||
Package=<5>
|
Package=<5>
|
||||||
|
@ -1,101 +0,0 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="ssl_test" - Package Owner=<4>
|
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
|
||||||
# ** DO NOT EDIT **
|
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
|
||||||
|
|
||||||
CFG=ssl_test - Win32 Debug
|
|
||||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
|
||||||
!MESSAGE use the Export Makefile command and run
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "ssl_test.mak".
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE You can specify a configuration when running NMAKE
|
|
||||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE NMAKE /f "ssl_test.mak" CFG="ssl_test - Win32 Debug"
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE Possible choices for configuration are:
|
|
||||||
!MESSAGE
|
|
||||||
!MESSAGE "ssl_test - Win32 Release" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE "ssl_test - Win32 Debug" (based on "Win32 (x86) Console Application")
|
|
||||||
!MESSAGE
|
|
||||||
|
|
||||||
# Begin Project
|
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
|
||||||
# PROP Scc_LocalPath ""
|
|
||||||
CPP=cl.exe
|
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "ssl_test - Win32 Release"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 0
|
|
||||||
# PROP BASE Output_Dir ""
|
|
||||||
# PROP BASE Intermediate_Dir "temp"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 0
|
|
||||||
# PROP Output_Dir ""
|
|
||||||
# PROP Intermediate_Dir "temp"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
|
||||||
# ADD BASE RSC /l 0x40c /d "NDEBUG"
|
|
||||||
# ADD RSC /l 0x40c /d "NDEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "ssl_test - Win32 Debug"
|
|
||||||
|
|
||||||
# PROP BASE Use_MFC 0
|
|
||||||
# PROP BASE Use_Debug_Libraries 1
|
|
||||||
# PROP BASE Output_Dir ""
|
|
||||||
# PROP BASE Intermediate_Dir "temp"
|
|
||||||
# PROP BASE Target_Dir ""
|
|
||||||
# PROP Use_MFC 0
|
|
||||||
# PROP Use_Debug_Libraries 1
|
|
||||||
# PROP Output_Dir ""
|
|
||||||
# PROP Intermediate_Dir "temp"
|
|
||||||
# PROP Target_Dir ""
|
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
|
||||||
# ADD BASE RSC /l 0x40c /d "_DEBUG"
|
|
||||||
# ADD RSC /l 0x40c /d "_DEBUG"
|
|
||||||
BSC32=bscmake.exe
|
|
||||||
# ADD BASE BSC32 /nologo
|
|
||||||
# ADD BSC32 /nologo
|
|
||||||
LINK32=link.exe
|
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# Begin Target
|
|
||||||
|
|
||||||
# Name "ssl_test - Win32 Release"
|
|
||||||
# Name "ssl_test - Win32 Debug"
|
|
||||||
# Begin Group "Source Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\programs\test\ssl_test.c
|
|
||||||
# ADD CPP /I "../../include"
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Header Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
|
||||||
# End Group
|
|
||||||
# Begin Group "Resource Files"
|
|
||||||
|
|
||||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
|
||||||
# End Group
|
|
||||||
# End Target
|
|
||||||
# End Project
|
|
Loading…
Reference in New Issue
Block a user