2009-07-22 15:39 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* include/hbapi.h
* source/common/hbstr.c
* source/rtl/hbmd5.c
* Moved (and somewhat standardized and renamed) mem to hex C
function from hbm5/rtl to common lib.
* bin/hb-func.sh
! Fixed double '%' chars in hbmk.cfg generation.
* contrib/hbcrypt/Makefile
+ contrib/hbcrypt/hbsha1.c
+ contrib/hbcrypt/hbsha1hm.c
+ contrib/hbcrypt/tests/testsha1.prg
+ Added HB_SHA1() and HB_HMAC_SHA1() functions.
* source/rtl/hbmd5.c
* Changed meaning of second boolean parameter. From
now on a .T. has to be passed to get binary output.
(I won't list this as a incompatible, as the new
parameter has just been introduced)
; by now HB_MD5() and HB_SHA*() functions are synced
in functionality.
* contrib/hbcrypt/hbsha1.c
* contrib/hbcrypt/hbsha2.c
* contrib/hbcrypt/hbsha1hm.c
* contrib/hbcrypt/hbsha2hm.c
* contrib/hbcrypt/tests/testsha2.prg
* Changed all SHA2 functions to returned digest in hex
format by default. The binary format can be requested by
passing .T. as an extra parameter.
INCOMPATIBLE: Please update your sources if you used
these functions. Add .T. parameter to keep
current workings.
* contrib/hbcurl/hbcurl.c
% Cleaned types (no BYTE, no BOOL, deleted unnecessary casts).
Only a few ULONGs remained.
* contrib/hbssl/pem.c
+ Some advances.
This commit is contained in:
@@ -17,6 +17,49 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-07-22 15:39 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* include/hbapi.h
|
||||
* source/common/hbstr.c
|
||||
* source/rtl/hbmd5.c
|
||||
* Moved (and somewhat standardized and renamed) mem to hex C
|
||||
function from hbm5/rtl to common lib.
|
||||
|
||||
* bin/hb-func.sh
|
||||
! Fixed double '%' chars in hbmk.cfg generation.
|
||||
|
||||
* contrib/hbcrypt/Makefile
|
||||
+ contrib/hbcrypt/hbsha1.c
|
||||
+ contrib/hbcrypt/hbsha1hm.c
|
||||
+ contrib/hbcrypt/tests/testsha1.prg
|
||||
+ Added HB_SHA1() and HB_HMAC_SHA1() functions.
|
||||
|
||||
* source/rtl/hbmd5.c
|
||||
* Changed meaning of second boolean parameter. From
|
||||
now on a .T. has to be passed to get binary output.
|
||||
(I won't list this as a incompatible, as the new
|
||||
parameter has just been introduced)
|
||||
; by now HB_MD5() and HB_SHA*() functions are synced
|
||||
in functionality.
|
||||
|
||||
* contrib/hbcrypt/hbsha1.c
|
||||
* contrib/hbcrypt/hbsha2.c
|
||||
* contrib/hbcrypt/hbsha1hm.c
|
||||
* contrib/hbcrypt/hbsha2hm.c
|
||||
* contrib/hbcrypt/tests/testsha2.prg
|
||||
* Changed all SHA2 functions to returned digest in hex
|
||||
format by default. The binary format can be requested by
|
||||
passing .T. as an extra parameter.
|
||||
INCOMPATIBLE: Please update your sources if you used
|
||||
these functions. Add .T. parameter to keep
|
||||
current workings.
|
||||
|
||||
* contrib/hbcurl/hbcurl.c
|
||||
% Cleaned types (no BYTE, no BOOL, deleted unnecessary casts).
|
||||
Only a few ULONGs remained.
|
||||
|
||||
* contrib/hbssl/pem.c
|
||||
+ Some advances.
|
||||
|
||||
2009-07-22 13:12 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbssl/Makefile
|
||||
+ contrib/hbssl/pem.c
|
||||
|
||||
@@ -243,10 +243,10 @@ mk_hbtools()
|
||||
echo "# Harbour Make configuration"> ${hb_hbmkcfg}
|
||||
echo "# Generated by Harbour build process">> ${hb_hbmkcfg}
|
||||
echo "">> ${hb_hbmkcfg}
|
||||
echo "libpaths=../contrib/%%{hb_name}">> ${hb_hbmkcfg}
|
||||
echo "libpaths=../contrib/rddsql/%%{hb_name}">> ${hb_hbmkcfg}
|
||||
echo "libpaths=../addons/%%{hb_name}">> ${hb_hbmkcfg}
|
||||
echo "libpaths=../examples/%%{hb_name}">> ${hb_hbmkcfg}
|
||||
echo "libpaths=../contrib/%{hb_name}">> ${hb_hbmkcfg}
|
||||
echo "libpaths=../contrib/rddsql/%{hb_name}">> ${hb_hbmkcfg}
|
||||
echo "libpaths=../addons/%{hb_name}">> ${hb_hbmkcfg}
|
||||
echo "libpaths=../examples/%{hb_name}">> ${hb_hbmkcfg}
|
||||
echo "">> ${hb_hbmkcfg}
|
||||
if [ -n "${hb_gt_ori}" ]; then
|
||||
echo "gtdef=${hb_mkdef}${hb_gt_ori}">> ${hb_hbmkcfg}
|
||||
|
||||
@@ -7,6 +7,8 @@ ROOT = ../../
|
||||
LIBNAME=hbcrypt
|
||||
|
||||
C_SOURCES=\
|
||||
hbsha1.c \
|
||||
hbsha1hm.c \
|
||||
hbsha2.c \
|
||||
hbsha2hm.c \
|
||||
sha1.c \
|
||||
|
||||
76
harbour/contrib/hbcrypt/hbsha1.c
Normal file
76
harbour/contrib/hbcrypt/hbsha1.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* SHA1 Harbour wrappers.
|
||||
*
|
||||
* Copyright 2009 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.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, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
|
||||
#include "sha1.h"
|
||||
|
||||
HB_FUNC( HB_SHA1 )
|
||||
{
|
||||
sha1_byte digest[ SHA1_DIGEST_LENGTH ];
|
||||
SHA_CTX ctx;
|
||||
|
||||
SHA1_Init( &ctx );
|
||||
SHA1_Update( &ctx, ( sha1_byte * ) hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
SHA1_Final( digest, &ctx );
|
||||
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
char hex[ ( sizeof( digest ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) digest, sizeof( digest ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) digest, sizeof( digest ) );
|
||||
|
||||
return;
|
||||
}
|
||||
78
harbour/contrib/hbcrypt/hbsha1hm.c
Normal file
78
harbour/contrib/hbcrypt/hbsha1hm.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* HMAC-SHA1 Harbour wrappers.
|
||||
*
|
||||
* Copyright 2009 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.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, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
|
||||
#include "sha1hmac.h"
|
||||
|
||||
HB_FUNC( HB_HMAC_SHA1 )
|
||||
{
|
||||
unsigned char mac[ HMAC_SHA1_DIGEST_LENGTH ];
|
||||
HMAC_SHA1_CTX ctx;
|
||||
|
||||
HMAC_SHA1_Init( &ctx );
|
||||
HMAC_SHA1_UpdateKey( &ctx, ( unsigned char * ) hb_parcx( 2 ), hb_parclen( 2 ) );
|
||||
HMAC_SHA1_EndKey( &ctx );
|
||||
HMAC_SHA1_StartMessage( &ctx );
|
||||
HMAC_SHA1_UpdateMessage( &ctx, ( unsigned char * ) hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
HMAC_SHA1_EndMessage( mac, &ctx );
|
||||
HMAC_SHA1_Done( &ctx );
|
||||
|
||||
if( ! hb_parl( 3 ) )
|
||||
{
|
||||
char hex[ ( sizeof( mac ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) mac, sizeof( mac ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) mac, sizeof( mac ) );
|
||||
}
|
||||
@@ -60,7 +60,14 @@ HB_FUNC( HB_SHA224 )
|
||||
|
||||
sha224( ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
|
||||
hb_retclen( ( char * ) digest, HB_SIZEOFARRAY( digest ) );
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
char hex[ ( sizeof( digest ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) digest, sizeof( digest ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) digest, sizeof( digest ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_SHA256 )
|
||||
@@ -69,7 +76,14 @@ HB_FUNC( HB_SHA256 )
|
||||
|
||||
sha256( ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
|
||||
hb_retclen( ( char * ) digest, HB_SIZEOFARRAY( digest ) );
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
char hex[ ( sizeof( digest ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) digest, sizeof( digest ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) digest, sizeof( digest ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_SHA384 )
|
||||
@@ -78,7 +92,14 @@ HB_FUNC( HB_SHA384 )
|
||||
|
||||
sha384( ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
|
||||
hb_retclen( ( char * ) digest, HB_SIZEOFARRAY( digest ) );
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
char hex[ ( sizeof( digest ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) digest, sizeof( digest ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) digest, sizeof( digest ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_SHA512 )
|
||||
@@ -87,5 +108,12 @@ HB_FUNC( HB_SHA512 )
|
||||
|
||||
sha512( ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
|
||||
hb_retclen( ( char * ) digest, HB_SIZEOFARRAY( digest ) );
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
char hex[ ( sizeof( digest ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) digest, sizeof( digest ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) digest, sizeof( digest ) );
|
||||
}
|
||||
|
||||
@@ -60,7 +60,14 @@ HB_FUNC( HB_HMAC_SHA224 )
|
||||
|
||||
hmac_sha224( ( BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
|
||||
hb_retclen( ( char * ) mac, HB_SIZEOFARRAY( mac ) );
|
||||
if( ! hb_parl( 3 ) )
|
||||
{
|
||||
char hex[ ( sizeof( mac ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) mac, sizeof( mac ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) mac, sizeof( mac ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_HMAC_SHA256 )
|
||||
@@ -69,7 +76,14 @@ HB_FUNC( HB_HMAC_SHA256 )
|
||||
|
||||
hmac_sha256( ( BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
|
||||
hb_retclen( ( char * ) mac, HB_SIZEOFARRAY( mac ) );
|
||||
if( ! hb_parl( 3 ) )
|
||||
{
|
||||
char hex[ ( sizeof( mac ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) mac, sizeof( mac ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) mac, sizeof( mac ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_HMAC_SHA384 )
|
||||
@@ -78,7 +92,14 @@ HB_FUNC( HB_HMAC_SHA384 )
|
||||
|
||||
hmac_sha384( ( BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
|
||||
hb_retclen( ( char * ) mac, HB_SIZEOFARRAY( mac ) );
|
||||
if( ! hb_parl( 3 ) )
|
||||
{
|
||||
char hex[ ( sizeof( mac ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) mac, sizeof( mac ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) mac, sizeof( mac ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_HMAC_SHA512 )
|
||||
@@ -87,5 +108,12 @@ HB_FUNC( HB_HMAC_SHA512 )
|
||||
|
||||
hmac_sha512( ( BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
|
||||
hb_retclen( ( char * ) mac, HB_SIZEOFARRAY( mac ) );
|
||||
if( ! hb_parl( 3 ) )
|
||||
{
|
||||
char hex[ ( sizeof( mac ) * 2 ) + 1 ];
|
||||
hb_strtohex( ( char * ) mac, sizeof( mac ), hex );
|
||||
hb_retclen( hex, HB_SIZEOFARRAY( hex ) - 1 );
|
||||
}
|
||||
else
|
||||
hb_retclen( ( char * ) mac, sizeof( mac ) );
|
||||
}
|
||||
|
||||
22
harbour/contrib/hbcrypt/tests/testsha1.prg
Normal file
22
harbour/contrib/hbcrypt/tests/testsha1.prg
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
*
|
||||
* Rewritten from C: Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
*/
|
||||
|
||||
PROCEDURE Main()
|
||||
|
||||
? ">" + hb_sha1( "hello" ) + "<"
|
||||
? ">" + hb_sha1( "hello", .F. ) + "<"
|
||||
? ">" + hb_sha1( "hello", .T. ) + "<"
|
||||
|
||||
? ">" + hb_hmac_sha1( "hello", "key" ) + "<"
|
||||
? ">" + hb_hmac_sha1( "hello", "key", .F. ) + "<"
|
||||
? ">" + hb_hmac_sha1( "hello", "key", .T. ) + "<"
|
||||
|
||||
RETURN
|
||||
@@ -135,4 +135,4 @@ STATIC PROCEDURE Test_SHA2_HMAC()
|
||||
RETURN
|
||||
|
||||
STATIC FUNCTION StrToHex( cString )
|
||||
RETURN Lower( hb_StrToHex( cString ) )
|
||||
RETURN Lower( cString )
|
||||
|
||||
@@ -95,17 +95,17 @@ typedef struct _HB_CURL
|
||||
struct curl_slist * pPREQUOTE;
|
||||
struct curl_slist * pTELNETOPTIONS;
|
||||
|
||||
char * ul_name;
|
||||
char * ul_name;
|
||||
HB_FHANDLE ul_handle;
|
||||
|
||||
char * dl_name;
|
||||
char * dl_name;
|
||||
HB_FHANDLE dl_handle;
|
||||
|
||||
BYTE * ul_ptr;
|
||||
unsigned char * ul_ptr;
|
||||
size_t ul_len;
|
||||
size_t ul_pos;
|
||||
|
||||
BYTE * dl_ptr;
|
||||
unsigned char * dl_ptr;
|
||||
size_t dl_len;
|
||||
size_t dl_pos;
|
||||
|
||||
@@ -143,7 +143,7 @@ static HB_HASH_FUNC( hb_curl_HashKey ) /* ULONG func( const void * Value, con
|
||||
/* deletes a string */
|
||||
static HB_HASH_FUNC( hb_curl_HashDel )
|
||||
{
|
||||
hb_xfree( ( void * ) Value );
|
||||
hb_xfree( Value );
|
||||
HB_SYMBOL_UNUSED( HashPtr );
|
||||
HB_SYMBOL_UNUSED( Cargo );
|
||||
return 1;
|
||||
@@ -164,11 +164,11 @@ static const char * hb_curl_StrHashNew( PHB_CURL hb_curl, const char * szValue )
|
||||
hb_curl->pHash = hb_hashTableCreate( HB_CURL_HASH_TABLE_SIZE,
|
||||
hb_curl_HashKey, hb_curl_HashDel, hb_curl_HashCmp );
|
||||
|
||||
szHash = ( char * ) hb_hashTableFind( hb_curl->pHash, ( const void * ) szValue );
|
||||
szHash = ( char * ) hb_hashTableFind( hb_curl->pHash, szValue );
|
||||
if( ! szHash )
|
||||
{
|
||||
szHash = hb_strdup( szValue );
|
||||
hb_hashTableAdd( hb_curl->pHash, ( void * ) szHash, ( const void * ) szHash );
|
||||
hb_hashTableAdd( hb_curl->pHash, szHash, szHash );
|
||||
}
|
||||
return szHash;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ static size_t hb_curl_write_buff_callback( void * buffer, size_t size, size_t nm
|
||||
if( nTodo > nLeft )
|
||||
{
|
||||
hb_curl->dl_len += HB_CURL_DL_BUFF_SIZE_INCR;
|
||||
hb_curl->dl_ptr = ( BYTE * ) hb_xrealloc( hb_curl->dl_ptr, hb_curl->dl_len );
|
||||
hb_curl->dl_ptr = ( unsigned char * ) hb_xrealloc( hb_curl->dl_ptr, hb_curl->dl_len );
|
||||
}
|
||||
|
||||
hb_xmemcpy( hb_curl->dl_ptr + hb_curl->dl_pos, buffer, nTodo );
|
||||
@@ -343,7 +343,7 @@ static int hb_curl_progress_callback( void * Cargo, double dltotal, double dlnow
|
||||
PHB_ITEM p1 = hb_itemPutND( NULL, ulnow > 0 ? ulnow : dlnow );
|
||||
PHB_ITEM p2 = hb_itemPutND( NULL, ultotal > 0 ? ultotal : dltotal );
|
||||
|
||||
BOOL bResult = hb_itemGetL( hb_vmEvalBlockV( ( PHB_ITEM ) Cargo, 2, p1, p2 ) );
|
||||
hbBool bResult = hb_itemGetL( hb_vmEvalBlockV( ( PHB_ITEM ) Cargo, 2, p1, p2 ) );
|
||||
|
||||
hb_itemRelease( p1 );
|
||||
hb_itemRelease( p2 );
|
||||
@@ -431,7 +431,7 @@ static void hb_curl_buff_dl_free( PHB_CURL hb_curl )
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* Constructor/Destructor */
|
||||
|
||||
static void PHB_CURL_free( PHB_CURL hb_curl, BOOL bFree )
|
||||
static void PHB_CURL_free( PHB_CURL hb_curl, hbBool bFree )
|
||||
{
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, NULL );
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, NULL );
|
||||
@@ -496,7 +496,7 @@ static PHB_CURL PHB_CURL_create( CURL * from )
|
||||
{
|
||||
PHB_CURL hb_curl = ( PHB_CURL ) hb_xgrab( sizeof( HB_CURL ) );
|
||||
|
||||
memset( ( void * ) hb_curl, 0, sizeof( HB_CURL ) );
|
||||
memset( hb_curl, 0, sizeof( HB_CURL ) );
|
||||
hb_curl->curl = curl;
|
||||
|
||||
return hb_curl;
|
||||
@@ -513,7 +513,7 @@ static HB_GARBAGE_FUNC( PHB_CURL_release )
|
||||
if( ph && * ph )
|
||||
{
|
||||
/* Destroy the object */
|
||||
PHB_CURL_free( ( PHB_CURL ) * ph, TRUE );
|
||||
PHB_CURL_free( ( PHB_CURL ) * ph, hbTRUE );
|
||||
|
||||
/* set pointer to NULL to avoid multiple freeing */
|
||||
* ph = NULL;
|
||||
@@ -566,7 +566,7 @@ HB_FUNC( CURL_EASY_CLEANUP )
|
||||
if( ph && * ph )
|
||||
{
|
||||
/* Destroy the object */
|
||||
PHB_CURL_free( ( PHB_CURL ) * ph, TRUE );
|
||||
PHB_CURL_free( ( PHB_CURL ) * ph, hbTRUE );
|
||||
|
||||
/* set pointer to NULL to avoid multiple freeing */
|
||||
* ph = NULL;
|
||||
@@ -585,7 +585,7 @@ HB_FUNC( CURL_EASY_RESET )
|
||||
PHB_CURL hb_curl = PHB_CURL_par( 1 );
|
||||
|
||||
if( hb_curl )
|
||||
PHB_CURL_free( hb_curl, FALSE );
|
||||
PHB_CURL_free( hb_curl, hbFALSE );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
@@ -635,7 +635,7 @@ HB_FUNC( CURL_EASY_SEND )
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
res = curl_easy_send( hb_curl->curl, ( void * ) hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ), &size );
|
||||
res = curl_easy_send( hb_curl->curl, hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ), &size );
|
||||
|
||||
hb_stornl( size, 3 );
|
||||
}
|
||||
@@ -1367,7 +1367,7 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
hb_curl->pProgressBlock = hb_itemNew( pProgressBlock );
|
||||
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSFUNCTION, hb_curl_progress_callback );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSDATA, ( void * ) hb_curl->pProgressBlock );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSDATA, hb_curl->pProgressBlock );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1382,7 +1382,7 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
hb_curl->ul_handle = FS_ERROR;
|
||||
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_file_callback );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, ( void * ) hb_curl );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, hb_curl );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1402,7 +1402,7 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
hb_curl->dl_handle = FS_ERROR;
|
||||
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, hb_curl_write_file_callback );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, ( void * ) hb_curl );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, hb_curl );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1420,12 +1420,12 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
{
|
||||
hb_curl->ul_pos = 0;
|
||||
hb_curl->ul_len = hb_parclen( 3 );
|
||||
hb_curl->ul_ptr = ( BYTE * ) hb_xgrab( hb_curl->ul_len );
|
||||
hb_curl->ul_ptr = ( unsigned char * ) hb_xgrab( hb_curl->ul_len );
|
||||
|
||||
hb_xmemcpy( hb_curl->ul_ptr, hb_parc( 3 ), hb_curl->ul_len );
|
||||
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_buff_callback );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, ( void * ) hb_curl );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, hb_curl );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1436,10 +1436,10 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
|
||||
hb_curl->dl_pos = 0;
|
||||
hb_curl->dl_len = HB_ISNUM( 3 ) ? hb_parnl( 3 ) : HB_CURL_DL_BUFF_SIZE_INIT;
|
||||
hb_curl->dl_ptr = ( BYTE * ) hb_xgrab( hb_curl->dl_len );
|
||||
hb_curl->dl_ptr = ( unsigned char * ) hb_xgrab( hb_curl->dl_len );
|
||||
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, hb_curl_write_buff_callback );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, ( void * ) hb_curl );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, hb_curl );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1454,7 +1454,7 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
hb_curl_buff_ul_free( hb_curl );
|
||||
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_dummy_callback );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, ( void * ) hb_curl );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, hb_curl );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1683,7 +1683,7 @@ HB_FUNC( CURL_EASY_GETINFO )
|
||||
hb_retc( ret_string );
|
||||
break;
|
||||
case HB_CURL_INFO_TYPE_PTR:
|
||||
hb_retptr( ( void * ) ret_ptr );
|
||||
hb_retptr( ret_ptr );
|
||||
break;
|
||||
case HB_CURL_INFO_TYPE_LONG:
|
||||
hb_retnl( ret_long );
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbvm.h"
|
||||
|
||||
#include "hbssl.h"
|
||||
|
||||
@@ -60,12 +62,26 @@
|
||||
|
||||
int hb_ssl_pem_password_cb( char * buf, int size, int rwflag, void * userdata )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( buf );
|
||||
HB_SYMBOL_UNUSED( size );
|
||||
HB_SYMBOL_UNUSED( rwflag );
|
||||
HB_SYMBOL_UNUSED( userdata );
|
||||
int retsize = 0;
|
||||
|
||||
return 0;
|
||||
if( size > 0 && userdata )
|
||||
{
|
||||
PHB_ITEM p = hb_itemPutNI( NULL, rwflag );
|
||||
PHB_ITEM r = hb_vmEvalBlockV( ( PHB_ITEM ) userdata, 1, p );
|
||||
|
||||
buf[ 0 ] = '\0';
|
||||
|
||||
retsize = hb_itemGetCLen( r );
|
||||
|
||||
if( retsize > size )
|
||||
retsize = size;
|
||||
|
||||
memcpy( buf, hb_itemGetCPtr( r ), retsize );
|
||||
|
||||
hb_itemRelease( p );
|
||||
}
|
||||
|
||||
return retsize;
|
||||
}
|
||||
|
||||
HB_FUNC( ERR_LOAD_PEM_STRINGS )
|
||||
|
||||
@@ -947,6 +947,7 @@ extern HB_EXPORT char * hb_numToStr( char * szBuf, ULONG ulSize, HB_LONG lNum
|
||||
extern HB_EXPORT double hb_numRound( double dResult, int iDec ); /* round a number to a specific number of digits */
|
||||
extern HB_EXPORT double hb_numInt( double dNum ); /* take the integer part of the number */
|
||||
extern HB_EXPORT double hb_numDecConv( double dNum, int iDec );
|
||||
extern HB_EXPORT void hb_strtohex( const char * pSource, ULONG size, char * pDest );
|
||||
|
||||
extern HB_EXPORT PHB_ITEM hb_strFormat( PHB_ITEM pItemReturn, PHB_ITEM pItemFormat, int iCount, PHB_ITEM * pItemArray );
|
||||
|
||||
|
||||
@@ -1089,3 +1089,18 @@ char * hb_compDecodeString( int iMethod, const char * szText, ULONG * pulLen )
|
||||
}
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
/* 'pDest' must be double the size of 'size'. [vszakats] */
|
||||
void hb_strtohex( const char * pSource, ULONG size, char * pDest )
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for( i = 0; i < size; i++ )
|
||||
{
|
||||
int b;
|
||||
b = ( ( UCHAR ) pSource[ i ] >> 4 ) & 0x0F;
|
||||
*pDest++ = ( char ) ( b + ( b > 9 ? 'a' - 10 : '0' ) );
|
||||
b = ( UCHAR ) pSource[ i ] & 0x0F;
|
||||
*pDest++ = ( char ) ( b + ( b > 9 ? 'a' - 10 : '0' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,19 +261,6 @@ static void hb_md5val( UINT32 accum[], char * md5val )
|
||||
}
|
||||
}
|
||||
|
||||
static void hb_md5digest( const char * md5val, char * digest )
|
||||
{
|
||||
int i, b;
|
||||
|
||||
for( i = 0; i < 16; i++ )
|
||||
{
|
||||
b = ( ( UCHAR ) md5val[ i ] >> 4 ) & 0x0F;
|
||||
*digest++ = ( char ) ( b + ( b > 9 ? 'a' - 10 : '0' ) );
|
||||
b = ( UCHAR ) md5val[ i ] & 0x0F;
|
||||
*digest++ = ( char ) ( b + ( b > 9 ? 'a' - 10 : '0' ) );
|
||||
}
|
||||
}
|
||||
|
||||
void hb_md5( const void * data, ULONG ulLen, char * digest )
|
||||
{
|
||||
const unsigned char * ucdata = ( const unsigned char * ) data;
|
||||
@@ -382,10 +369,10 @@ HB_FUNC( HB_MD5 )
|
||||
|
||||
hb_md5( pszStr, ulLen, dststr );
|
||||
|
||||
if( ! ISLOG( 2 ) || hb_parl( 2 ) )
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
char digest[ 32 + 1 ];
|
||||
hb_md5digest( dststr, digest );
|
||||
char digest[ ( sizeof( dststr ) * 2 ) + 1 ];
|
||||
hb_strtohex( dststr, sizeof( dststr ), digest );
|
||||
hb_retclen( digest, HB_SIZEOFARRAY( digest ) - 1 );
|
||||
}
|
||||
else
|
||||
@@ -409,10 +396,10 @@ HB_FUNC( HB_MD5FILE )
|
||||
|
||||
hb_md5file( hFile, dststr );
|
||||
|
||||
if( ! ISLOG( 2 ) || hb_parl( 2 ) )
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
char digest[ 32 + 1 ];
|
||||
hb_md5digest( dststr, digest );
|
||||
char digest[ ( sizeof( dststr ) * 2 ) + 1 ];
|
||||
hb_strtohex( dststr, sizeof( dststr ), digest );
|
||||
hb_retclen( digest, HB_SIZEOFARRAY( digest ) - 1 );
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user