From ea283827e08fac758b2adf4d7376daa7dded6185 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 5 Feb 2010 03:51:42 +0000 Subject: [PATCH] 2010-02-05 04:50 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/sha1.c * src/rtl/sha1.h * src/rtl/hbsha1hm.c * src/rtl/sha2.c * src/rtl/sha2.h * src/rtl/hbsha2hm.c * src/rtl/sha1hmac.c * src/rtl/sha1hmac.h * src/rtl/hbsha1.c * src/rtl/sha2hmac.c * src/rtl/sha2hmac.h * src/rtl/hbsha2.c + Not using HB_BYTE type anymore. + Using 'const void*' type for key/data variables in public functions. % Deleted unnecessary casting. --- harbour/ChangeLog | 17 +++++++++++++++++ harbour/src/rtl/hbsha1.c | 2 +- harbour/src/rtl/hbsha1hm.c | 4 ++-- harbour/src/rtl/hbsha2.c | 16 ++++++++-------- harbour/src/rtl/hbsha2hm.c | 16 ++++++++-------- harbour/src/rtl/sha1.c | 3 ++- harbour/src/rtl/sha1.h | 2 +- harbour/src/rtl/sha1hmac.c | 4 ++-- harbour/src/rtl/sha1hmac.h | 4 ++-- harbour/src/rtl/sha2.c | 20 ++++++++++++-------- harbour/src/rtl/sha2.h | 16 ++++++++-------- harbour/src/rtl/sha2hmac.c | 36 ++++++++++++++++++++---------------- harbour/src/rtl/sha2hmac.h | 32 ++++++++++++++++---------------- 13 files changed, 99 insertions(+), 73 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 140257f38b..4020d2b310 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,23 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-05 04:50 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/sha1.c + * src/rtl/sha1.h + * src/rtl/hbsha1hm.c + * src/rtl/sha2.c + * src/rtl/sha2.h + * src/rtl/hbsha2hm.c + * src/rtl/sha1hmac.c + * src/rtl/sha1hmac.h + * src/rtl/hbsha1.c + * src/rtl/sha2hmac.c + * src/rtl/sha2hmac.h + * src/rtl/hbsha2.c + + Not using HB_BYTE type anymore. + + Using 'const void*' type for key/data variables in public functions. + % Deleted unnecessary casting. + 2010-02-05 04:27 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/sha1.c * src/rtl/sha1.h diff --git a/harbour/src/rtl/hbsha1.c b/harbour/src/rtl/hbsha1.c index 229499dd1a..ed344e2fa2 100644 --- a/harbour/src/rtl/hbsha1.c +++ b/harbour/src/rtl/hbsha1.c @@ -60,7 +60,7 @@ HB_FUNC( HB_SHA1 ) SHA_CTX ctx; SHA1_Init( &ctx ); - SHA1_Update( &ctx, ( const sha1_byte * ) hb_parcx( 1 ), hb_parclen( 1 ) ); + SHA1_Update( &ctx, hb_parcx( 1 ), hb_parclen( 1 ) ); SHA1_Final( digest, &ctx ); if( ! hb_parl( 2 ) ) diff --git a/harbour/src/rtl/hbsha1hm.c b/harbour/src/rtl/hbsha1hm.c index 666d967c99..3ef211d924 100644 --- a/harbour/src/rtl/hbsha1hm.c +++ b/harbour/src/rtl/hbsha1hm.c @@ -60,10 +60,10 @@ HB_FUNC( HB_HMAC_SHA1 ) HMAC_SHA1_CTX ctx; HMAC_SHA1_Init( &ctx ); - HMAC_SHA1_UpdateKey( &ctx, ( const unsigned char * ) hb_parcx( 2 ), hb_parclen( 2 ) ); + HMAC_SHA1_UpdateKey( &ctx, hb_parcx( 2 ), hb_parclen( 2 ) ); HMAC_SHA1_EndKey( &ctx ); HMAC_SHA1_StartMessage( &ctx ); - HMAC_SHA1_UpdateMessage( &ctx, ( const unsigned char * ) hb_parcx( 1 ), hb_parclen( 1 ) ); + HMAC_SHA1_UpdateMessage( &ctx, hb_parcx( 1 ), hb_parclen( 1 ) ); HMAC_SHA1_EndMessage( mac, &ctx ); HMAC_SHA1_Done( &ctx ); diff --git a/harbour/src/rtl/hbsha2.c b/harbour/src/rtl/hbsha2.c index 5bd8e07108..5d5b53299d 100644 --- a/harbour/src/rtl/hbsha2.c +++ b/harbour/src/rtl/hbsha2.c @@ -56,9 +56,9 @@ HB_FUNC( HB_SHA224 ) { - HB_BYTE digest[ SHA224_DIGEST_SIZE ]; + unsigned char digest[ SHA224_DIGEST_SIZE ]; - sha224( ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest ); + sha224( hb_parcx( 1 ), hb_parclen( 1 ), digest ); if( ! hb_parl( 2 ) ) { @@ -72,9 +72,9 @@ HB_FUNC( HB_SHA224 ) HB_FUNC( HB_SHA256 ) { - HB_BYTE digest[ SHA256_DIGEST_SIZE ]; + unsigned char digest[ SHA256_DIGEST_SIZE ]; - sha256( ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest ); + sha256( hb_parcx( 1 ), hb_parclen( 1 ), digest ); if( ! hb_parl( 2 ) ) { @@ -88,9 +88,9 @@ HB_FUNC( HB_SHA256 ) HB_FUNC( HB_SHA384 ) { - HB_BYTE digest[ SHA384_DIGEST_SIZE ]; + unsigned char digest[ SHA384_DIGEST_SIZE ]; - sha384( ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest ); + sha384( hb_parcx( 1 ), hb_parclen( 1 ), digest ); if( ! hb_parl( 2 ) ) { @@ -104,9 +104,9 @@ HB_FUNC( HB_SHA384 ) HB_FUNC( HB_SHA512 ) { - HB_BYTE digest[ SHA512_DIGEST_SIZE ]; + unsigned char digest[ SHA512_DIGEST_SIZE ]; - sha512( ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest ); + sha512( hb_parcx( 1 ), hb_parclen( 1 ), digest ); if( ! hb_parl( 2 ) ) { diff --git a/harbour/src/rtl/hbsha2hm.c b/harbour/src/rtl/hbsha2hm.c index 0ac7c11e84..8e0d8952e3 100644 --- a/harbour/src/rtl/hbsha2hm.c +++ b/harbour/src/rtl/hbsha2hm.c @@ -56,9 +56,9 @@ HB_FUNC( HB_HMAC_SHA224 ) { - HB_BYTE mac[ SHA224_DIGEST_SIZE ]; + unsigned char mac[ SHA224_DIGEST_SIZE ]; - hmac_sha224( ( const HB_BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) ); + hmac_sha224( hb_parcx( 2 ), hb_parclen( 2 ), hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) ); if( ! hb_parl( 3 ) ) { @@ -72,9 +72,9 @@ HB_FUNC( HB_HMAC_SHA224 ) HB_FUNC( HB_HMAC_SHA256 ) { - HB_BYTE mac[ SHA256_DIGEST_SIZE ]; + unsigned char mac[ SHA256_DIGEST_SIZE ]; - hmac_sha256( ( const HB_BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) ); + hmac_sha256( hb_parcx( 2 ), hb_parclen( 2 ), hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) ); if( ! hb_parl( 3 ) ) { @@ -88,9 +88,9 @@ HB_FUNC( HB_HMAC_SHA256 ) HB_FUNC( HB_HMAC_SHA384 ) { - HB_BYTE mac[ SHA384_DIGEST_SIZE ]; + unsigned char mac[ SHA384_DIGEST_SIZE ]; - hmac_sha384( ( const HB_BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) ); + hmac_sha384( hb_parcx( 2 ), hb_parclen( 2 ), hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) ); if( ! hb_parl( 3 ) ) { @@ -104,9 +104,9 @@ HB_FUNC( HB_HMAC_SHA384 ) HB_FUNC( HB_HMAC_SHA512 ) { - HB_BYTE mac[ SHA512_DIGEST_SIZE ]; + unsigned char mac[ SHA512_DIGEST_SIZE ]; - hmac_sha512( ( const HB_BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) ); + hmac_sha512( hb_parcx( 2 ), hb_parclen( 2 ), hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) ); if( ! hb_parl( 3 ) ) { diff --git a/harbour/src/rtl/sha1.c b/harbour/src/rtl/sha1.c index d7ebc868b2..c8578741b1 100644 --- a/harbour/src/rtl/sha1.c +++ b/harbour/src/rtl/sha1.c @@ -122,7 +122,8 @@ void SHA1_Init(SHA_CTX* context) { } /* Run your data through this. */ -void SHA1_Update(SHA_CTX *context, const sha1_byte *data, unsigned int len) { +void SHA1_Update(SHA_CTX *context, const void *datav, unsigned int len) { + const sha1_byte * data = ( const sha1_byte * ) datav; unsigned int i, j; j = (context->count[0] >> 3) & 63; diff --git a/harbour/src/rtl/sha1.h b/harbour/src/rtl/sha1.h index 977ebf1a9d..ef9ea17c0c 100644 --- a/harbour/src/rtl/sha1.h +++ b/harbour/src/rtl/sha1.h @@ -67,7 +67,7 @@ typedef struct _SHA_CTX { #ifndef NOPROTO void SHA1_Init(SHA_CTX *context); -void SHA1_Update(SHA_CTX *context, const sha1_byte *data, unsigned int len); +void SHA1_Update(SHA_CTX *context, const void *data, unsigned int len); void SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH], SHA_CTX* context); #else void SHA1_Init(); diff --git a/harbour/src/rtl/sha1hmac.c b/harbour/src/rtl/sha1hmac.c index 7056737228..95c2ac0dab 100644 --- a/harbour/src/rtl/sha1hmac.c +++ b/harbour/src/rtl/sha1hmac.c @@ -80,7 +80,7 @@ void HMAC_SHA1_Init(HMAC_SHA1_CTX *ctx) { ctx->hashkey = 0; } -void HMAC_SHA1_UpdateKey(HMAC_SHA1_CTX *ctx, const unsigned char *key, unsigned int keylen) { +void HMAC_SHA1_UpdateKey(HMAC_SHA1_CTX *ctx, const void *key, unsigned int keylen) { /* Do we have anything to work with? If not, return right away. */ if (keylen < 1) @@ -167,7 +167,7 @@ void HMAC_SHA1_StartMessage(HMAC_SHA1_CTX *ctx) { SHA1_Update(&ctx->shactx, &(ctx->ipad[0]), HMAC_SHA1_BLOCK_LENGTH); } -void HMAC_SHA1_UpdateMessage(HMAC_SHA1_CTX *ctx, const unsigned char *data, unsigned int datalen) { +void HMAC_SHA1_UpdateMessage(HMAC_SHA1_CTX *ctx, const void *data, unsigned int datalen) { SHA1_Update(&ctx->shactx, data, datalen); } diff --git a/harbour/src/rtl/sha1hmac.h b/harbour/src/rtl/sha1hmac.h index 277ebe0553..7639374b4a 100644 --- a/harbour/src/rtl/sha1hmac.h +++ b/harbour/src/rtl/sha1hmac.h @@ -73,10 +73,10 @@ typedef struct _HMAC_SHA1_CTX { #ifndef NOPROTO void HMAC_SHA1_Init(HMAC_SHA1_CTX *ctx); -void HMAC_SHA1_UpdateKey(HMAC_SHA1_CTX *ctx, const unsigned char *key, unsigned int keylen); +void HMAC_SHA1_UpdateKey(HMAC_SHA1_CTX *ctx, const void *key, unsigned int keylen); void HMAC_SHA1_EndKey(HMAC_SHA1_CTX *ctx); void HMAC_SHA1_StartMessage(HMAC_SHA1_CTX *ctx); -void HMAC_SHA1_UpdateMessage(HMAC_SHA1_CTX *ctx, const unsigned char *data, unsigned int datalen); +void HMAC_SHA1_UpdateMessage(HMAC_SHA1_CTX *ctx, const void *data, unsigned int datalen); void HMAC_SHA1_EndMessage(unsigned char *out, HMAC_SHA1_CTX *ctx); void HMAC_SHA1_Done(HMAC_SHA1_CTX *ctx); #else diff --git a/harbour/src/rtl/sha2.c b/harbour/src/rtl/sha2.c index 7d2b401c26..d70754b975 100644 --- a/harbour/src/rtl/sha2.c +++ b/harbour/src/rtl/sha2.c @@ -340,7 +340,7 @@ void sha256_transf(sha256_ctx *ctx, const unsigned char *message, } } -void sha256(const unsigned char *message, unsigned int len, unsigned char *digest) +void sha256(const void *message, unsigned int len, unsigned char *digest) { sha256_ctx ctx; @@ -367,9 +367,10 @@ void sha256_init(sha256_ctx *ctx) ctx->tot_len = 0; } -void sha256_update(sha256_ctx *ctx, const unsigned char *message, +void sha256_update(sha256_ctx *ctx, const void *messagev, unsigned int len) { + const unsigned char * message = ( const unsigned char * ) messagev; unsigned int block_nb; unsigned int new_len, rem_len, tmp_len; const unsigned char *shifted_message; @@ -536,7 +537,7 @@ void sha512_transf(sha512_ctx *ctx, const unsigned char *message, } } -void sha512(const unsigned char *message, unsigned int len, +void sha512(const void *message, unsigned int len, unsigned char *digest) { sha512_ctx ctx; @@ -564,9 +565,10 @@ void sha512_init(sha512_ctx *ctx) ctx->tot_len = 0; } -void sha512_update(sha512_ctx *ctx, const unsigned char *message, +void sha512_update(sha512_ctx *ctx, const void *messagev, unsigned int len) { + const unsigned char * message = ( const unsigned char * ) messagev; unsigned int block_nb; unsigned int new_len, rem_len, tmp_len; const unsigned char *shifted_message; @@ -638,7 +640,7 @@ void sha512_final(sha512_ctx *ctx, unsigned char *digest) /* SHA-384 functions */ -void sha384(const unsigned char *message, unsigned int len, +void sha384(const void *message, unsigned int len, unsigned char *digest) { sha384_ctx ctx; @@ -666,9 +668,10 @@ void sha384_init(sha384_ctx *ctx) ctx->tot_len = 0; } -void sha384_update(sha384_ctx *ctx, const unsigned char *message, +void sha384_update(sha384_ctx *ctx, const void *messagev, unsigned int len) { + const unsigned char * message = ( const unsigned char * ) messagev; unsigned int block_nb; unsigned int new_len, rem_len, tmp_len; const unsigned char *shifted_message; @@ -738,7 +741,7 @@ void sha384_final(sha384_ctx *ctx, unsigned char *digest) /* SHA-224 functions */ -void sha224(const unsigned char *message, unsigned int len, +void sha224(const void *message, unsigned int len, unsigned char *digest) { sha224_ctx ctx; @@ -766,9 +769,10 @@ void sha224_init(sha224_ctx *ctx) ctx->tot_len = 0; } -void sha224_update(sha224_ctx *ctx, const unsigned char *message, +void sha224_update(sha224_ctx *ctx, const void *messagev, unsigned int len) { + const unsigned char * message = ( const unsigned char * ) messagev; unsigned int block_nb; unsigned int new_len, rem_len, tmp_len; const unsigned char *shifted_message; diff --git a/harbour/src/rtl/sha2.h b/harbour/src/rtl/sha2.h index cb158b382d..846232d85e 100644 --- a/harbour/src/rtl/sha2.h +++ b/harbour/src/rtl/sha2.h @@ -81,31 +81,31 @@ typedef sha512_ctx sha384_ctx; typedef sha256_ctx sha224_ctx; void sha224_init(sha224_ctx *ctx); -void sha224_update(sha224_ctx *ctx, const unsigned char *message, +void sha224_update(sha224_ctx *ctx, const void *message, unsigned int len); void sha224_final(sha224_ctx *ctx, unsigned char *digest); -void sha224(const unsigned char *message, unsigned int len, +void sha224(const void *message, unsigned int len, unsigned char *digest); void sha256_init(sha256_ctx * ctx); -void sha256_update(sha256_ctx *ctx, const unsigned char *message, +void sha256_update(sha256_ctx *ctx, const void *message, unsigned int len); void sha256_final(sha256_ctx *ctx, unsigned char *digest); -void sha256(const unsigned char *message, unsigned int len, +void sha256(const void *message, unsigned int len, unsigned char *digest); void sha384_init(sha384_ctx *ctx); -void sha384_update(sha384_ctx *ctx, const unsigned char *message, +void sha384_update(sha384_ctx *ctx, const void *message, unsigned int len); void sha384_final(sha384_ctx *ctx, unsigned char *digest); -void sha384(const unsigned char *message, unsigned int len, +void sha384(const void *message, unsigned int len, unsigned char *digest); void sha512_init(sha512_ctx *ctx); -void sha512_update(sha512_ctx *ctx, const unsigned char *message, +void sha512_update(sha512_ctx *ctx, const void *message, unsigned int len); void sha512_final(sha512_ctx *ctx, unsigned char *digest); -void sha512(const unsigned char *message, unsigned int len, +void sha512(const void *message, unsigned int len, unsigned char *digest); #ifdef __cplusplus diff --git a/harbour/src/rtl/sha2hmac.c b/harbour/src/rtl/sha2hmac.c index a233d6758a..88653be213 100644 --- a/harbour/src/rtl/sha2hmac.c +++ b/harbour/src/rtl/sha2hmac.c @@ -41,12 +41,13 @@ /* HMAC-SHA-224 functions */ -void hmac_sha224_init(hmac_sha224_ctx *ctx, const unsigned char *key, +void hmac_sha224_init(hmac_sha224_ctx *ctx, const void *keyv, unsigned int key_size) { unsigned int fill; unsigned int num; + const unsigned char *key = ( const unsigned char * ) keyv; unsigned char *key_used; unsigned char key_temp[SHA224_DIGEST_SIZE]; unsigned int i; @@ -96,7 +97,7 @@ void hmac_sha224_reinit(hmac_sha224_ctx *ctx) sizeof(sha224_ctx)); } -void hmac_sha224_update(hmac_sha224_ctx *ctx, const unsigned char *message, +void hmac_sha224_update(hmac_sha224_ctx *ctx, const void *message, unsigned int message_len) { sha224_update(&ctx->ctx_inside, message, message_len); @@ -114,8 +115,8 @@ void hmac_sha224_final(hmac_sha224_ctx *ctx, unsigned char *mac, memcpy(mac, mac_temp, mac_size); } -void hmac_sha224(const unsigned char *key, unsigned int key_size, - const unsigned char *message, unsigned int message_len, +void hmac_sha224(const void *key, unsigned int key_size, + const void *message, unsigned int message_len, unsigned char *mac, unsigned mac_size) { hmac_sha224_ctx ctx; @@ -127,12 +128,13 @@ void hmac_sha224(const unsigned char *key, unsigned int key_size, /* HMAC-SHA-256 functions */ -void hmac_sha256_init(hmac_sha256_ctx *ctx, const unsigned char *key, +void hmac_sha256_init(hmac_sha256_ctx *ctx, const void *keyv, unsigned int key_size) { unsigned int fill; unsigned int num; + const unsigned char *key = ( const unsigned char * ) keyv; unsigned char *key_used; unsigned char key_temp[SHA256_DIGEST_SIZE]; unsigned int i; @@ -182,7 +184,7 @@ void hmac_sha256_reinit(hmac_sha256_ctx *ctx) sizeof(sha256_ctx)); } -void hmac_sha256_update(hmac_sha256_ctx *ctx, const unsigned char *message, +void hmac_sha256_update(hmac_sha256_ctx *ctx, const void *message, unsigned int message_len) { sha256_update(&ctx->ctx_inside, message, message_len); @@ -200,8 +202,8 @@ void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac, memcpy(mac, mac_temp, mac_size); } -void hmac_sha256(const unsigned char *key, unsigned int key_size, - const unsigned char *message, unsigned int message_len, +void hmac_sha256(const void *key, unsigned int key_size, + const void *message, unsigned int message_len, unsigned char *mac, unsigned mac_size) { hmac_sha256_ctx ctx; @@ -213,12 +215,13 @@ void hmac_sha256(const unsigned char *key, unsigned int key_size, /* HMAC-SHA-384 functions */ -void hmac_sha384_init(hmac_sha384_ctx *ctx, const unsigned char *key, +void hmac_sha384_init(hmac_sha384_ctx *ctx, const void *keyv, unsigned int key_size) { unsigned int fill; unsigned int num; + const unsigned char *key = ( const unsigned char * ) keyv; unsigned char *key_used; unsigned char key_temp[SHA384_DIGEST_SIZE]; unsigned int i; @@ -268,7 +271,7 @@ void hmac_sha384_reinit(hmac_sha384_ctx *ctx) sizeof(sha384_ctx)); } -void hmac_sha384_update(hmac_sha384_ctx *ctx, const unsigned char *message, +void hmac_sha384_update(hmac_sha384_ctx *ctx, const void *message, unsigned int message_len) { sha384_update(&ctx->ctx_inside, message, message_len); @@ -286,8 +289,8 @@ void hmac_sha384_final(hmac_sha384_ctx *ctx, unsigned char *mac, memcpy(mac, mac_temp, mac_size); } -void hmac_sha384(const unsigned char *key, unsigned int key_size, - const unsigned char *message, unsigned int message_len, +void hmac_sha384(const void *key, unsigned int key_size, + const void *message, unsigned int message_len, unsigned char *mac, unsigned mac_size) { hmac_sha384_ctx ctx; @@ -299,12 +302,13 @@ void hmac_sha384(const unsigned char *key, unsigned int key_size, /* HMAC-SHA-512 functions */ -void hmac_sha512_init(hmac_sha512_ctx *ctx, const unsigned char *key, +void hmac_sha512_init(hmac_sha512_ctx *ctx, const void *keyv, unsigned int key_size) { unsigned int fill; unsigned int num; + const unsigned char *key = ( const unsigned char * ) keyv; unsigned char *key_used; unsigned char key_temp[SHA512_DIGEST_SIZE]; unsigned int i; @@ -354,7 +358,7 @@ void hmac_sha512_reinit(hmac_sha512_ctx *ctx) sizeof(sha512_ctx)); } -void hmac_sha512_update(hmac_sha512_ctx *ctx, const unsigned char *message, +void hmac_sha512_update(hmac_sha512_ctx *ctx, const void *message, unsigned int message_len) { sha512_update(&ctx->ctx_inside, message, message_len); @@ -372,8 +376,8 @@ void hmac_sha512_final(hmac_sha512_ctx *ctx, unsigned char *mac, memcpy(mac, mac_temp, mac_size); } -void hmac_sha512(const unsigned char *key, unsigned int key_size, - const unsigned char *message, unsigned int message_len, +void hmac_sha512(const void *key, unsigned int key_size, + const void *message, unsigned int message_len, unsigned char *mac, unsigned mac_size) { hmac_sha512_ctx ctx; diff --git a/harbour/src/rtl/sha2hmac.h b/harbour/src/rtl/sha2hmac.h index a3be3ae72b..cdb87b16c9 100644 --- a/harbour/src/rtl/sha2hmac.h +++ b/harbour/src/rtl/sha2hmac.h @@ -92,48 +92,48 @@ typedef struct { unsigned char block_opad[SHA512_BLOCK_SIZE]; } hmac_sha512_ctx; -void hmac_sha224_init(hmac_sha224_ctx *ctx, const unsigned char *key, +void hmac_sha224_init(hmac_sha224_ctx *ctx, const void *key, unsigned int key_size); void hmac_sha224_reinit(hmac_sha224_ctx *ctx); -void hmac_sha224_update(hmac_sha224_ctx *ctx, const unsigned char *message, +void hmac_sha224_update(hmac_sha224_ctx *ctx, const void *message, unsigned int message_len); void hmac_sha224_final(hmac_sha224_ctx *ctx, unsigned char *mac, unsigned int mac_size); -void hmac_sha224(const unsigned char *key, unsigned int key_size, - const unsigned char *message, unsigned int message_len, +void hmac_sha224(const void *key, unsigned int key_size, + const void *message, unsigned int message_len, unsigned char *mac, unsigned mac_size); -void hmac_sha256_init(hmac_sha256_ctx *ctx, const unsigned char *key, +void hmac_sha256_init(hmac_sha256_ctx *ctx, const void *key, unsigned int key_size); void hmac_sha256_reinit(hmac_sha256_ctx *ctx); -void hmac_sha256_update(hmac_sha256_ctx *ctx, const unsigned char *message, +void hmac_sha256_update(hmac_sha256_ctx *ctx, const void *message, unsigned int message_len); void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac, unsigned int mac_size); -void hmac_sha256(const unsigned char *key, unsigned int key_size, - const unsigned char *message, unsigned int message_len, +void hmac_sha256(const void *key, unsigned int key_size, + const void *message, unsigned int message_len, unsigned char *mac, unsigned mac_size); -void hmac_sha384_init(hmac_sha384_ctx *ctx, const unsigned char *key, +void hmac_sha384_init(hmac_sha384_ctx *ctx, const void *key, unsigned int key_size); void hmac_sha384_reinit(hmac_sha384_ctx *ctx); -void hmac_sha384_update(hmac_sha384_ctx *ctx, const unsigned char *message, +void hmac_sha384_update(hmac_sha384_ctx *ctx, const void *message, unsigned int message_len); void hmac_sha384_final(hmac_sha384_ctx *ctx, unsigned char *mac, unsigned int mac_size); -void hmac_sha384(const unsigned char *key, unsigned int key_size, - const unsigned char *message, unsigned int message_len, +void hmac_sha384(const void *key, unsigned int key_size, + const void *message, unsigned int message_len, unsigned char *mac, unsigned mac_size); -void hmac_sha512_init(hmac_sha512_ctx *ctx, const unsigned char *key, +void hmac_sha512_init(hmac_sha512_ctx *ctx, const void *key, unsigned int key_size); void hmac_sha512_reinit(hmac_sha512_ctx *ctx); -void hmac_sha512_update(hmac_sha512_ctx *ctx, const unsigned char *message, +void hmac_sha512_update(hmac_sha512_ctx *ctx, const void *message, unsigned int message_len); void hmac_sha512_final(hmac_sha512_ctx *ctx, unsigned char *mac, unsigned int mac_size); -void hmac_sha512(const unsigned char *key, unsigned int key_size, - const unsigned char *message, unsigned int message_len, +void hmac_sha512(const void *key, unsigned int key_size, + const void *message, unsigned int message_len, unsigned char *mac, unsigned mac_size); #ifdef __cplusplus