diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8d10b42fdd..0b1cfd538f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,28 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-22 12:41 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbcurl/hbcurl.c + % Callback functions changed to 'static'. + + * contrib/hbcurl/hbcurl.hbc + * Added some level of static linking support. + * Corrected libs line for mingw. + + * contrib/hbssl/evpciph.c + * contrib/hbssl/ssl.c + * contrib/hbssl/bio.c + * contrib/hbssl/evpmd.c + * contrib/hbssl/sslctx.c + * contrib/hbssl/tests/hbmk.hbm + * contrib/hbssl/tests/digest.prg + * contrib/hbssl/tests/crypt.prg + * contrib/hbssl/evp.c + * Some variables renamed. + ! Fixed GPF when invalid CIPHER or MD is passed. + + Added EVP_BytesToKey() examples. + + Added -w3 to tests. + 2009-07-22 11:48 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/xhb/xhbfunc.c + Added HB_F_EOF() xhb compatibility function. diff --git a/harbour/contrib/hbcurl/hbcurl.c b/harbour/contrib/hbcurl/hbcurl.c index 4437b6470a..833fd34fb3 100644 --- a/harbour/contrib/hbcurl/hbcurl.c +++ b/harbour/contrib/hbcurl/hbcurl.c @@ -184,27 +184,27 @@ static const char * hb_curl_StrHashNew( PHB_CURL hb_curl, const char * szValue ) /* ---------------------------------------------------------------------------- */ /* Global initialization/deinitialization */ -void * hb_curl_xgrab( size_t size ) +static void * hb_curl_xgrab( size_t size ) { return hb_xgrab( size ); } -void hb_curl_xfree( void * p ) +static void hb_curl_xfree( void * p ) { hb_xfree( p ); } -void * hb_curl_xrealloc( void * p, size_t size ) +static void * hb_curl_xrealloc( void * p, size_t size ) { return hb_xrealloc( p, size ); } -char * hb_curl_strdup( const char * s ) +static char * hb_curl_strdup( const char * s ) { return hb_strdup( s ); } -void * hb_curl_calloc( size_t nelem, size_t elsize ) +static void * hb_curl_calloc( size_t nelem, size_t elsize ) { size_t size = nelem * elsize; void * ptr = hb_xgrab( size ); @@ -232,7 +232,7 @@ HB_FUNC( CURL_GLOBAL_CLEANUP ) /* ---------------------------------------------------------------------------- */ /* Callbacks */ -size_t hb_curl_read_dummy_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +static size_t hb_curl_read_dummy_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) { HB_SYMBOL_UNUSED( buffer ); HB_SYMBOL_UNUSED( size ); @@ -242,7 +242,7 @@ size_t hb_curl_read_dummy_callback( void * buffer, size_t size, size_t nmemb, vo return 0; } -size_t hb_curl_read_file_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +static size_t hb_curl_read_file_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) { PHB_CURL hb_curl = ( PHB_CURL ) Cargo; @@ -266,7 +266,7 @@ size_t hb_curl_read_file_callback( void * buffer, size_t size, size_t nmemb, voi return ( size_t ) -1; } -size_t hb_curl_read_buff_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +static size_t hb_curl_read_buff_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) { PHB_CURL hb_curl = ( PHB_CURL ) Cargo; @@ -288,7 +288,7 @@ size_t hb_curl_read_buff_callback( void * buffer, size_t size, size_t nmemb, voi return ( size_t ) -1; } -size_t hb_curl_write_file_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +static size_t hb_curl_write_file_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) { PHB_CURL hb_curl = ( PHB_CURL ) Cargo; @@ -311,7 +311,7 @@ size_t hb_curl_write_file_callback( void * buffer, size_t size, size_t nmemb, vo #define HB_CURL_DL_BUFF_SIZE_INIT ( CURL_MAX_WRITE_SIZE * 2 ) #define HB_CURL_DL_BUFF_SIZE_INCR ( CURL_MAX_WRITE_SIZE * 4 ) -size_t hb_curl_write_buff_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +static size_t hb_curl_write_buff_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) { PHB_CURL hb_curl = ( PHB_CURL ) Cargo; @@ -336,7 +336,7 @@ size_t hb_curl_write_buff_callback( void * buffer, size_t size, size_t nmemb, vo return ( size_t ) -1; } -int hb_curl_progress_callback( void * Cargo, double dltotal, double dlnow, double ultotal, double ulnow ) +static int hb_curl_progress_callback( void * Cargo, double dltotal, double dlnow, double ultotal, double ulnow ) { if( Cargo ) { diff --git a/harbour/contrib/hbcurl/hbcurl.hbc b/harbour/contrib/hbcurl/hbcurl.hbc index 6f6dfd5135..9a962b4a06 100644 --- a/harbour/contrib/hbcurl/hbcurl.hbc +++ b/harbour/contrib/hbcurl/hbcurl.hbc @@ -4,5 +4,11 @@ incpaths=. -libs=hbcurl -libs=libcurl +# NOTE: HB_CURL_STATIC mode requires additional libs be linked: +# libssh2 and OpenSSL + +{!HB_CURL_STATIC}libs=hbcurl +{ HB_CURL_STATIC}libs=hbcurls +{!mingw}libs=libcurl +{mingw&!HB_CURL_STATIC}libs=curldll +{mingw& HB_CURL_STATIC}libs=curl diff --git a/harbour/contrib/hbssl/bio.c b/harbour/contrib/hbssl/bio.c index 021978d9f7..fa40982959 100644 --- a/harbour/contrib/hbssl/bio.c +++ b/harbour/contrib/hbssl/bio.c @@ -72,67 +72,67 @@ static int hb_BIO_METHOD_is( int iParam ) static BIO_METHOD * hb_BIO_METHOD_par( int iParam ) { - BIO_METHOD * method; + BIO_METHOD * p; switch( hb_parni( iParam ) ) { - case HB_BIO_METHOD_S_NULL : method = BIO_s_null(); break; + case HB_BIO_METHOD_S_NULL : p = BIO_s_null(); break; #ifndef OPENSSL_NO_FP_API - case HB_BIO_METHOD_S_FILE : method = BIO_s_file(); break; + case HB_BIO_METHOD_S_FILE : p = BIO_s_file(); break; #endif - case HB_BIO_METHOD_S_MEM : method = BIO_s_mem(); break; - case HB_BIO_METHOD_S_SOCKET : method = BIO_s_socket(); break; - case HB_BIO_METHOD_S_CONNECT : method = BIO_s_connect(); break; - case HB_BIO_METHOD_S_ACCEPT : method = BIO_s_accept(); break; - case HB_BIO_METHOD_S_FD : method = BIO_s_fd(); break; + case HB_BIO_METHOD_S_MEM : p = BIO_s_mem(); break; + case HB_BIO_METHOD_S_SOCKET : p = BIO_s_socket(); break; + case HB_BIO_METHOD_S_CONNECT : p = BIO_s_connect(); break; + case HB_BIO_METHOD_S_ACCEPT : p = BIO_s_accept(); break; + case HB_BIO_METHOD_S_FD : p = BIO_s_fd(); break; #ifndef OPENSSL_SYS_OS2 - case HB_BIO_METHOD_S_LOG : method = BIO_s_log(); break; + case HB_BIO_METHOD_S_LOG : p = BIO_s_log(); break; #endif - case HB_BIO_METHOD_S_BIO : method = BIO_s_bio(); break; + case HB_BIO_METHOD_S_BIO : p = BIO_s_bio(); break; #ifndef OPENSSL_NO_DGRAM - case HB_BIO_METHOD_S_DATAGRAM : method = BIO_s_datagram(); break; + case HB_BIO_METHOD_S_DATAGRAM : p = BIO_s_datagram(); break; #endif - case HB_BIO_METHOD_F_NULL : method = BIO_f_null(); break; - case HB_BIO_METHOD_F_BUFFER : method = BIO_f_buffer(); break; + case HB_BIO_METHOD_F_NULL : p = BIO_f_null(); break; + case HB_BIO_METHOD_F_BUFFER : p = BIO_f_buffer(); break; #ifdef OPENSSL_SYS_VMS - case HB_BIO_METHOD_F_LINEBUFFER : method = BIO_f_linebuffer(); break; + case HB_BIO_METHOD_F_LINEBUFFER : p = BIO_f_linebuffer(); break; #endif - case HB_BIO_METHOD_F_NBIO_TEST : method = BIO_f_nbio_test(); break; - default : method = NULL; + case HB_BIO_METHOD_F_NBIO_TEST : p = BIO_f_nbio_test(); break; + default : p = NULL; } - return method; + return p; } #if 0 /* NOTE: Unused yet. Commented to avoid warning */ -static int hb_BIO_METHOD_ptr_to_id( const BIO_METHOD * method ) +static int hb_BIO_METHOD_ptr_to_id( const BIO_METHOD * p ) { int n; - if( method == BIO_s_null() ) n = HB_BIO_METHOD_S_NULL; + if( p == BIO_s_null() ) n = HB_BIO_METHOD_S_NULL; #ifndef OPENSSL_NO_FP_API - else if( method == BIO_s_file() ) n = HB_BIO_METHOD_S_FILE; + else if( p == BIO_s_file() ) n = HB_BIO_METHOD_S_FILE; #endif - else if( method == BIO_s_mem() ) n = HB_BIO_METHOD_S_MEM; - else if( method == BIO_s_socket() ) n = HB_BIO_METHOD_S_SOCKET; - else if( method == BIO_s_connect() ) n = HB_BIO_METHOD_S_CONNECT; - else if( method == BIO_s_accept() ) n = HB_BIO_METHOD_S_ACCEPT; - else if( method == BIO_s_fd() ) n = HB_BIO_METHOD_S_FD; + else if( p == BIO_s_mem() ) n = HB_BIO_METHOD_S_MEM; + else if( p == BIO_s_socket() ) n = HB_BIO_METHOD_S_SOCKET; + else if( p == BIO_s_connect() ) n = HB_BIO_METHOD_S_CONNECT; + else if( p == BIO_s_accept() ) n = HB_BIO_METHOD_S_ACCEPT; + else if( p == BIO_s_fd() ) n = HB_BIO_METHOD_S_FD; #ifndef OPENSSL_SYS_OS2 - else if( method == BIO_s_log() ) n = HB_BIO_METHOD_S_LOG; + else if( p == BIO_s_log() ) n = HB_BIO_METHOD_S_LOG; #endif - else if( method == BIO_s_bio() ) n = HB_BIO_METHOD_S_BIO; + else if( p == BIO_s_bio() ) n = HB_BIO_METHOD_S_BIO; #ifndef OPENSSL_NO_DGRAM - else if( method == BIO_s_datagram() ) n = HB_BIO_METHOD_S_DATAGRAM; + else if( p == BIO_s_datagram() ) n = HB_BIO_METHOD_S_DATAGRAM; #endif - else if( method == BIO_f_null() ) n = HB_BIO_METHOD_F_NULL; - else if( method == BIO_f_buffer() ) n = HB_BIO_METHOD_F_BUFFER; + else if( p == BIO_f_null() ) n = HB_BIO_METHOD_F_NULL; + else if( p == BIO_f_buffer() ) n = HB_BIO_METHOD_F_BUFFER; #ifdef OPENSSL_SYS_VMS - else if( method == BIO_f_linebuffer() ) n = HB_BIO_METHOD_F_LINEBUFFER; + else if( p == BIO_f_linebuffer() ) n = HB_BIO_METHOD_F_LINEBUFFER; #endif - else if( method == BIO_f_nbio_test() ) n = HB_BIO_METHOD_F_NBIO_TEST; - else n = HB_BIO_METHOD_UNSUPPORTED; + else if( p == BIO_f_nbio_test() ) n = HB_BIO_METHOD_F_NBIO_TEST; + else n = HB_BIO_METHOD_UNSUPPORTED; return n; } diff --git a/harbour/contrib/hbssl/evp.c b/harbour/contrib/hbssl/evp.c index d56a64bd23..2c873b0625 100644 --- a/harbour/contrib/hbssl/evp.c +++ b/harbour/contrib/hbssl/evp.c @@ -85,15 +85,18 @@ HB_FUNC( ERR_LOAD_EVP_STRINGS ) HB_FUNC( EVP_BYTESTOKEY ) { - if( hb_EVP_CIPHER_is( 1 ), hb_EVP_MD_is( 2 ) ) + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 ); + const EVP_MD * md = hb_EVP_MD_par( 2 ); + + if( cipher && md && ( ! HB_ISCHAR( 3 ) || hb_parclen( 3 ) == 8 ) ) { unsigned char key[ EVP_MAX_KEY_LENGTH ]; unsigned char iv[ EVP_MAX_IV_LENGTH ]; - hb_retni( EVP_BytesToKey( hb_EVP_CIPHER_par( 1 ), - hb_EVP_MD_par( 2 ), + hb_retni( EVP_BytesToKey( cipher, + md, ( const unsigned char * ) hb_parc( 3 ) /* salt */, - ( const unsigned char * ) hb_parc( 4 ) /* data */, + ( const unsigned char * ) hb_parcx( 4 ) /* data */, hb_parclen( 4 ), hb_parni( 5 ) /* count */, key, diff --git a/harbour/contrib/hbssl/evpciph.c b/harbour/contrib/hbssl/evpciph.c index ff7de195d5..7bf97d2ed7 100644 --- a/harbour/contrib/hbssl/evpciph.c +++ b/harbour/contrib/hbssl/evpciph.c @@ -97,262 +97,262 @@ int hb_EVP_CIPHER_is( int iParam ) const EVP_CIPHER * hb_EVP_CIPHER_par( int iParam ) { - const EVP_CIPHER * method; + const EVP_CIPHER * p; if( HB_ISCHAR( iParam ) ) return EVP_get_cipherbyname( hb_parc( iParam ) ); switch( hb_parni( iParam ) ) { - case HB_EVP_CIPHER_ENC_NULL : method = EVP_enc_null(); break; + case HB_EVP_CIPHER_ENC_NULL : p = EVP_enc_null(); break; #ifndef OPENSSL_NO_DES - case HB_EVP_CIPHER_DES_ECB : method = EVP_des_ecb(); break; - case HB_EVP_CIPHER_DES_EDE : method = EVP_des_ede(); break; - case HB_EVP_CIPHER_DES_EDE3 : method = EVP_des_ede3(); break; - case HB_EVP_CIPHER_DES_EDE_ECB : method = EVP_des_ede_ecb(); break; - case HB_EVP_CIPHER_DES_EDE3_ECB : method = EVP_des_ede3_ecb(); break; - case HB_EVP_CIPHER_DES_CFB64 : method = EVP_des_cfb64(); break; - case HB_EVP_CIPHER_DES_CFB : method = EVP_des_cfb(); break; - case HB_EVP_CIPHER_DES_CFB1 : method = EVP_des_cfb1(); break; - case HB_EVP_CIPHER_DES_CFB8 : method = EVP_des_cfb8(); break; - case HB_EVP_CIPHER_DES_EDE_CFB64 : method = EVP_des_ede_cfb64(); break; - case HB_EVP_CIPHER_DES_EDE_CFB : method = EVP_des_ede_cfb(); break; - case HB_EVP_CIPHER_DES_EDE3_CFB64 : method = EVP_des_ede3_cfb64(); break; - case HB_EVP_CIPHER_DES_EDE3_CFB : method = EVP_des_ede3_cfb(); break; - case HB_EVP_CIPHER_DES_EDE3_CFB1 : method = EVP_des_ede3_cfb1(); break; - case HB_EVP_CIPHER_DES_EDE3_CFB8 : method = EVP_des_ede3_cfb8(); break; - case HB_EVP_CIPHER_DES_OFB : method = EVP_des_ofb(); break; - case HB_EVP_CIPHER_DES_EDE_OFB : method = EVP_des_ede_ofb(); break; - case HB_EVP_CIPHER_DES_EDE3_OFB : method = EVP_des_ede3_ofb(); break; - case HB_EVP_CIPHER_DES_CBC : method = EVP_des_cbc(); break; - case HB_EVP_CIPHER_DES_EDE_CBC : method = EVP_des_ede_cbc(); break; - case HB_EVP_CIPHER_DES_EDE3_CBC : method = EVP_des_ede3_cbc(); break; - case HB_EVP_CIPHER_DESX_CBC : method = EVP_desx_cbc(); break; + case HB_EVP_CIPHER_DES_ECB : p = EVP_des_ecb(); break; + case HB_EVP_CIPHER_DES_EDE : p = EVP_des_ede(); break; + case HB_EVP_CIPHER_DES_EDE3 : p = EVP_des_ede3(); break; + case HB_EVP_CIPHER_DES_EDE_ECB : p = EVP_des_ede_ecb(); break; + case HB_EVP_CIPHER_DES_EDE3_ECB : p = EVP_des_ede3_ecb(); break; + case HB_EVP_CIPHER_DES_CFB64 : p = EVP_des_cfb64(); break; + case HB_EVP_CIPHER_DES_CFB : p = EVP_des_cfb(); break; + case HB_EVP_CIPHER_DES_CFB1 : p = EVP_des_cfb1(); break; + case HB_EVP_CIPHER_DES_CFB8 : p = EVP_des_cfb8(); break; + case HB_EVP_CIPHER_DES_EDE_CFB64 : p = EVP_des_ede_cfb64(); break; + case HB_EVP_CIPHER_DES_EDE_CFB : p = EVP_des_ede_cfb(); break; + case HB_EVP_CIPHER_DES_EDE3_CFB64 : p = EVP_des_ede3_cfb64(); break; + case HB_EVP_CIPHER_DES_EDE3_CFB : p = EVP_des_ede3_cfb(); break; + case HB_EVP_CIPHER_DES_EDE3_CFB1 : p = EVP_des_ede3_cfb1(); break; + case HB_EVP_CIPHER_DES_EDE3_CFB8 : p = EVP_des_ede3_cfb8(); break; + case HB_EVP_CIPHER_DES_OFB : p = EVP_des_ofb(); break; + case HB_EVP_CIPHER_DES_EDE_OFB : p = EVP_des_ede_ofb(); break; + case HB_EVP_CIPHER_DES_EDE3_OFB : p = EVP_des_ede3_ofb(); break; + case HB_EVP_CIPHER_DES_CBC : p = EVP_des_cbc(); break; + case HB_EVP_CIPHER_DES_EDE_CBC : p = EVP_des_ede_cbc(); break; + case HB_EVP_CIPHER_DES_EDE3_CBC : p = EVP_des_ede3_cbc(); break; + case HB_EVP_CIPHER_DESX_CBC : p = EVP_desx_cbc(); break; #endif #ifndef OPENSSL_NO_RC4 - case HB_EVP_CIPHER_RC4 : method = EVP_rc4(); break; - case HB_EVP_CIPHER_RC4_40 : method = EVP_rc4_40(); break; + case HB_EVP_CIPHER_RC4 : p = EVP_rc4(); break; + case HB_EVP_CIPHER_RC4_40 : p = EVP_rc4_40(); break; #endif #ifndef OPENSSL_NO_IDEA - case HB_EVP_CIPHER_IDEA_ECB : method = EVP_idea_ecb(); break; - case HB_EVP_CIPHER_IDEA_CFB64 : method = EVP_idea_cfb64(); break; - case HB_EVP_CIPHER_IDEA_CFB : method = EVP_idea_cfb(); break; - case HB_EVP_CIPHER_IDEA_OFB : method = EVP_idea_ofb(); break; - case HB_EVP_CIPHER_IDEA_CBC : method = EVP_idea_cbc(); break; + case HB_EVP_CIPHER_IDEA_ECB : p = EVP_idea_ecb(); break; + case HB_EVP_CIPHER_IDEA_CFB64 : p = EVP_idea_cfb64(); break; + case HB_EVP_CIPHER_IDEA_CFB : p = EVP_idea_cfb(); break; + case HB_EVP_CIPHER_IDEA_OFB : p = EVP_idea_ofb(); break; + case HB_EVP_CIPHER_IDEA_CBC : p = EVP_idea_cbc(); break; #endif #ifndef OPENSSL_NO_RC2 - case HB_EVP_CIPHER_RC2_ECB : method = EVP_rc2_ecb(); break; - case HB_EVP_CIPHER_RC2_CBC : method = EVP_rc2_cbc(); break; - case HB_EVP_CIPHER_RC2_40_CBC : method = EVP_rc2_40_cbc(); break; - case HB_EVP_CIPHER_RC2_64_CBC : method = EVP_rc2_64_cbc(); break; - case HB_EVP_CIPHER_RC2_CFB64 : method = EVP_rc2_cfb64(); break; - case HB_EVP_CIPHER_RC2_CFB : method = EVP_rc2_cfb(); break; - case HB_EVP_CIPHER_RC2_OFB : method = EVP_rc2_ofb(); break; + case HB_EVP_CIPHER_RC2_ECB : p = EVP_rc2_ecb(); break; + case HB_EVP_CIPHER_RC2_CBC : p = EVP_rc2_cbc(); break; + case HB_EVP_CIPHER_RC2_40_CBC : p = EVP_rc2_40_cbc(); break; + case HB_EVP_CIPHER_RC2_64_CBC : p = EVP_rc2_64_cbc(); break; + case HB_EVP_CIPHER_RC2_CFB64 : p = EVP_rc2_cfb64(); break; + case HB_EVP_CIPHER_RC2_CFB : p = EVP_rc2_cfb(); break; + case HB_EVP_CIPHER_RC2_OFB : p = EVP_rc2_ofb(); break; #endif #ifndef OPENSSL_NO_BF - case HB_EVP_CIPHER_BF_ECB : method = EVP_bf_ecb(); break; - case HB_EVP_CIPHER_BF_CBC : method = EVP_bf_cbc(); break; - case HB_EVP_CIPHER_BF_CFB64 : method = EVP_bf_cfb64(); break; - case HB_EVP_CIPHER_BF_CFB : method = EVP_bf_cfb(); break; - case HB_EVP_CIPHER_BF_OFB : method = EVP_bf_ofb(); break; + case HB_EVP_CIPHER_BF_ECB : p = EVP_bf_ecb(); break; + case HB_EVP_CIPHER_BF_CBC : p = EVP_bf_cbc(); break; + case HB_EVP_CIPHER_BF_CFB64 : p = EVP_bf_cfb64(); break; + case HB_EVP_CIPHER_BF_CFB : p = EVP_bf_cfb(); break; + case HB_EVP_CIPHER_BF_OFB : p = EVP_bf_ofb(); break; #endif #ifndef OPENSSL_NO_CAST - case HB_EVP_CIPHER_CAST5_ECB : method = EVP_cast5_ecb(); break; - case HB_EVP_CIPHER_CAST5_CBC : method = EVP_cast5_cbc(); break; - case HB_EVP_CIPHER_CAST5_CFB64 : method = EVP_cast5_cfb64(); break; - case HB_EVP_CIPHER_CAST5_CFB : method = EVP_cast5_cfb(); break; - case HB_EVP_CIPHER_CAST5_OFB : method = EVP_cast5_ofb(); break; + case HB_EVP_CIPHER_CAST5_ECB : p = EVP_cast5_ecb(); break; + case HB_EVP_CIPHER_CAST5_CBC : p = EVP_cast5_cbc(); break; + case HB_EVP_CIPHER_CAST5_CFB64 : p = EVP_cast5_cfb64(); break; + case HB_EVP_CIPHER_CAST5_CFB : p = EVP_cast5_cfb(); break; + case HB_EVP_CIPHER_CAST5_OFB : p = EVP_cast5_ofb(); break; #endif #ifndef OPENSSL_NO_RC5 - case HB_EVP_CIPHER_RC5_32_12_16_CBC : method = EVP_rc5_32_12_16_cbc(); break; - case HB_EVP_CIPHER_RC5_32_12_16_ECB : method = EVP_rc5_32_12_16_ecb(); break; - case HB_EVP_CIPHER_RC5_32_12_16_CFB64 : method = EVP_rc5_32_12_16_cfb64(); break; - case HB_EVP_CIPHER_RC5_32_12_16_CFB : method = EVP_rc5_32_12_16_cfb(); break; - case HB_EVP_CIPHER_RC5_32_12_16_OFB : method = EVP_rc5_32_12_16_ofb(); break; + case HB_EVP_CIPHER_RC5_32_12_16_CBC : p = EVP_rc5_32_12_16_cbc(); break; + case HB_EVP_CIPHER_RC5_32_12_16_ECB : p = EVP_rc5_32_12_16_ecb(); break; + case HB_EVP_CIPHER_RC5_32_12_16_CFB64 : p = EVP_rc5_32_12_16_cfb64(); break; + case HB_EVP_CIPHER_RC5_32_12_16_CFB : p = EVP_rc5_32_12_16_cfb(); break; + case HB_EVP_CIPHER_RC5_32_12_16_OFB : p = EVP_rc5_32_12_16_ofb(); break; #endif #ifndef OPENSSL_NO_AES - case HB_EVP_CIPHER_AES_128_ECB : method = EVP_aes_128_ecb(); break; - case HB_EVP_CIPHER_AES_128_CBC : method = EVP_aes_128_cbc(); break; - case HB_EVP_CIPHER_AES_128_CFB1 : method = EVP_aes_128_cfb1(); break; - case HB_EVP_CIPHER_AES_128_CFB8 : method = EVP_aes_128_cfb8(); break; - case HB_EVP_CIPHER_AES_128_CFB128 : method = EVP_aes_128_cfb128(); break; - case HB_EVP_CIPHER_AES_128_CFB : method = EVP_aes_128_cfb(); break; - case HB_EVP_CIPHER_AES_128_OFB : method = EVP_aes_128_ofb(); break; - case HB_EVP_CIPHER_AES_192_ECB : method = EVP_aes_192_ecb(); break; - case HB_EVP_CIPHER_AES_192_CBC : method = EVP_aes_192_cbc(); break; - case HB_EVP_CIPHER_AES_192_CFB1 : method = EVP_aes_192_cfb1(); break; - case HB_EVP_CIPHER_AES_192_CFB8 : method = EVP_aes_192_cfb8(); break; - case HB_EVP_CIPHER_AES_192_CFB128 : method = EVP_aes_192_cfb128(); break; - case HB_EVP_CIPHER_AES_192_CFB : method = EVP_aes_192_cfb(); break; - case HB_EVP_CIPHER_AES_192_OFB : method = EVP_aes_192_ofb(); break; - case HB_EVP_CIPHER_AES_256_ECB : method = EVP_aes_256_ecb(); break; - case HB_EVP_CIPHER_AES_256_CBC : method = EVP_aes_256_cbc(); break; - case HB_EVP_CIPHER_AES_256_CFB1 : method = EVP_aes_256_cfb1(); break; - case HB_EVP_CIPHER_AES_256_CFB8 : method = EVP_aes_256_cfb8(); break; - case HB_EVP_CIPHER_AES_256_CFB128 : method = EVP_aes_256_cfb128(); break; - case HB_EVP_CIPHER_AES_256_CFB : method = EVP_aes_256_cfb(); break; - case HB_EVP_CIPHER_AES_256_OFB : method = EVP_aes_256_ofb(); break; + case HB_EVP_CIPHER_AES_128_ECB : p = EVP_aes_128_ecb(); break; + case HB_EVP_CIPHER_AES_128_CBC : p = EVP_aes_128_cbc(); break; + case HB_EVP_CIPHER_AES_128_CFB1 : p = EVP_aes_128_cfb1(); break; + case HB_EVP_CIPHER_AES_128_CFB8 : p = EVP_aes_128_cfb8(); break; + case HB_EVP_CIPHER_AES_128_CFB128 : p = EVP_aes_128_cfb128(); break; + case HB_EVP_CIPHER_AES_128_CFB : p = EVP_aes_128_cfb(); break; + case HB_EVP_CIPHER_AES_128_OFB : p = EVP_aes_128_ofb(); break; + case HB_EVP_CIPHER_AES_192_ECB : p = EVP_aes_192_ecb(); break; + case HB_EVP_CIPHER_AES_192_CBC : p = EVP_aes_192_cbc(); break; + case HB_EVP_CIPHER_AES_192_CFB1 : p = EVP_aes_192_cfb1(); break; + case HB_EVP_CIPHER_AES_192_CFB8 : p = EVP_aes_192_cfb8(); break; + case HB_EVP_CIPHER_AES_192_CFB128 : p = EVP_aes_192_cfb128(); break; + case HB_EVP_CIPHER_AES_192_CFB : p = EVP_aes_192_cfb(); break; + case HB_EVP_CIPHER_AES_192_OFB : p = EVP_aes_192_ofb(); break; + case HB_EVP_CIPHER_AES_256_ECB : p = EVP_aes_256_ecb(); break; + case HB_EVP_CIPHER_AES_256_CBC : p = EVP_aes_256_cbc(); break; + case HB_EVP_CIPHER_AES_256_CFB1 : p = EVP_aes_256_cfb1(); break; + case HB_EVP_CIPHER_AES_256_CFB8 : p = EVP_aes_256_cfb8(); break; + case HB_EVP_CIPHER_AES_256_CFB128 : p = EVP_aes_256_cfb128(); break; + case HB_EVP_CIPHER_AES_256_CFB : p = EVP_aes_256_cfb(); break; + case HB_EVP_CIPHER_AES_256_OFB : p = EVP_aes_256_ofb(); break; #endif #ifndef OPENSSL_NO_CAMELLIA - case HB_EVP_CIPHER_CAMELLIA_128_ECB : method = EVP_camellia_128_ecb(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CBC : method = EVP_camellia_128_cbc(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CFB1 : method = EVP_camellia_128_cfb1(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CFB8 : method = EVP_camellia_128_cfb8(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CFB128 : method = EVP_camellia_128_cfb128(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CFB : method = EVP_camellia_128_cfb(); break; - case HB_EVP_CIPHER_CAMELLIA_128_OFB : method = EVP_camellia_128_ofb(); break; - case HB_EVP_CIPHER_CAMELLIA_192_ECB : method = EVP_camellia_192_ecb(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CBC : method = EVP_camellia_192_cbc(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CFB1 : method = EVP_camellia_192_cfb1(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CFB8 : method = EVP_camellia_192_cfb8(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CFB128 : method = EVP_camellia_192_cfb128(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CFB : method = EVP_camellia_192_cfb(); break; - case HB_EVP_CIPHER_CAMELLIA_192_OFB : method = EVP_camellia_192_ofb(); break; - case HB_EVP_CIPHER_CAMELLIA_256_ECB : method = EVP_camellia_256_ecb(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CBC : method = EVP_camellia_256_cbc(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CFB1 : method = EVP_camellia_256_cfb1(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CFB8 : method = EVP_camellia_256_cfb8(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CFB128 : method = EVP_camellia_256_cfb128(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CFB : method = EVP_camellia_256_cfb(); break; - case HB_EVP_CIPHER_CAMELLIA_256_OFB : method = EVP_camellia_256_ofb(); break; + case HB_EVP_CIPHER_CAMELLIA_128_ECB : p = EVP_camellia_128_ecb(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CBC : p = EVP_camellia_128_cbc(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CFB1 : p = EVP_camellia_128_cfb1(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CFB8 : p = EVP_camellia_128_cfb8(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CFB128 : p = EVP_camellia_128_cfb128(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CFB : p = EVP_camellia_128_cfb(); break; + case HB_EVP_CIPHER_CAMELLIA_128_OFB : p = EVP_camellia_128_ofb(); break; + case HB_EVP_CIPHER_CAMELLIA_192_ECB : p = EVP_camellia_192_ecb(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CBC : p = EVP_camellia_192_cbc(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CFB1 : p = EVP_camellia_192_cfb1(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CFB8 : p = EVP_camellia_192_cfb8(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CFB128 : p = EVP_camellia_192_cfb128(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CFB : p = EVP_camellia_192_cfb(); break; + case HB_EVP_CIPHER_CAMELLIA_192_OFB : p = EVP_camellia_192_ofb(); break; + case HB_EVP_CIPHER_CAMELLIA_256_ECB : p = EVP_camellia_256_ecb(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CBC : p = EVP_camellia_256_cbc(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CFB1 : p = EVP_camellia_256_cfb1(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CFB8 : p = EVP_camellia_256_cfb8(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CFB128 : p = EVP_camellia_256_cfb128(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CFB : p = EVP_camellia_256_cfb(); break; + case HB_EVP_CIPHER_CAMELLIA_256_OFB : p = EVP_camellia_256_ofb(); break; #endif #ifndef OPENSSL_NO_SEED - case HB_EVP_CIPHER_SEED_ECB : method = EVP_seed_ecb(); break; - case HB_EVP_CIPHER_SEED_CBC : method = EVP_seed_cbc(); break; - case HB_EVP_CIPHER_SEED_CFB128 : method = EVP_seed_cfb128(); break; - case HB_EVP_CIPHER_SEED_CFB : method = EVP_seed_cfb(); break; - case HB_EVP_CIPHER_SEED_OFB : method = EVP_seed_ofb(); break; + case HB_EVP_CIPHER_SEED_ECB : p = EVP_seed_ecb(); break; + case HB_EVP_CIPHER_SEED_CBC : p = EVP_seed_cbc(); break; + case HB_EVP_CIPHER_SEED_CFB128 : p = EVP_seed_cfb128(); break; + case HB_EVP_CIPHER_SEED_CFB : p = EVP_seed_cfb(); break; + case HB_EVP_CIPHER_SEED_OFB : p = EVP_seed_ofb(); break; #endif - default : method = NULL; + default : p = NULL; } - return method; + return p; } -static int hb_EVP_CIPHER_ptr_to_id( const EVP_CIPHER * method ) +static int hb_EVP_CIPHER_ptr_to_id( const EVP_CIPHER * p ) { int n; - if( method == EVP_enc_null() ) n = HB_EVP_CIPHER_ENC_NULL; + if( p == EVP_enc_null() ) n = HB_EVP_CIPHER_ENC_NULL; #ifndef OPENSSL_NO_DES - else if( method == EVP_des_ecb() ) n = HB_EVP_CIPHER_DES_ECB; - else if( method == EVP_des_ede() ) n = HB_EVP_CIPHER_DES_EDE; - else if( method == EVP_des_ede3() ) n = HB_EVP_CIPHER_DES_EDE3; - else if( method == EVP_des_ede_ecb() ) n = HB_EVP_CIPHER_DES_EDE_ECB; - else if( method == EVP_des_ede3_ecb() ) n = HB_EVP_CIPHER_DES_EDE3_ECB; - else if( method == EVP_des_cfb64() ) n = HB_EVP_CIPHER_DES_CFB64; - else if( method == EVP_des_cfb() ) n = HB_EVP_CIPHER_DES_CFB; - else if( method == EVP_des_cfb1() ) n = HB_EVP_CIPHER_DES_CFB1; - else if( method == EVP_des_cfb8() ) n = HB_EVP_CIPHER_DES_CFB8; - else if( method == EVP_des_ede_cfb64() ) n = HB_EVP_CIPHER_DES_EDE_CFB64; - else if( method == EVP_des_ede_cfb() ) n = HB_EVP_CIPHER_DES_EDE_CFB; - else if( method == EVP_des_ede3_cfb64() ) n = HB_EVP_CIPHER_DES_EDE3_CFB64; - else if( method == EVP_des_ede3_cfb() ) n = HB_EVP_CIPHER_DES_EDE3_CFB; - else if( method == EVP_des_ede3_cfb1() ) n = HB_EVP_CIPHER_DES_EDE3_CFB1; - else if( method == EVP_des_ede3_cfb8() ) n = HB_EVP_CIPHER_DES_EDE3_CFB8; - else if( method == EVP_des_ofb() ) n = HB_EVP_CIPHER_DES_OFB; - else if( method == EVP_des_ede_ofb() ) n = HB_EVP_CIPHER_DES_EDE_OFB; - else if( method == EVP_des_ede3_ofb() ) n = HB_EVP_CIPHER_DES_EDE3_OFB; - else if( method == EVP_des_cbc() ) n = HB_EVP_CIPHER_DES_CBC; - else if( method == EVP_des_ede_cbc() ) n = HB_EVP_CIPHER_DES_EDE_CBC; - else if( method == EVP_des_ede3_cbc() ) n = HB_EVP_CIPHER_DES_EDE3_CBC; - else if( method == EVP_desx_cbc() ) n = HB_EVP_CIPHER_DESX_CBC; + else if( p == EVP_des_ecb() ) n = HB_EVP_CIPHER_DES_ECB; + else if( p == EVP_des_ede() ) n = HB_EVP_CIPHER_DES_EDE; + else if( p == EVP_des_ede3() ) n = HB_EVP_CIPHER_DES_EDE3; + else if( p == EVP_des_ede_ecb() ) n = HB_EVP_CIPHER_DES_EDE_ECB; + else if( p == EVP_des_ede3_ecb() ) n = HB_EVP_CIPHER_DES_EDE3_ECB; + else if( p == EVP_des_cfb64() ) n = HB_EVP_CIPHER_DES_CFB64; + else if( p == EVP_des_cfb() ) n = HB_EVP_CIPHER_DES_CFB; + else if( p == EVP_des_cfb1() ) n = HB_EVP_CIPHER_DES_CFB1; + else if( p == EVP_des_cfb8() ) n = HB_EVP_CIPHER_DES_CFB8; + else if( p == EVP_des_ede_cfb64() ) n = HB_EVP_CIPHER_DES_EDE_CFB64; + else if( p == EVP_des_ede_cfb() ) n = HB_EVP_CIPHER_DES_EDE_CFB; + else if( p == EVP_des_ede3_cfb64() ) n = HB_EVP_CIPHER_DES_EDE3_CFB64; + else if( p == EVP_des_ede3_cfb() ) n = HB_EVP_CIPHER_DES_EDE3_CFB; + else if( p == EVP_des_ede3_cfb1() ) n = HB_EVP_CIPHER_DES_EDE3_CFB1; + else if( p == EVP_des_ede3_cfb8() ) n = HB_EVP_CIPHER_DES_EDE3_CFB8; + else if( p == EVP_des_ofb() ) n = HB_EVP_CIPHER_DES_OFB; + else if( p == EVP_des_ede_ofb() ) n = HB_EVP_CIPHER_DES_EDE_OFB; + else if( p == EVP_des_ede3_ofb() ) n = HB_EVP_CIPHER_DES_EDE3_OFB; + else if( p == EVP_des_cbc() ) n = HB_EVP_CIPHER_DES_CBC; + else if( p == EVP_des_ede_cbc() ) n = HB_EVP_CIPHER_DES_EDE_CBC; + else if( p == EVP_des_ede3_cbc() ) n = HB_EVP_CIPHER_DES_EDE3_CBC; + else if( p == EVP_desx_cbc() ) n = HB_EVP_CIPHER_DESX_CBC; #endif #ifndef OPENSSL_NO_RC4 - else if( method == EVP_rc4() ) n = HB_EVP_CIPHER_RC4; - else if( method == EVP_rc4_40() ) n = HB_EVP_CIPHER_RC4_40; + else if( p == EVP_rc4() ) n = HB_EVP_CIPHER_RC4; + else if( p == EVP_rc4_40() ) n = HB_EVP_CIPHER_RC4_40; #endif #ifndef OPENSSL_NO_IDEA - else if( method == EVP_idea_ecb() ) n = HB_EVP_CIPHER_IDEA_ECB; - else if( method == EVP_idea_cfb64() ) n = HB_EVP_CIPHER_IDEA_CFB64; - else if( method == EVP_idea_cfb() ) n = HB_EVP_CIPHER_IDEA_CFB; - else if( method == EVP_idea_ofb() ) n = HB_EVP_CIPHER_IDEA_OFB; - else if( method == EVP_idea_cbc() ) n = HB_EVP_CIPHER_IDEA_CBC; + else if( p == EVP_idea_ecb() ) n = HB_EVP_CIPHER_IDEA_ECB; + else if( p == EVP_idea_cfb64() ) n = HB_EVP_CIPHER_IDEA_CFB64; + else if( p == EVP_idea_cfb() ) n = HB_EVP_CIPHER_IDEA_CFB; + else if( p == EVP_idea_ofb() ) n = HB_EVP_CIPHER_IDEA_OFB; + else if( p == EVP_idea_cbc() ) n = HB_EVP_CIPHER_IDEA_CBC; #endif #ifndef OPENSSL_NO_RC2 - else if( method == EVP_rc2_ecb() ) n = HB_EVP_CIPHER_RC2_ECB; - else if( method == EVP_rc2_cbc() ) n = HB_EVP_CIPHER_RC2_CBC; - else if( method == EVP_rc2_40_cbc() ) n = HB_EVP_CIPHER_RC2_40_CBC; - else if( method == EVP_rc2_64_cbc() ) n = HB_EVP_CIPHER_RC2_64_CBC; - else if( method == EVP_rc2_cfb64() ) n = HB_EVP_CIPHER_RC2_CFB64; - else if( method == EVP_rc2_cfb() ) n = HB_EVP_CIPHER_RC2_CFB; - else if( method == EVP_rc2_ofb() ) n = HB_EVP_CIPHER_RC2_OFB; + else if( p == EVP_rc2_ecb() ) n = HB_EVP_CIPHER_RC2_ECB; + else if( p == EVP_rc2_cbc() ) n = HB_EVP_CIPHER_RC2_CBC; + else if( p == EVP_rc2_40_cbc() ) n = HB_EVP_CIPHER_RC2_40_CBC; + else if( p == EVP_rc2_64_cbc() ) n = HB_EVP_CIPHER_RC2_64_CBC; + else if( p == EVP_rc2_cfb64() ) n = HB_EVP_CIPHER_RC2_CFB64; + else if( p == EVP_rc2_cfb() ) n = HB_EVP_CIPHER_RC2_CFB; + else if( p == EVP_rc2_ofb() ) n = HB_EVP_CIPHER_RC2_OFB; #endif #ifndef OPENSSL_NO_BF - else if( method == EVP_bf_ecb() ) n = HB_EVP_CIPHER_BF_ECB; - else if( method == EVP_bf_cbc() ) n = HB_EVP_CIPHER_BF_CBC; - else if( method == EVP_bf_cfb64() ) n = HB_EVP_CIPHER_BF_CFB64; - else if( method == EVP_bf_cfb() ) n = HB_EVP_CIPHER_BF_CFB; - else if( method == EVP_bf_ofb() ) n = HB_EVP_CIPHER_BF_OFB; + else if( p == EVP_bf_ecb() ) n = HB_EVP_CIPHER_BF_ECB; + else if( p == EVP_bf_cbc() ) n = HB_EVP_CIPHER_BF_CBC; + else if( p == EVP_bf_cfb64() ) n = HB_EVP_CIPHER_BF_CFB64; + else if( p == EVP_bf_cfb() ) n = HB_EVP_CIPHER_BF_CFB; + else if( p == EVP_bf_ofb() ) n = HB_EVP_CIPHER_BF_OFB; #endif #ifndef OPENSSL_NO_CAST - else if( method == EVP_cast5_ecb() ) n = HB_EVP_CIPHER_CAST5_ECB; - else if( method == EVP_cast5_cbc() ) n = HB_EVP_CIPHER_CAST5_CBC; - else if( method == EVP_cast5_cfb64() ) n = HB_EVP_CIPHER_CAST5_CFB64; - else if( method == EVP_cast5_cfb() ) n = HB_EVP_CIPHER_CAST5_CFB; - else if( method == EVP_cast5_ofb() ) n = HB_EVP_CIPHER_CAST5_OFB; + else if( p == EVP_cast5_ecb() ) n = HB_EVP_CIPHER_CAST5_ECB; + else if( p == EVP_cast5_cbc() ) n = HB_EVP_CIPHER_CAST5_CBC; + else if( p == EVP_cast5_cfb64() ) n = HB_EVP_CIPHER_CAST5_CFB64; + else if( p == EVP_cast5_cfb() ) n = HB_EVP_CIPHER_CAST5_CFB; + else if( p == EVP_cast5_ofb() ) n = HB_EVP_CIPHER_CAST5_OFB; #endif #ifndef OPENSSL_NO_RC5 - else if( method == EVP_rc5_32_12_16_cbc() ) n = HB_EVP_CIPHER_RC5_32_12_16_CBC; - else if( method == EVP_rc5_32_12_16_ecb() ) n = HB_EVP_CIPHER_RC5_32_12_16_ECB; - else if( method == EVP_rc5_32_12_16_cfb64() ) n = HB_EVP_CIPHER_RC5_32_12_16_CFB64; - else if( method == EVP_rc5_32_12_16_cfb() ) n = HB_EVP_CIPHER_RC5_32_12_16_CFB; - else if( method == EVP_rc5_32_12_16_ofb() ) n = HB_EVP_CIPHER_RC5_32_12_16_OFB; + else if( p == EVP_rc5_32_12_16_cbc() ) n = HB_EVP_CIPHER_RC5_32_12_16_CBC; + else if( p == EVP_rc5_32_12_16_ecb() ) n = HB_EVP_CIPHER_RC5_32_12_16_ECB; + else if( p == EVP_rc5_32_12_16_cfb64() ) n = HB_EVP_CIPHER_RC5_32_12_16_CFB64; + else if( p == EVP_rc5_32_12_16_cfb() ) n = HB_EVP_CIPHER_RC5_32_12_16_CFB; + else if( p == EVP_rc5_32_12_16_ofb() ) n = HB_EVP_CIPHER_RC5_32_12_16_OFB; #endif #ifndef OPENSSL_NO_AES - else if( method == EVP_aes_128_ecb() ) n = HB_EVP_CIPHER_AES_128_ECB; - else if( method == EVP_aes_128_cbc() ) n = HB_EVP_CIPHER_AES_128_CBC; - else if( method == EVP_aes_128_cfb1() ) n = HB_EVP_CIPHER_AES_128_CFB1; - else if( method == EVP_aes_128_cfb8() ) n = HB_EVP_CIPHER_AES_128_CFB8; - else if( method == EVP_aes_128_cfb128() ) n = HB_EVP_CIPHER_AES_128_CFB128; - else if( method == EVP_aes_128_cfb() ) n = HB_EVP_CIPHER_AES_128_CFB; - else if( method == EVP_aes_128_ofb() ) n = HB_EVP_CIPHER_AES_128_OFB; - else if( method == EVP_aes_192_ecb() ) n = HB_EVP_CIPHER_AES_192_ECB; - else if( method == EVP_aes_192_cbc() ) n = HB_EVP_CIPHER_AES_192_CBC; - else if( method == EVP_aes_192_cfb1() ) n = HB_EVP_CIPHER_AES_192_CFB1; - else if( method == EVP_aes_192_cfb8() ) n = HB_EVP_CIPHER_AES_192_CFB8; - else if( method == EVP_aes_192_cfb128() ) n = HB_EVP_CIPHER_AES_192_CFB128; - else if( method == EVP_aes_192_cfb() ) n = HB_EVP_CIPHER_AES_192_CFB; - else if( method == EVP_aes_192_ofb() ) n = HB_EVP_CIPHER_AES_192_OFB; - else if( method == EVP_aes_256_ecb() ) n = HB_EVP_CIPHER_AES_256_ECB; - else if( method == EVP_aes_256_cbc() ) n = HB_EVP_CIPHER_AES_256_CBC; - else if( method == EVP_aes_256_cfb1() ) n = HB_EVP_CIPHER_AES_256_CFB1; - else if( method == EVP_aes_256_cfb8() ) n = HB_EVP_CIPHER_AES_256_CFB8; - else if( method == EVP_aes_256_cfb128() ) n = HB_EVP_CIPHER_AES_256_CFB128; - else if( method == EVP_aes_256_cfb() ) n = HB_EVP_CIPHER_AES_256_CFB; - else if( method == EVP_aes_256_ofb() ) n = HB_EVP_CIPHER_AES_256_OFB; + else if( p == EVP_aes_128_ecb() ) n = HB_EVP_CIPHER_AES_128_ECB; + else if( p == EVP_aes_128_cbc() ) n = HB_EVP_CIPHER_AES_128_CBC; + else if( p == EVP_aes_128_cfb1() ) n = HB_EVP_CIPHER_AES_128_CFB1; + else if( p == EVP_aes_128_cfb8() ) n = HB_EVP_CIPHER_AES_128_CFB8; + else if( p == EVP_aes_128_cfb128() ) n = HB_EVP_CIPHER_AES_128_CFB128; + else if( p == EVP_aes_128_cfb() ) n = HB_EVP_CIPHER_AES_128_CFB; + else if( p == EVP_aes_128_ofb() ) n = HB_EVP_CIPHER_AES_128_OFB; + else if( p == EVP_aes_192_ecb() ) n = HB_EVP_CIPHER_AES_192_ECB; + else if( p == EVP_aes_192_cbc() ) n = HB_EVP_CIPHER_AES_192_CBC; + else if( p == EVP_aes_192_cfb1() ) n = HB_EVP_CIPHER_AES_192_CFB1; + else if( p == EVP_aes_192_cfb8() ) n = HB_EVP_CIPHER_AES_192_CFB8; + else if( p == EVP_aes_192_cfb128() ) n = HB_EVP_CIPHER_AES_192_CFB128; + else if( p == EVP_aes_192_cfb() ) n = HB_EVP_CIPHER_AES_192_CFB; + else if( p == EVP_aes_192_ofb() ) n = HB_EVP_CIPHER_AES_192_OFB; + else if( p == EVP_aes_256_ecb() ) n = HB_EVP_CIPHER_AES_256_ECB; + else if( p == EVP_aes_256_cbc() ) n = HB_EVP_CIPHER_AES_256_CBC; + else if( p == EVP_aes_256_cfb1() ) n = HB_EVP_CIPHER_AES_256_CFB1; + else if( p == EVP_aes_256_cfb8() ) n = HB_EVP_CIPHER_AES_256_CFB8; + else if( p == EVP_aes_256_cfb128() ) n = HB_EVP_CIPHER_AES_256_CFB128; + else if( p == EVP_aes_256_cfb() ) n = HB_EVP_CIPHER_AES_256_CFB; + else if( p == EVP_aes_256_ofb() ) n = HB_EVP_CIPHER_AES_256_OFB; #endif #ifndef OPENSSL_NO_CAMELLIA - else if( method == EVP_camellia_128_ecb() ) n = HB_EVP_CIPHER_CAMELLIA_128_ECB; - else if( method == EVP_camellia_128_cbc() ) n = HB_EVP_CIPHER_CAMELLIA_128_CBC; - else if( method == EVP_camellia_128_cfb1() ) n = HB_EVP_CIPHER_CAMELLIA_128_CFB1; - else if( method == EVP_camellia_128_cfb8() ) n = HB_EVP_CIPHER_CAMELLIA_128_CFB8; - else if( method == EVP_camellia_128_cfb128() ) n = HB_EVP_CIPHER_CAMELLIA_128_CFB128; - else if( method == EVP_camellia_128_cfb() ) n = HB_EVP_CIPHER_CAMELLIA_128_CFB; - else if( method == EVP_camellia_128_ofb() ) n = HB_EVP_CIPHER_CAMELLIA_128_OFB; - else if( method == EVP_camellia_192_ecb() ) n = HB_EVP_CIPHER_CAMELLIA_192_ECB; - else if( method == EVP_camellia_192_cbc() ) n = HB_EVP_CIPHER_CAMELLIA_192_CBC; - else if( method == EVP_camellia_192_cfb1() ) n = HB_EVP_CIPHER_CAMELLIA_192_CFB1; - else if( method == EVP_camellia_192_cfb8() ) n = HB_EVP_CIPHER_CAMELLIA_192_CFB8; - else if( method == EVP_camellia_192_cfb128() ) n = HB_EVP_CIPHER_CAMELLIA_192_CFB128; - else if( method == EVP_camellia_192_cfb() ) n = HB_EVP_CIPHER_CAMELLIA_192_CFB; - else if( method == EVP_camellia_192_ofb() ) n = HB_EVP_CIPHER_CAMELLIA_192_OFB; - else if( method == EVP_camellia_256_ecb() ) n = HB_EVP_CIPHER_CAMELLIA_256_ECB; - else if( method == EVP_camellia_256_cbc() ) n = HB_EVP_CIPHER_CAMELLIA_256_CBC; - else if( method == EVP_camellia_256_cfb1() ) n = HB_EVP_CIPHER_CAMELLIA_256_CFB1; - else if( method == EVP_camellia_256_cfb8() ) n = HB_EVP_CIPHER_CAMELLIA_256_CFB8; - else if( method == EVP_camellia_256_cfb128() ) n = HB_EVP_CIPHER_CAMELLIA_256_CFB128; - else if( method == EVP_camellia_256_cfb() ) n = HB_EVP_CIPHER_CAMELLIA_256_CFB; - else if( method == EVP_camellia_256_ofb() ) n = HB_EVP_CIPHER_CAMELLIA_256_OFB; + else if( p == EVP_camellia_128_ecb() ) n = HB_EVP_CIPHER_CAMELLIA_128_ECB; + else if( p == EVP_camellia_128_cbc() ) n = HB_EVP_CIPHER_CAMELLIA_128_CBC; + else if( p == EVP_camellia_128_cfb1() ) n = HB_EVP_CIPHER_CAMELLIA_128_CFB1; + else if( p == EVP_camellia_128_cfb8() ) n = HB_EVP_CIPHER_CAMELLIA_128_CFB8; + else if( p == EVP_camellia_128_cfb128() ) n = HB_EVP_CIPHER_CAMELLIA_128_CFB128; + else if( p == EVP_camellia_128_cfb() ) n = HB_EVP_CIPHER_CAMELLIA_128_CFB; + else if( p == EVP_camellia_128_ofb() ) n = HB_EVP_CIPHER_CAMELLIA_128_OFB; + else if( p == EVP_camellia_192_ecb() ) n = HB_EVP_CIPHER_CAMELLIA_192_ECB; + else if( p == EVP_camellia_192_cbc() ) n = HB_EVP_CIPHER_CAMELLIA_192_CBC; + else if( p == EVP_camellia_192_cfb1() ) n = HB_EVP_CIPHER_CAMELLIA_192_CFB1; + else if( p == EVP_camellia_192_cfb8() ) n = HB_EVP_CIPHER_CAMELLIA_192_CFB8; + else if( p == EVP_camellia_192_cfb128() ) n = HB_EVP_CIPHER_CAMELLIA_192_CFB128; + else if( p == EVP_camellia_192_cfb() ) n = HB_EVP_CIPHER_CAMELLIA_192_CFB; + else if( p == EVP_camellia_192_ofb() ) n = HB_EVP_CIPHER_CAMELLIA_192_OFB; + else if( p == EVP_camellia_256_ecb() ) n = HB_EVP_CIPHER_CAMELLIA_256_ECB; + else if( p == EVP_camellia_256_cbc() ) n = HB_EVP_CIPHER_CAMELLIA_256_CBC; + else if( p == EVP_camellia_256_cfb1() ) n = HB_EVP_CIPHER_CAMELLIA_256_CFB1; + else if( p == EVP_camellia_256_cfb8() ) n = HB_EVP_CIPHER_CAMELLIA_256_CFB8; + else if( p == EVP_camellia_256_cfb128() ) n = HB_EVP_CIPHER_CAMELLIA_256_CFB128; + else if( p == EVP_camellia_256_cfb() ) n = HB_EVP_CIPHER_CAMELLIA_256_CFB; + else if( p == EVP_camellia_256_ofb() ) n = HB_EVP_CIPHER_CAMELLIA_256_OFB; #endif #ifndef OPENSSL_NO_SEED - else if( method == EVP_seed_ecb() ) n = HB_EVP_CIPHER_SEED_ECB; - else if( method == EVP_seed_cbc() ) n = HB_EVP_CIPHER_SEED_CBC; - else if( method == EVP_seed_cfb128() ) n = HB_EVP_CIPHER_SEED_CFB128; - else if( method == EVP_seed_cfb() ) n = HB_EVP_CIPHER_SEED_CFB; - else if( method == EVP_seed_ofb() ) n = HB_EVP_CIPHER_SEED_OFB; + else if( p == EVP_seed_ecb() ) n = HB_EVP_CIPHER_SEED_ECB; + else if( p == EVP_seed_cbc() ) n = HB_EVP_CIPHER_SEED_CBC; + else if( p == EVP_seed_cfb128() ) n = HB_EVP_CIPHER_SEED_CFB128; + else if( p == EVP_seed_cfb() ) n = HB_EVP_CIPHER_SEED_CFB; + else if( p == EVP_seed_ofb() ) n = HB_EVP_CIPHER_SEED_OFB; #endif - else n = HB_EVP_CIPHER_UNSUPPORTED; + else n = HB_EVP_CIPHER_UNSUPPORTED; return n; } @@ -375,51 +375,51 @@ HB_FUNC( EVP_GET_CIPHERBYNID ) HB_FUNC( EVP_CIPHER_NID ) { - const EVP_CIPHER * method = hb_EVP_CIPHER_par( 1 ); + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 ); - hb_retni( method ? EVP_CIPHER_nid( method ) : 0 ); + hb_retni( cipher ? EVP_CIPHER_nid( cipher ) : 0 ); } HB_FUNC( EVP_CIPHER_BLOCK_SIZE ) { - const EVP_CIPHER * method = hb_EVP_CIPHER_par( 1 ); + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 ); - hb_retni( method ? EVP_CIPHER_block_size( method ) : 0 ); + hb_retni( cipher ? EVP_CIPHER_block_size( cipher ) : 0 ); } HB_FUNC( EVP_CIPHER_KEY_LENGTH ) { - const EVP_CIPHER * method = hb_EVP_CIPHER_par( 1 ); + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 ); - hb_retni( method ? EVP_CIPHER_key_length( method ) : 0 ); + hb_retni( cipher ? EVP_CIPHER_key_length( cipher ) : 0 ); } HB_FUNC( EVP_CIPHER_KEY_IV_LENGTH ) { - const EVP_CIPHER * method = hb_EVP_CIPHER_par( 1 ); + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 ); - hb_retni( method ? EVP_CIPHER_iv_length( method ) : 0 ); + hb_retni( cipher ? EVP_CIPHER_iv_length( cipher ) : 0 ); } HB_FUNC( EVP_CIPHER_KEY_FLAGS ) { - const EVP_CIPHER * method = hb_EVP_CIPHER_par( 1 ); + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 ); - hb_retnint( method ? EVP_CIPHER_flags( method ) : 0 ); + hb_retnint( cipher ? EVP_CIPHER_flags( cipher ) : 0 ); } HB_FUNC( EVP_CIPHER_KEY_MODE ) { - const EVP_CIPHER * method = hb_EVP_CIPHER_par( 1 ); + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 ); - hb_retni( method ? EVP_CIPHER_mode( method ) : 0 ); + hb_retni( cipher ? EVP_CIPHER_mode( cipher ) : 0 ); } HB_FUNC( EVP_CIPHER_TYPE ) { - const EVP_CIPHER * method = hb_EVP_CIPHER_par( 1 ); + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 1 ); - hb_retni( method ? EVP_CIPHER_type( method ) : 0 ); + hb_retni( cipher ? EVP_CIPHER_type( cipher ) : 0 ); } HB_FUNC( HB_EVP_CIPHER_CTX_CREATE ) @@ -529,13 +529,15 @@ HB_FUNC( EVP_CIPHER_CTX_CIPHER ) HB_FUNC( EVP_ENCRYPTINIT ) { - if( hb_EVP_CIPHER_CTX_is( 1 ) && hb_EVP_CIPHER_is( 2 ) ) + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 2 ); + + if( hb_EVP_CIPHER_CTX_is( 1 ) && cipher ) { EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); if( ctx ) hb_retni( EVP_EncryptInit( ctx, - hb_EVP_CIPHER_par( 2 ), + cipher, ( const unsigned char * ) hb_parc( 3 ), ( const unsigned char * ) hb_parc( 4 ) ) ); } @@ -545,13 +547,15 @@ HB_FUNC( EVP_ENCRYPTINIT ) HB_FUNC( EVP_ENCRYPTINIT_EX ) { - if( hb_EVP_CIPHER_CTX_is( 1 ) && hb_EVP_CIPHER_is( 2 ) ) + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 2 ); + + if( hb_EVP_CIPHER_CTX_is( 1 ) && cipher ) { EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); if( ctx ) hb_retni( EVP_EncryptInit_ex( ctx, - hb_EVP_CIPHER_par( 2 ), + cipher, ( ENGINE * ) hb_parptr( 3 ), ( const unsigned char * ) hb_parc( 4 ), ( const unsigned char * ) hb_parc( 5 ) ) ); @@ -644,13 +648,15 @@ HB_FUNC( EVP_ENCRYPTFINAL_EX ) HB_FUNC( EVP_DECRYPTINIT ) { - if( hb_EVP_CIPHER_CTX_is( 1 ) && hb_EVP_CIPHER_is( 2 ) ) + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 2 ); + + if( hb_EVP_CIPHER_CTX_is( 1 ) && cipher ) { EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); if( ctx ) hb_retni( EVP_DecryptInit( ctx, - hb_EVP_CIPHER_par( 2 ), + cipher, ( const unsigned char * ) hb_parc( 3 ), ( const unsigned char * ) hb_parc( 4 ) ) ); } @@ -660,13 +666,15 @@ HB_FUNC( EVP_DECRYPTINIT ) HB_FUNC( EVP_DECRYPTINIT_EX ) { - if( hb_EVP_CIPHER_CTX_is( 1 ) && hb_EVP_CIPHER_is( 2 ) ) + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 2 ); + + if( hb_EVP_CIPHER_CTX_is( 1 ) && cipher ) { EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); if( ctx ) hb_retni( EVP_DecryptInit_ex( ctx, - hb_EVP_CIPHER_par( 2 ), + cipher, ( ENGINE * ) hb_parptr( 3 ), ( const unsigned char * ) hb_parc( 4 ), ( const unsigned char * ) hb_parc( 5 ) ) ); @@ -759,16 +767,18 @@ HB_FUNC( EVP_DECRYPTFINAL_EX ) HB_FUNC( EVP_CIPHERINIT ) { - if( hb_EVP_CIPHER_CTX_is( 1 ) && hb_EVP_CIPHER_is( 2 ) ) + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 2 ); + + if( hb_EVP_CIPHER_CTX_is( 1 ) && cipher ) { EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); if( ctx ) hb_retni( EVP_CipherInit( ctx, - hb_EVP_CIPHER_par( 2 ), - ( const unsigned char * ) hb_parc( 3 ), - ( const unsigned char * ) hb_parc( 4 ), - hb_parni( 5 ) ) ); + cipher, + ( const unsigned char * ) hb_parc( 3 ), + ( const unsigned char * ) hb_parc( 4 ), + hb_parni( 5 ) ) ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -776,13 +786,15 @@ HB_FUNC( EVP_CIPHERINIT ) HB_FUNC( EVP_CIPHERINIT_EX ) { - if( hb_EVP_CIPHER_CTX_is( 1 ) && hb_EVP_CIPHER_is( 2 ) ) + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 2 ); + + if( hb_EVP_CIPHER_CTX_is( 1 ) && cipher ) { EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); if( ctx ) hb_retni( EVP_CipherInit_ex( ctx, - hb_EVP_CIPHER_par( 2 ), + cipher, ( ENGINE * ) hb_parptr( 3 ), ( const unsigned char * ) hb_parc( 4 ), ( const unsigned char * ) hb_parc( 5 ), diff --git a/harbour/contrib/hbssl/evpmd.c b/harbour/contrib/hbssl/evpmd.c index 77a7af8622..e30af22ea4 100644 --- a/harbour/contrib/hbssl/evpmd.c +++ b/harbour/contrib/hbssl/evpmd.c @@ -99,86 +99,86 @@ int hb_EVP_MD_is( int iParam ) const EVP_MD * hb_EVP_MD_par( int iParam ) { - const EVP_MD * method; + const EVP_MD * p; if( HB_ISCHAR( iParam ) ) return EVP_get_digestbyname( hb_parc( iParam ) ); switch( hb_parni( iParam ) ) { - case HB_EVP_MD_MD_NULL : method = EVP_md_null(); break; + case HB_EVP_MD_MD_NULL : p = EVP_md_null(); break; #ifndef OPENSSL_NO_MD2 - case HB_EVP_MD_MD2 : method = EVP_md2(); break; + case HB_EVP_MD_MD2 : p = EVP_md2(); break; #endif #ifndef OPENSSL_NO_MD4 - case HB_EVP_MD_MD4 : method = EVP_md4(); break; + case HB_EVP_MD_MD4 : p = EVP_md4(); break; #endif #ifndef OPENSSL_NO_MD5 - case HB_EVP_MD_MD5 : method = EVP_md5(); break; + case HB_EVP_MD_MD5 : p = EVP_md5(); break; #endif #ifndef OPENSSL_NO_SHA - case HB_EVP_MD_SHA : method = EVP_sha(); break; - case HB_EVP_MD_SHA1 : method = EVP_sha1(); break; - case HB_EVP_MD_DSS : method = EVP_dss(); break; - case HB_EVP_MD_DSS1 : method = EVP_dss1(); break; - case HB_EVP_MD_ECDSA : method = EVP_ecdsa(); break; + case HB_EVP_MD_SHA : p = EVP_sha(); break; + case HB_EVP_MD_SHA1 : p = EVP_sha1(); break; + case HB_EVP_MD_DSS : p = EVP_dss(); break; + case HB_EVP_MD_DSS1 : p = EVP_dss1(); break; + case HB_EVP_MD_ECDSA : p = EVP_ecdsa(); break; #endif #ifndef OPENSSL_NO_SHA256 - case HB_EVP_MD_SHA224 : method = EVP_sha224(); break; - case HB_EVP_MD_SHA256 : method = EVP_sha256(); break; + case HB_EVP_MD_SHA224 : p = EVP_sha224(); break; + case HB_EVP_MD_SHA256 : p = EVP_sha256(); break; #endif #ifndef OPENSSL_NO_SHA512 - case HB_EVP_MD_SHA384 : method = EVP_sha384(); break; - case HB_EVP_MD_SHA512 : method = EVP_sha512(); break; + case HB_EVP_MD_SHA384 : p = EVP_sha384(); break; + case HB_EVP_MD_SHA512 : p = EVP_sha512(); break; #endif #ifndef OPENSSL_NO_MDC2 - case HB_EVP_MD_MDC2 : method = EVP_mdc2(); break; + case HB_EVP_MD_MDC2 : p = EVP_mdc2(); break; #endif #ifndef OPENSSL_NO_RIPEMD - case HB_EVP_MD_RIPEMD160 : method = EVP_ripemd160(); break; + case HB_EVP_MD_RIPEMD160 : p = EVP_ripemd160(); break; #endif - default : method = NULL; + default : p = NULL; } - return method; + return p; } -static int hb_EVP_MD_ptr_to_id( const EVP_MD * method ) +static int hb_EVP_MD_ptr_to_id( const EVP_MD * p ) { int n; - if( method == EVP_md_null() ) n = HB_EVP_MD_MD_NULL; + if( p == EVP_md_null() ) n = HB_EVP_MD_MD_NULL; #ifndef OPENSSL_NO_MD2 - else if( method == EVP_md2() ) n = HB_EVP_MD_MD2; + else if( p == EVP_md2() ) n = HB_EVP_MD_MD2; #endif #ifndef OPENSSL_NO_MD4 - else if( method == EVP_md4() ) n = HB_EVP_MD_MD4; + else if( p == EVP_md4() ) n = HB_EVP_MD_MD4; #endif #ifndef OPENSSL_NO_MD5 - else if( method == EVP_md5() ) n = HB_EVP_MD_MD5; + else if( p == EVP_md5() ) n = HB_EVP_MD_MD5; #endif #ifndef OPENSSL_NO_SHA - else if( method == EVP_sha() ) n = HB_EVP_MD_SHA; - else if( method == EVP_sha1() ) n = HB_EVP_MD_SHA1; - else if( method == EVP_dss() ) n = HB_EVP_MD_DSS; - else if( method == EVP_dss1() ) n = HB_EVP_MD_DSS1; - else if( method == EVP_ecdsa() ) n = HB_EVP_MD_ECDSA; + else if( p == EVP_sha() ) n = HB_EVP_MD_SHA; + else if( p == EVP_sha1() ) n = HB_EVP_MD_SHA1; + else if( p == EVP_dss() ) n = HB_EVP_MD_DSS; + else if( p == EVP_dss1() ) n = HB_EVP_MD_DSS1; + else if( p == EVP_ecdsa() ) n = HB_EVP_MD_ECDSA; #endif #ifndef OPENSSL_NO_SHA256 - else if( method == EVP_sha224() ) n = HB_EVP_MD_SHA224; - else if( method == EVP_sha256() ) n = HB_EVP_MD_SHA256; + else if( p == EVP_sha224() ) n = HB_EVP_MD_SHA224; + else if( p == EVP_sha256() ) n = HB_EVP_MD_SHA256; #endif #ifndef OPENSSL_NO_SHA512 - else if( method == EVP_sha384() ) n = HB_EVP_MD_SHA384; - else if( method == EVP_sha512() ) n = HB_EVP_MD_SHA512; + else if( p == EVP_sha384() ) n = HB_EVP_MD_SHA384; + else if( p == EVP_sha512() ) n = HB_EVP_MD_SHA512; #endif #ifndef OPENSSL_NO_MDC2 - else if( method == EVP_mdc2() ) n = HB_EVP_MD_MDC2; + else if( p == EVP_mdc2() ) n = HB_EVP_MD_MDC2; #endif #ifndef OPENSSL_NO_RIPEMD - else if( method == EVP_ripemd160() ) n = HB_EVP_MD_RIPEMD160; + else if( p == EVP_ripemd160() ) n = HB_EVP_MD_RIPEMD160; #endif - else n = HB_EVP_MD_UNSUPPORTED; + else n = HB_EVP_MD_UNSUPPORTED; return n; } @@ -201,37 +201,37 @@ HB_FUNC( EVP_GET_DIGESTBYNID ) HB_FUNC( EVP_MD_TYPE ) { - const EVP_MD * method = hb_EVP_MD_par( 1 ); + const EVP_MD * md = hb_EVP_MD_par( 1 ); - hb_retni( method ? EVP_MD_type( method ) : 0 ); + hb_retni( md ? EVP_MD_type( md ) : 0 ); } HB_FUNC( EVP_MD_NID ) { - const EVP_MD * method = hb_EVP_MD_par( 1 ); + const EVP_MD * md = hb_EVP_MD_par( 1 ); - hb_retni( method ? EVP_MD_nid( method ) : 0 ); + hb_retni( md ? EVP_MD_nid( md ) : 0 ); } HB_FUNC( EVP_MD_PKEY_TYPE ) { - const EVP_MD * method = hb_EVP_MD_par( 1 ); + const EVP_MD * md = hb_EVP_MD_par( 1 ); - hb_retni( method ? EVP_MD_pkey_type( method ) : 0 ); + hb_retni( md ? EVP_MD_pkey_type( md ) : 0 ); } HB_FUNC( EVP_MD_SIZE ) { - const EVP_MD * method = hb_EVP_MD_par( 1 ); + const EVP_MD * md = hb_EVP_MD_par( 1 ); - hb_retni( method ? EVP_MD_size( method ) : 0 ); + hb_retni( md ? EVP_MD_size( md ) : 0 ); } HB_FUNC( EVP_MD_BLOCK_SIZE ) { - const EVP_MD * method = hb_EVP_MD_par( 1 ); + const EVP_MD * md = hb_EVP_MD_par( 1 ); - hb_retni( method ? EVP_MD_block_size( method ) : 0 ); + hb_retni( md ? EVP_MD_block_size( md ) : 0 ); } HB_FUNC( EVP_MD_CTX_CREATE ) @@ -314,12 +314,14 @@ HB_FUNC( EVP_MD_CTX_COPY_EX ) HB_FUNC( EVP_DIGESTINIT ) { - if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_is( 2 ) ) + const EVP_MD * md = hb_EVP_MD_par( 2 ); + + if( hb_EVP_MD_CTX_is( 1 ) && md ) { EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 ); if( ctx ) - hb_retni( EVP_DigestInit( ctx, hb_EVP_MD_par( 2 ) ) ); + hb_retni( EVP_DigestInit( ctx, md ) ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -327,12 +329,14 @@ HB_FUNC( EVP_DIGESTINIT ) HB_FUNC( EVP_DIGESTINIT_EX ) { - if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_is( 2 ) ) + const EVP_MD * md = hb_EVP_MD_par( 2 ); + + if( hb_EVP_MD_CTX_is( 1 ) && md ) { EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 ); if( ctx ) - hb_retni( EVP_DigestInit_ex( ctx, hb_EVP_MD_par( 2 ), ( ENGINE * ) hb_parptr( 3 ) ) ); + hb_retni( EVP_DigestInit_ex( ctx, md, ( ENGINE * ) hb_parptr( 3 ) ) ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -405,12 +409,14 @@ HB_FUNC( EVP_DIGESTFINAL_EX ) HB_FUNC( EVP_SIGNINIT ) { - if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_is( 2 ) ) + const EVP_MD * md = hb_EVP_MD_par( 2 ); + + if( hb_EVP_MD_CTX_is( 1 ) && md ) { EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 ); if( ctx ) - EVP_SignInit( ctx, hb_EVP_MD_par( 2 ) ); + EVP_SignInit( ctx, md ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -418,12 +424,14 @@ HB_FUNC( EVP_SIGNINIT ) HB_FUNC( EVP_SIGNINIT_EX ) { - if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_is( 2 ) ) + const EVP_MD * md = hb_EVP_MD_par( 2 ); + + if( hb_EVP_MD_CTX_is( 1 ) && md ) { EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 ); if( ctx ) - hb_retni( EVP_SignInit_ex( ctx, hb_EVP_MD_par( 2 ), ( ENGINE * ) hb_parptr( 3 ) ) ); + hb_retni( EVP_SignInit_ex( ctx, md, ( ENGINE * ) hb_parptr( 3 ) ) ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -470,12 +478,14 @@ HB_FUNC( EVP_SIGNFINAL ) HB_FUNC( EVP_VERIFYINIT ) { - if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_is( 2 ) ) + const EVP_MD * md = hb_EVP_MD_par( 2 ); + + if( hb_EVP_MD_CTX_is( 1 ) && md ) { EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 ); if( ctx ) - hb_retni( EVP_VerifyInit( ctx, hb_EVP_MD_par( 2 ) ) ); + hb_retni( EVP_VerifyInit( ctx, md ) ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); @@ -483,12 +493,14 @@ HB_FUNC( EVP_VERIFYINIT ) HB_FUNC( EVP_VERIFYINIT_EX ) { - if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_is( 2 ) ) + const EVP_MD * md = hb_EVP_MD_par( 2 ); + + if( hb_EVP_MD_CTX_is( 1 ) && md ) { EVP_MD_CTX * ctx = hb_EVP_MD_CTX_par( 1 ); if( ctx ) - hb_retni( EVP_VerifyInit_ex( ctx, hb_EVP_MD_par( 2 ), ( ENGINE * ) hb_parptr( 3 ) ) ); + hb_retni( EVP_VerifyInit_ex( ctx, md, ( ENGINE * ) hb_parptr( 3 ) ) ); } else hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); diff --git a/harbour/contrib/hbssl/ssl.c b/harbour/contrib/hbssl/ssl.c index 80b07006a4..b51eb958e0 100644 --- a/harbour/contrib/hbssl/ssl.c +++ b/harbour/contrib/hbssl/ssl.c @@ -573,24 +573,24 @@ HB_FUNC( SSL_GET_SSL_METHOD ) if( ssl ) { - SSL_METHOD * method = SSL_get_ssl_method( ssl ); - int nMethod; + SSL_METHOD * p = SSL_get_ssl_method( ssl ); + int n; - if( method == SSLv2_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV2; - else if( method == SSLv2_server_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV2_SERVER; - else if( method == SSLv2_client_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV2_CLIENT; - else if( method == SSLv3_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV3; - else if( method == SSLv3_server_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV3_SERVER; - else if( method == SSLv3_client_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV3_CLIENT; - else if( method == TLSv1_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_TLSV1; - else if( method == TLSv1_server_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_TLSV1_SERVER; - else if( method == TLSv1_client_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_TLSV1_CLIENT; - else if( method == SSLv23_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV23; - else if( method == SSLv23_server_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV23_SERVER; - else if( method == SSLv23_client_method() ) nMethod = HB_SSL_CTX_NEW_METHOD_SSLV23_CLIENT; - else nMethod = HB_SSL_CTX_NEW_METHOD_UNKNOWN; + if( p == SSLv2_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV2; + else if( p == SSLv2_server_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV2_SERVER; + else if( p == SSLv2_client_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV2_CLIENT; + else if( p == SSLv3_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV3; + else if( p == SSLv3_server_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV3_SERVER; + else if( p == SSLv3_client_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV3_CLIENT; + else if( p == TLSv1_method() ) n = HB_SSL_CTX_NEW_METHOD_TLSV1; + else if( p == TLSv1_server_method() ) n = HB_SSL_CTX_NEW_METHOD_TLSV1_SERVER; + else if( p == TLSv1_client_method() ) n = HB_SSL_CTX_NEW_METHOD_TLSV1_CLIENT; + else if( p == SSLv23_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV23; + else if( p == SSLv23_server_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV23_SERVER; + else if( p == SSLv23_client_method() ) n = HB_SSL_CTX_NEW_METHOD_SSLV23_CLIENT; + else n = HB_SSL_CTX_NEW_METHOD_UNKNOWN; - hb_retni( nMethod ); + hb_retni( n ); } } else diff --git a/harbour/contrib/hbssl/sslctx.c b/harbour/contrib/hbssl/sslctx.c index 3bddc9f5a3..2ad44b8daf 100644 --- a/harbour/contrib/hbssl/sslctx.c +++ b/harbour/contrib/hbssl/sslctx.c @@ -85,26 +85,26 @@ SSL_CTX * hb_SSL_CTX_par( int iParam ) SSL_METHOD * hb_ssl_method_id_to_ptr( int n ) { - SSL_METHOD * method; + SSL_METHOD * p; switch( n ) { - case HB_SSL_CTX_NEW_METHOD_SSLV2 : method = SSLv2_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV2_SERVER : method = SSLv2_server_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV2_CLIENT : method = SSLv2_client_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV3 : method = SSLv3_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV3_SERVER : method = SSLv3_server_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV3_CLIENT : method = SSLv3_client_method(); break; - case HB_SSL_CTX_NEW_METHOD_TLSV1 : method = TLSv1_method(); break; - case HB_SSL_CTX_NEW_METHOD_TLSV1_SERVER : method = TLSv1_server_method(); break; - case HB_SSL_CTX_NEW_METHOD_TLSV1_CLIENT : method = TLSv1_client_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV23 : method = SSLv23_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV23_SERVER : method = SSLv23_server_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV23_CLIENT : method = SSLv23_client_method(); break; - default : method = SSLv23_method(); + case HB_SSL_CTX_NEW_METHOD_SSLV2 : p = SSLv2_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV2_SERVER : p = SSLv2_server_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV2_CLIENT : p = SSLv2_client_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV3 : p = SSLv3_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV3_SERVER : p = SSLv3_server_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV3_CLIENT : p = SSLv3_client_method(); break; + case HB_SSL_CTX_NEW_METHOD_TLSV1 : p = TLSv1_method(); break; + case HB_SSL_CTX_NEW_METHOD_TLSV1_SERVER : p = TLSv1_server_method(); break; + case HB_SSL_CTX_NEW_METHOD_TLSV1_CLIENT : p = TLSv1_client_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV23 : p = SSLv23_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV23_SERVER : p = SSLv23_server_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV23_CLIENT : p = SSLv23_client_method(); break; + default : p = SSLv23_method(); } - return method; + return p; } HB_FUNC( SSL_CTX_NEW ) diff --git a/harbour/contrib/hbssl/tests/crypt.prg b/harbour/contrib/hbssl/tests/crypt.prg index e9fe416d62..5b837286b1 100644 --- a/harbour/contrib/hbssl/tests/crypt.prg +++ b/harbour/contrib/hbssl/tests/crypt.prg @@ -36,6 +36,7 @@ PROCEDURE Main() EVP_EncryptFinal( ctx, @result ) encrypted += result ? "ENCRYTPTED", ">" + hb_StrToHex( encrypted ) + "<" + ? ">" + encrypted + "<" EVP_CIPHER_CTX_init( ctx ) EVP_CIPHER_CTX_cleanup( ctx ) diff --git a/harbour/contrib/hbssl/tests/digest.prg b/harbour/contrib/hbssl/tests/digest.prg index faa9501f3d..bb648435aa 100644 --- a/harbour/contrib/hbssl/tests/digest.prg +++ b/harbour/contrib/hbssl/tests/digest.prg @@ -16,13 +16,24 @@ PROCEDURE Main() LOCAL ctx LOCAL digest + LOCAL key + LOCAL iv + OpenSSL_add_all_digests() + OpenSSL_add_all_ciphers() + ? "Version built against:", hb_NumToHex( OPENSSL_VERSION() ) ? "Version loaded:", hb_NumToHex( SSLEAY() ) ctx := EVP_MD_CTX_create() EVP_MD_CTX_init( ctx ) + EVP_DigestInit_ex( ctx, "SHA256" ) + EVP_DigestUpdate( ctx, "sample text" ) + digest := "" + EVP_DigestFinal( ctx, @digest ) + ? "SHA256", ">" + hb_StrToHex( digest ) + "<" + EVP_DigestInit_ex( ctx, HB_EVP_MD_SHA256 ) EVP_DigestUpdate( ctx, "sample text" ) digest := "" @@ -37,6 +48,30 @@ PROCEDURE Main() EVP_DigestFinal( ctx, @digest ) ? "RIPEMD160", ">" + hb_StrToHex( digest ) + "<" + key := "" + iv := "" + ? "EVP_BytesToKey", EVP_BytesToKey( HB_EVP_CIPHER_AES_192_OFB, HB_EVP_MD_SHA256, "salt1234", "data", 2, @key, @iv ) + ? "KEY", hb_StrToHex( key ) + ? ">" + key + "<" + ? "IV", hb_StrToHex( iv ) + ? ">" + iv + "<" + + key := "" + iv := "" + ? "EVP_BytesToKey", EVP_BytesToKey( "AES-192-OFB", "SHA256", "salt1234", "data", 2, @key, @iv ) + ? "KEY", hb_StrToHex( key ) + ? ">" + key + "<" + ? "IV", hb_StrToHex( iv ) + ? ">" + iv + "<" + + key := "" + iv := "" + ? "EVP_BytesToKey", EVP_BytesToKey( "AES-192-OFB", "SHA256",, "data", 2, @key, @iv ) + ? "KEY", hb_StrToHex( key ) + ? ">" + key + "<" + ? "IV", hb_StrToHex( iv ) + ? ">" + iv + "<" + EVP_cleanup() RETURN diff --git a/harbour/contrib/hbssl/tests/hbmk.hbm b/harbour/contrib/hbssl/tests/hbmk.hbm index 00ccb1127e..7420eb2518 100644 --- a/harbour/contrib/hbssl/tests/hbmk.hbm +++ b/harbour/contrib/hbssl/tests/hbmk.hbm @@ -2,4 +2,6 @@ # $Id$ # +-w3 + ../hbssl.hbc