diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8291c66096..c66320f48a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -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 diff --git a/harbour/src/rtl/hbsha1.c b/harbour/src/rtl/hbsha1.c index 20e15fdb9c..e6a1799084 100644 --- a/harbour/src/rtl/hbsha1.c +++ b/harbour/src/rtl/hbsha1.c @@ -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 ) ) diff --git a/harbour/src/rtl/hbsha1hm.c b/harbour/src/rtl/hbsha1hm.c index 8b66a62a17..84e9666923 100644 --- a/harbour/src/rtl/hbsha1hm.c +++ b/harbour/src/rtl/hbsha1hm.c @@ -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 );