2010-06-22 17:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/hbsha1.c
* src/rtl/hbsha1hm.c
+ Added Win64 support for SHA1 functions.
; Please review it.
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2010-06-22 17:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* src/rtl/hbsha1.c
|
||||
* src/rtl/hbsha1hm.c
|
||||
+ Added Win64 support for SHA1 functions.
|
||||
; Please review it.
|
||||
|
||||
2010-06-22 17:00 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* src/macro/macro.yyc
|
||||
* src/macro/macro.y
|
||||
|
||||
@@ -60,7 +60,37 @@ HB_FUNC( HB_SHA1 )
|
||||
SHA_CTX ctx;
|
||||
|
||||
SHA1_Init( &ctx );
|
||||
SHA1_Update( &ctx, hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
|
||||
#if HB_SIZE_MAX > UINT_MAX
|
||||
{
|
||||
const char * buffer = hb_parcx( 1 );
|
||||
HB_SIZE nCount = hb_parclen( 1 );
|
||||
HB_SIZE nDone = 0;
|
||||
|
||||
while( nCount )
|
||||
{
|
||||
unsigned int uiChunk;
|
||||
|
||||
if( nCount > ( HB_SIZE ) UINT_MAX )
|
||||
{
|
||||
uiChunk = UINT_MAX;
|
||||
nCount -= ( HB_SIZE ) uiChunk;
|
||||
}
|
||||
else
|
||||
{
|
||||
uiChunk = ( unsigned int ) nCount;
|
||||
nCount = 0;
|
||||
}
|
||||
|
||||
SHA1_Update( &ctx, buffer + nDone, uiChunk );
|
||||
|
||||
nDone += ( HB_SIZE ) uiChunk;
|
||||
}
|
||||
}
|
||||
#else
|
||||
SHA1_Update( &ctx, hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
#endif
|
||||
|
||||
SHA1_Final( digest, &ctx );
|
||||
|
||||
if( ! hb_parl( 2 ) )
|
||||
|
||||
@@ -60,10 +60,67 @@ HB_FUNC( HB_HMAC_SHA1 )
|
||||
HMAC_SHA1_CTX ctx;
|
||||
|
||||
HMAC_SHA1_Init( &ctx );
|
||||
HMAC_SHA1_UpdateKey( &ctx, hb_parcx( 2 ), hb_parclen( 2 ) );
|
||||
#if HB_SIZE_MAX > UINT_MAX
|
||||
{
|
||||
const char * buffer = hb_parcx( 2 );
|
||||
HB_SIZE nCount = hb_parclen( 2 );
|
||||
HB_SIZE nDone = 0;
|
||||
|
||||
while( nCount )
|
||||
{
|
||||
unsigned int uiChunk;
|
||||
|
||||
if( nCount > ( HB_SIZE ) UINT_MAX )
|
||||
{
|
||||
uiChunk = UINT_MAX;
|
||||
nCount -= ( HB_SIZE ) uiChunk;
|
||||
}
|
||||
else
|
||||
{
|
||||
uiChunk = ( unsigned int ) nCount;
|
||||
nCount = 0;
|
||||
}
|
||||
|
||||
HMAC_SHA1_UpdateKey( &ctx, buffer + nDone, uiChunk );
|
||||
|
||||
nDone += ( HB_SIZE ) uiChunk;
|
||||
}
|
||||
}
|
||||
#else
|
||||
HMAC_SHA1_UpdateKey( &ctx, hb_parcx( 2 ), hb_parclen( 2 ) );
|
||||
#endif
|
||||
HMAC_SHA1_EndKey( &ctx );
|
||||
|
||||
HMAC_SHA1_StartMessage( &ctx );
|
||||
HMAC_SHA1_UpdateMessage( &ctx, hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
#if HB_SIZE_MAX > UINT_MAX
|
||||
{
|
||||
const char * buffer = hb_parcx( 1 );
|
||||
HB_SIZE nCount = hb_parclen( 1 );
|
||||
HB_SIZE nDone = 0;
|
||||
|
||||
while( nCount )
|
||||
{
|
||||
unsigned int uiChunk;
|
||||
|
||||
if( nCount > ( HB_SIZE ) UINT_MAX )
|
||||
{
|
||||
uiChunk = UINT_MAX;
|
||||
nCount -= ( HB_SIZE ) uiChunk;
|
||||
}
|
||||
else
|
||||
{
|
||||
uiChunk = ( unsigned int ) nCount;
|
||||
nCount = 0;
|
||||
}
|
||||
|
||||
HMAC_SHA1_UpdateMessage( &ctx, buffer + nDone, uiChunk );
|
||||
|
||||
nDone += ( HB_SIZE ) uiChunk;
|
||||
}
|
||||
}
|
||||
#else
|
||||
HMAC_SHA1_UpdateMessage( &ctx, hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
#endif
|
||||
HMAC_SHA1_EndMessage( mac, &ctx );
|
||||
HMAC_SHA1_Done( &ctx );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user