From 2cefe1006f1c9b69658270415eb988e4d137ebca Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 23 Jul 2009 12:05:14 +0000 Subject: [PATCH] 2009-07-23 14:04 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbssl/evpciph.c + EVP_OPENINIT(), EVP_OPENUPDATE(), EVP_OPENFINAL() (not tested yet) ; TOFIX: EVP_SEALINIT() - does something nasty with memory. * contrib/hbssl/ssl.c ! MSVC cast/warning. * config/globsh.cf + Put a nt cmd param in dblquotes. --- harbour/ChangeLog | 12 +++++ harbour/config/globsh.cf | 4 +- harbour/contrib/hbssl/evpciph.c | 83 +++++++++++++++++++++++++++++++-- harbour/contrib/hbssl/ssl.c | 2 +- 4 files changed, 93 insertions(+), 8 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0f45625d61..3674b0c452 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,18 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-23 14:04 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbssl/evpciph.c + + EVP_OPENINIT(), EVP_OPENUPDATE(), EVP_OPENFINAL() + (not tested yet) + ; TOFIX: EVP_SEALINIT() - does something nasty with memory. + + * contrib/hbssl/ssl.c + ! MSVC cast/warning. + + * config/globsh.cf + + Put a nt cmd param in dblquotes. + 2009-07-23 12:02 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbmisc/dates2.c * Renamed DAYSINMONTH() to HBMISC_DAYSINMONTH(), diff --git a/harbour/config/globsh.cf b/harbour/config/globsh.cf index 61891ad3a3..7db09ef288 100644 --- a/harbour/config/globsh.cf +++ b/harbour/config/globsh.cf @@ -57,12 +57,12 @@ MD = mkdir MDP = mkdir dirbase:: - -@$(CMDPREF)if not exist $(OBJ_DIR_OS) $(MDP) "$(OBJ_DIR_OS)" + -@$(CMDPREF)if not exist "$(OBJ_DIR_OS)" $(MDP) "$(OBJ_DIR_OS)" $(if $(LIB_FILE),-@$(CMDPREF)if not exist "$(LIB_DIR_OS)" $(MDP) "$(LIB_DIR_OS)",) $(if $(EXE_FILE),-@$(CMDPREF)if not exist "$(EXE_DIR_OS)" $(MDP) "$(EXE_DIR_OS)",) clean:: - -@$(CMDPREF)if exist $(OBJ_DIR_OS) $(RDP) "$(OBJ_DIR_OS)" + -@$(CMDPREF)if exist "$(OBJ_DIR_OS)" $(RDP) "$(OBJ_DIR_OS)" $(if $(LIB_FILE),-@$(CMDPREF)if exist "$(LIB_FILE_OS)" $(RM) "$(LIB_FILE_OS)",) $(if $(LIB_FILE),-@$(CMDPREF)if exist "$(basename $(LIB_FILE_OS)).bak" $(RM) "$(basename $(LIB_FILE_OS)).bak",) $(if $(LIB_FILE),-@$(CMDPREF)if exist "$(LIB_DIR_OS)" if not exist "$(LIB_DIR_OS)\*" $(RDP) "$(LIB_DIR_OS)",) diff --git a/harbour/contrib/hbssl/evpciph.c b/harbour/contrib/hbssl/evpciph.c index cc1ea2061b..bd2c799b01 100644 --- a/harbour/contrib/hbssl/evpciph.c +++ b/harbour/contrib/hbssl/evpciph.c @@ -904,7 +904,7 @@ HB_FUNC( EVP_SEALINIT ) npubk = ( int ) hb_arrayLen( pArray = hb_param( 5, HB_IT_ARRAY ) ); else if( HB_ISPOINTER( 5 ) ) { - if( ( pkey1 = ( EVP_PKEY * ) hb_parptr( 5 ) ) ) + if( ( pkey1 = ( EVP_PKEY * ) hb_parptr( 5 ) ) != NULL ) npubk = 1; } @@ -1014,11 +1014,84 @@ HB_FUNC( EVP_SEALFINAL ) hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } -#if 0 +HB_FUNC( EVP_OPENINIT ) +{ + const EVP_CIPHER * cipher = hb_EVP_CIPHER_par( 2 ); -int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek, int ekl,unsigned char *iv,EVP_PKEY *priv); -int EVP_OpenUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, unsigned char *in, int inl); -int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); + if( hb_EVP_CIPHER_CTX_is( 1 ) && cipher ) + { + EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); + EVP_PKEY * priv = ( EVP_PKEY * ) hb_parptr( 5 ); + + if( ctx && priv ) + hb_retni( EVP_OpenInit( ctx, + cipher, + ( const unsigned char * ) hb_parcx( 3 ), + hb_parclen( 3 ), + ( HB_ISCHAR( 4 ) && ( int ) hb_parclen( 4 ) == EVP_CIPHER_iv_length( cipher ) ) ? ( const unsigned char * ) hb_parc( 4 ) : NULL, + priv ) ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( EVP_OPENUPDATE ) +{ + if( hb_EVP_CIPHER_CTX_is( 1 ) ) + { + EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); + + if( ctx ) + { + int size = hb_parclen( 3 ) + EVP_CIPHER_CTX_block_size( ctx ) - 1; + unsigned char * buffer = ( unsigned char * ) hb_xgrab( size ); + + hb_retni( EVP_OpenUpdate( ctx, + buffer, + &size, + ( const unsigned char * ) hb_parcx( 3 ), + ( size_t ) hb_parclen( 3 ) ) ); + + if( size > 0 ) + { + if( ! hb_storclen_buffer( ( char * ) buffer, size, 2 ) ) + hb_xfree( buffer ); + } + else + hb_storc( NULL, 2 ); + } + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( EVP_OPENFINAL ) +{ + if( hb_EVP_CIPHER_CTX_is( 1 ) ) + { + EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); + + if( ctx ) + { + int size = EVP_CIPHER_CTX_block_size( ctx ); + unsigned char * buffer = ( unsigned char * ) hb_xgrab( size ); + + hb_retni( EVP_OpenFinal( ctx, buffer, &size ) ); + + if( size > 0 ) + { + if( ! hb_storclen_buffer( ( char * ) buffer, size, 2 ) ) + hb_xfree( buffer ); + } + else + hb_storc( NULL, 2 ); + } + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +#if 0 #define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d)) diff --git a/harbour/contrib/hbssl/ssl.c b/harbour/contrib/hbssl/ssl.c index d10734ebc2..1e740e4564 100644 --- a/harbour/contrib/hbssl/ssl.c +++ b/harbour/contrib/hbssl/ssl.c @@ -1469,7 +1469,7 @@ static void hb_ssl_msg_callback( int write_p, int version, int content_type, con PHB_ITEM p1 = hb_itemPutL( NULL, write_p ); PHB_ITEM p2 = hb_itemPutNI( NULL, version ); PHB_ITEM p3 = hb_itemPutNI( NULL, content_type ); - PHB_ITEM p4 = hb_itemPutCL( NULL, buf, ( ULONG ) len ); + PHB_ITEM p4 = hb_itemPutCL( NULL, ( const char * ) buf, ( ULONG ) len ); hb_vmEvalBlockV( ( PHB_ITEM ) userdata, 4, p1, p2, p3, p4 );