2010-02-05 04:27 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/sha1.c
* src/rtl/sha1.h
* src/rtl/hbsha1hm.c
* src/rtl/hbmd5.c
* 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
* BYTE -> HB_BYTE
* UINT32 -> HB_U32
+ Added 'const' keyword to low-level SHA2 related functions
where it was missing.
% Added static to SHA1_Transform().
* include/hbgtcore.h
* Formatting.
This commit is contained in:
@@ -17,6 +17,27 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-02-05 04:27 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* src/rtl/sha1.c
|
||||
* src/rtl/sha1.h
|
||||
* src/rtl/hbsha1hm.c
|
||||
* src/rtl/hbmd5.c
|
||||
* 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
|
||||
* BYTE -> HB_BYTE
|
||||
* UINT32 -> HB_U32
|
||||
+ Added 'const' keyword to low-level SHA2 related functions
|
||||
where it was missing.
|
||||
% Added static to SHA1_Transform().
|
||||
|
||||
* include/hbgtcore.h
|
||||
* Formatting.
|
||||
|
||||
2010-02-05 03:06 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/src/rtl/filesys.c
|
||||
* updated HB_FS_[SG]ETDRIVE() macros to operate on 'int' type
|
||||
@@ -44,7 +65,7 @@
|
||||
* Pacified warnings.
|
||||
|
||||
* contrib/hbwin/Makefile
|
||||
+ contrib/hbwin/wapi_wingdi_fontmem.c
|
||||
+ contrib/hbwin/wapi_wingdi_font.c
|
||||
+ Added WAPI_ADDFONTRESOURCEEX().
|
||||
+ Added WAPI_REMOVEFONTRESOURCEEX().
|
||||
|
||||
@@ -66,9 +87,9 @@
|
||||
* src/rtl/shadow.c
|
||||
! Fixed three remaining places where color value was cast to BYTE type.
|
||||
; QUESTION1: What to do with BYTE in hb_fs*Drv() calls?
|
||||
Should it be int or unsigned int?
|
||||
Should it be int or unsigned int? [DONE: int]
|
||||
; QUESTION2: What to do with BYTE types in checksum calculations and
|
||||
low level color storage, is HB_U8 type good?
|
||||
low level color storage, is HB_U8 type good? [DONE: HB_BYTE]
|
||||
|
||||
* src/rtl/transfrm.c
|
||||
* src/rtl/memofile.c
|
||||
|
||||
@@ -335,7 +335,7 @@ typedef struct _HB_GT_BASE
|
||||
PHB_ITEM pNotifierBlock;
|
||||
PHB_ITEM pCargo;
|
||||
|
||||
void * pGTData[HB_GT_MAX_]; /* local GT data */
|
||||
void * pGTData[ HB_GT_MAX_ ]; /* local GT data */
|
||||
|
||||
} HB_GT_BASE, * PHB_GT_BASE, * PHB_GT;
|
||||
|
||||
|
||||
@@ -101,8 +101,8 @@ C functions:
|
||||
/* MD5 buffer */
|
||||
typedef struct
|
||||
{
|
||||
UINT32 accum[ 4 ];
|
||||
BYTE buf[ 64 ];
|
||||
HB_U32 accum[ 4 ];
|
||||
HB_BYTE buf[ 64 ];
|
||||
} MD5_BUF;
|
||||
|
||||
/*
|
||||
@@ -129,7 +129,7 @@ typedef struct
|
||||
#define MAX_FBUF 0x20000 /* file read buffer size, MUST be 64*n */
|
||||
|
||||
/* Static data */
|
||||
static const UINT32 T[ 64 ] = {
|
||||
static const HB_U32 T[ 64 ] = {
|
||||
0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE,
|
||||
0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501,
|
||||
0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE,
|
||||
@@ -150,8 +150,8 @@ static const UINT32 T[ 64 ] = {
|
||||
|
||||
static void hb_md5go( MD5_BUF * md5 )
|
||||
{
|
||||
UINT32 X[ 16 ], A[ 4 ];
|
||||
BYTE * ptr;
|
||||
HB_U32 X[ 16 ], A[ 4 ];
|
||||
HB_BYTE * ptr;
|
||||
int i;
|
||||
|
||||
/* copy accumulators first */
|
||||
@@ -234,7 +234,7 @@ static void hb_md5go( MD5_BUF * md5 )
|
||||
md5->accum[ 3 ] += A[ 3 ];
|
||||
}
|
||||
|
||||
static void hb_md5accinit( UINT32 accum[] )
|
||||
static void hb_md5accinit( HB_U32 accum[] )
|
||||
{
|
||||
/* fill initial accumulator state */
|
||||
accum[ 0 ] = 0x67452301;
|
||||
@@ -243,7 +243,7 @@ static void hb_md5accinit( UINT32 accum[] )
|
||||
accum[ 3 ] = 0x10325476;
|
||||
}
|
||||
|
||||
static void hb_md5val( UINT32 accum[], char * md5val )
|
||||
static void hb_md5val( HB_U32 accum[], char * md5val )
|
||||
{
|
||||
int i, n;
|
||||
|
||||
@@ -257,7 +257,7 @@ static void hb_md5val( UINT32 accum[], char * md5val )
|
||||
void hb_md5( const void * data, HB_SIZE ulLen, char * digest )
|
||||
{
|
||||
const unsigned char * ucdata = ( const unsigned char * ) data;
|
||||
UCHAR buf[ 128 ];
|
||||
HB_UCHAR buf[ 128 ];
|
||||
MD5_BUF md5;
|
||||
int i, n;
|
||||
|
||||
@@ -285,11 +285,11 @@ void hb_md5( const void * data, HB_SIZE ulLen, char * digest )
|
||||
memcpy( md5.buf, buf, 64 );
|
||||
hb_md5go( &md5 );
|
||||
}
|
||||
buf[ i++ ] = ( UCHAR ) ( ( ulLen << 3 ) & 0xF8 );
|
||||
buf[ i++ ] = ( HB_UCHAR ) ( ( ulLen << 3 ) & 0xF8 );
|
||||
ulLen >>= 5;
|
||||
for( n = 7; n; --n )
|
||||
{
|
||||
buf[ i++ ] = ( UCHAR ) ( ulLen & 0xFF );
|
||||
buf[ i++ ] = ( HB_UCHAR ) ( ulLen & 0xFF );
|
||||
ulLen >>= 8;
|
||||
}
|
||||
memcpy( md5.buf, buf + i - 64, 64 );
|
||||
@@ -304,8 +304,8 @@ void hb_md5file( HB_FHANDLE hFile, char * digest )
|
||||
HB_SIZE n;
|
||||
int i;
|
||||
HB_FOFFSET flen = 0;
|
||||
UCHAR buf[ 128 ];
|
||||
BYTE * readbuf = ( BYTE * ) hb_xgrab( MAX_FBUF );
|
||||
HB_UCHAR buf[ 128 ];
|
||||
HB_BYTE * readbuf = ( HB_BYTE * ) hb_xgrab( MAX_FBUF );
|
||||
|
||||
hb_md5accinit( md5.accum );
|
||||
n = hb_fsReadLarge( hFile, readbuf, MAX_FBUF );
|
||||
@@ -340,11 +340,11 @@ void hb_md5file( HB_FHANDLE hFile, char * digest )
|
||||
memcpy( md5.buf, buf, 64 );
|
||||
hb_md5go( &md5 );
|
||||
}
|
||||
buf[ i++ ] = ( UCHAR ) ( ( flen << 3 ) & 0xF8 );
|
||||
buf[ i++ ] = ( HB_UCHAR ) ( ( flen << 3 ) & 0xF8 );
|
||||
flen >>= 5;
|
||||
for( n = 7; n; --n )
|
||||
{
|
||||
buf[ i++ ] = ( UCHAR ) ( flen & 0xFF );
|
||||
buf[ i++ ] = ( HB_UCHAR ) ( flen & 0xFF );
|
||||
flen >>= 8;
|
||||
}
|
||||
memcpy( md5.buf, buf + i - 64, 64 );
|
||||
|
||||
@@ -60,7 +60,7 @@ HB_FUNC( HB_SHA1 )
|
||||
SHA_CTX ctx;
|
||||
|
||||
SHA1_Init( &ctx );
|
||||
SHA1_Update( &ctx, ( sha1_byte * ) hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
SHA1_Update( &ctx, ( const sha1_byte * ) hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
SHA1_Final( digest, &ctx );
|
||||
|
||||
if( ! hb_parl( 2 ) )
|
||||
|
||||
@@ -60,10 +60,10 @@ HB_FUNC( HB_HMAC_SHA1 )
|
||||
HMAC_SHA1_CTX ctx;
|
||||
|
||||
HMAC_SHA1_Init( &ctx );
|
||||
HMAC_SHA1_UpdateKey( &ctx, ( unsigned char * ) hb_parcx( 2 ), hb_parclen( 2 ) );
|
||||
HMAC_SHA1_UpdateKey( &ctx, ( const 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_UpdateMessage( &ctx, ( const unsigned char * ) hb_parcx( 1 ), hb_parclen( 1 ) );
|
||||
HMAC_SHA1_EndMessage( mac, &ctx );
|
||||
HMAC_SHA1_Done( &ctx );
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@
|
||||
|
||||
HB_FUNC( HB_SHA224 )
|
||||
{
|
||||
BYTE digest[ SHA224_DIGEST_SIZE ];
|
||||
HB_BYTE digest[ SHA224_DIGEST_SIZE ];
|
||||
|
||||
sha224( ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
sha224( ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
@@ -72,9 +72,9 @@ HB_FUNC( HB_SHA224 )
|
||||
|
||||
HB_FUNC( HB_SHA256 )
|
||||
{
|
||||
BYTE digest[ SHA256_DIGEST_SIZE ];
|
||||
HB_BYTE digest[ SHA256_DIGEST_SIZE ];
|
||||
|
||||
sha256( ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
sha256( ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
@@ -88,9 +88,9 @@ HB_FUNC( HB_SHA256 )
|
||||
|
||||
HB_FUNC( HB_SHA384 )
|
||||
{
|
||||
BYTE digest[ SHA384_DIGEST_SIZE ];
|
||||
HB_BYTE digest[ SHA384_DIGEST_SIZE ];
|
||||
|
||||
sha384( ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
sha384( ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
@@ -104,9 +104,9 @@ HB_FUNC( HB_SHA384 )
|
||||
|
||||
HB_FUNC( HB_SHA512 )
|
||||
{
|
||||
BYTE digest[ SHA512_DIGEST_SIZE ];
|
||||
HB_BYTE digest[ SHA512_DIGEST_SIZE ];
|
||||
|
||||
sha512( ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
sha512( ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), digest );
|
||||
|
||||
if( ! hb_parl( 2 ) )
|
||||
{
|
||||
|
||||
@@ -56,9 +56,9 @@
|
||||
|
||||
HB_FUNC( HB_HMAC_SHA224 )
|
||||
{
|
||||
BYTE mac[ SHA224_DIGEST_SIZE ];
|
||||
HB_BYTE mac[ SHA224_DIGEST_SIZE ];
|
||||
|
||||
hmac_sha224( ( BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
hmac_sha224( ( const HB_BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( const HB_BYTE * ) 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 )
|
||||
{
|
||||
BYTE mac[ SHA256_DIGEST_SIZE ];
|
||||
HB_BYTE mac[ SHA256_DIGEST_SIZE ];
|
||||
|
||||
hmac_sha256( ( BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
hmac_sha256( ( const HB_BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( const HB_BYTE * ) 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 )
|
||||
{
|
||||
BYTE mac[ SHA384_DIGEST_SIZE ];
|
||||
HB_BYTE mac[ SHA384_DIGEST_SIZE ];
|
||||
|
||||
hmac_sha384( ( BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
hmac_sha384( ( const HB_BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( const HB_BYTE * ) 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 )
|
||||
{
|
||||
BYTE mac[ SHA512_DIGEST_SIZE ];
|
||||
HB_BYTE mac[ SHA512_DIGEST_SIZE ];
|
||||
|
||||
hmac_sha512( ( BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
hmac_sha512( ( const HB_BYTE * ) hb_parcx( 2 ), hb_parclen( 2 ), ( const HB_BYTE * ) hb_parcx( 1 ), hb_parclen( 1 ), mac, HB_SIZEOFARRAY( mac ) );
|
||||
|
||||
if( ! hb_parl( 3 ) )
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ typedef union _BYTE64QUAD16 {
|
||||
} BYTE64QUAD16;
|
||||
|
||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||
void SHA1_Transform(sha1_quadbyte state[5], sha1_byte buffer[64]) {
|
||||
static void SHA1_Transform(sha1_quadbyte state[5], const sha1_byte buffer[64]) {
|
||||
sha1_quadbyte a, b, c, d, e;
|
||||
BYTE64QUAD16 *block;
|
||||
|
||||
@@ -122,7 +122,7 @@ void SHA1_Init(SHA_CTX* context) {
|
||||
}
|
||||
|
||||
/* Run your data through this. */
|
||||
void SHA1_Update(SHA_CTX *context, sha1_byte *data, unsigned int len) {
|
||||
void SHA1_Update(SHA_CTX *context, const sha1_byte *data, unsigned int len) {
|
||||
unsigned int i, j;
|
||||
|
||||
j = (context->count[0] >> 3) & 63;
|
||||
|
||||
@@ -67,7 +67,7 @@ typedef struct _SHA_CTX {
|
||||
|
||||
#ifndef NOPROTO
|
||||
void SHA1_Init(SHA_CTX *context);
|
||||
void SHA1_Update(SHA_CTX *context, sha1_byte *data, unsigned int len);
|
||||
void SHA1_Update(SHA_CTX *context, const sha1_byte *data, unsigned int len);
|
||||
void SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH], SHA_CTX* context);
|
||||
#else
|
||||
void SHA1_Init();
|
||||
|
||||
@@ -80,7 +80,7 @@ void HMAC_SHA1_Init(HMAC_SHA1_CTX *ctx) {
|
||||
ctx->hashkey = 0;
|
||||
}
|
||||
|
||||
void HMAC_SHA1_UpdateKey(HMAC_SHA1_CTX *ctx, unsigned char *key, unsigned int keylen) {
|
||||
void HMAC_SHA1_UpdateKey(HMAC_SHA1_CTX *ctx, const unsigned char *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, unsigned char *data, unsigned int datalen) {
|
||||
void HMAC_SHA1_UpdateMessage(HMAC_SHA1_CTX *ctx, const unsigned char *data, unsigned int datalen) {
|
||||
SHA1_Update(&ctx->shactx, data, datalen);
|
||||
}
|
||||
|
||||
|
||||
@@ -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, unsigned char *key, unsigned int keylen);
|
||||
void HMAC_SHA1_UpdateKey(HMAC_SHA1_CTX *ctx, const unsigned char *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, unsigned char *data, unsigned int datalen);
|
||||
void HMAC_SHA1_UpdateMessage(HMAC_SHA1_CTX *ctx, const unsigned char *data, unsigned int datalen);
|
||||
void HMAC_SHA1_EndMessage(unsigned char *out, HMAC_SHA1_CTX *ctx);
|
||||
void HMAC_SHA1_Done(HMAC_SHA1_CTX *ctx);
|
||||
#else
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
/* HMAC-SHA-224 functions */
|
||||
|
||||
void hmac_sha224_init(hmac_sha224_ctx *ctx, unsigned char *key,
|
||||
void hmac_sha224_init(hmac_sha224_ctx *ctx, const unsigned char *key,
|
||||
unsigned int key_size)
|
||||
{
|
||||
unsigned int fill;
|
||||
@@ -52,7 +52,7 @@ void hmac_sha224_init(hmac_sha224_ctx *ctx, unsigned char *key,
|
||||
unsigned int i;
|
||||
|
||||
if (key_size == SHA224_BLOCK_SIZE) {
|
||||
key_used = key;
|
||||
key_used = ( unsigned char * ) key;
|
||||
num = SHA224_BLOCK_SIZE;
|
||||
} else {
|
||||
if (key_size > SHA224_BLOCK_SIZE){
|
||||
@@ -60,7 +60,7 @@ void hmac_sha224_init(hmac_sha224_ctx *ctx, unsigned char *key,
|
||||
num = SHA224_DIGEST_SIZE;
|
||||
sha224(key, key_size, key_used);
|
||||
} else { /* key_size > SHA224_BLOCK_SIZE */
|
||||
key_used = key;
|
||||
key_used = ( unsigned char * ) key;
|
||||
num = key_size;
|
||||
}
|
||||
fill = SHA224_BLOCK_SIZE - num;
|
||||
@@ -96,7 +96,7 @@ void hmac_sha224_reinit(hmac_sha224_ctx *ctx)
|
||||
sizeof(sha224_ctx));
|
||||
}
|
||||
|
||||
void hmac_sha224_update(hmac_sha224_ctx *ctx, unsigned char *message,
|
||||
void hmac_sha224_update(hmac_sha224_ctx *ctx, const unsigned char *message,
|
||||
unsigned int message_len)
|
||||
{
|
||||
sha224_update(&ctx->ctx_inside, message, message_len);
|
||||
@@ -114,8 +114,8 @@ void hmac_sha224_final(hmac_sha224_ctx *ctx, unsigned char *mac,
|
||||
memcpy(mac, mac_temp, mac_size);
|
||||
}
|
||||
|
||||
void hmac_sha224(unsigned char *key, unsigned int key_size,
|
||||
unsigned char *message, unsigned int message_len,
|
||||
void hmac_sha224(const unsigned char *key, unsigned int key_size,
|
||||
const unsigned char *message, unsigned int message_len,
|
||||
unsigned char *mac, unsigned mac_size)
|
||||
{
|
||||
hmac_sha224_ctx ctx;
|
||||
@@ -127,7 +127,7 @@ void hmac_sha224(unsigned char *key, unsigned int key_size,
|
||||
|
||||
/* HMAC-SHA-256 functions */
|
||||
|
||||
void hmac_sha256_init(hmac_sha256_ctx *ctx, unsigned char *key,
|
||||
void hmac_sha256_init(hmac_sha256_ctx *ctx, const unsigned char *key,
|
||||
unsigned int key_size)
|
||||
{
|
||||
unsigned int fill;
|
||||
@@ -138,7 +138,7 @@ void hmac_sha256_init(hmac_sha256_ctx *ctx, unsigned char *key,
|
||||
unsigned int i;
|
||||
|
||||
if (key_size == SHA256_BLOCK_SIZE) {
|
||||
key_used = key;
|
||||
key_used = ( unsigned char * ) key;
|
||||
num = SHA256_BLOCK_SIZE;
|
||||
} else {
|
||||
if (key_size > SHA256_BLOCK_SIZE){
|
||||
@@ -146,7 +146,7 @@ void hmac_sha256_init(hmac_sha256_ctx *ctx, unsigned char *key,
|
||||
num = SHA256_DIGEST_SIZE;
|
||||
sha256(key, key_size, key_used);
|
||||
} else { /* key_size > SHA256_BLOCK_SIZE */
|
||||
key_used = key;
|
||||
key_used = ( unsigned char * ) key;
|
||||
num = key_size;
|
||||
}
|
||||
fill = SHA256_BLOCK_SIZE - num;
|
||||
@@ -182,7 +182,7 @@ void hmac_sha256_reinit(hmac_sha256_ctx *ctx)
|
||||
sizeof(sha256_ctx));
|
||||
}
|
||||
|
||||
void hmac_sha256_update(hmac_sha256_ctx *ctx, unsigned char *message,
|
||||
void hmac_sha256_update(hmac_sha256_ctx *ctx, const unsigned char *message,
|
||||
unsigned int message_len)
|
||||
{
|
||||
sha256_update(&ctx->ctx_inside, message, message_len);
|
||||
@@ -200,8 +200,8 @@ void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac,
|
||||
memcpy(mac, mac_temp, mac_size);
|
||||
}
|
||||
|
||||
void hmac_sha256(unsigned char *key, unsigned int key_size,
|
||||
unsigned char *message, unsigned int message_len,
|
||||
void hmac_sha256(const unsigned char *key, unsigned int key_size,
|
||||
const unsigned char *message, unsigned int message_len,
|
||||
unsigned char *mac, unsigned mac_size)
|
||||
{
|
||||
hmac_sha256_ctx ctx;
|
||||
@@ -213,7 +213,7 @@ void hmac_sha256(unsigned char *key, unsigned int key_size,
|
||||
|
||||
/* HMAC-SHA-384 functions */
|
||||
|
||||
void hmac_sha384_init(hmac_sha384_ctx *ctx, unsigned char *key,
|
||||
void hmac_sha384_init(hmac_sha384_ctx *ctx, const unsigned char *key,
|
||||
unsigned int key_size)
|
||||
{
|
||||
unsigned int fill;
|
||||
@@ -224,7 +224,7 @@ void hmac_sha384_init(hmac_sha384_ctx *ctx, unsigned char *key,
|
||||
unsigned int i;
|
||||
|
||||
if (key_size == SHA384_BLOCK_SIZE) {
|
||||
key_used = key;
|
||||
key_used = ( unsigned char * ) key;
|
||||
num = SHA384_BLOCK_SIZE;
|
||||
} else {
|
||||
if (key_size > SHA384_BLOCK_SIZE){
|
||||
@@ -232,7 +232,7 @@ void hmac_sha384_init(hmac_sha384_ctx *ctx, unsigned char *key,
|
||||
num = SHA384_DIGEST_SIZE;
|
||||
sha384(key, key_size, key_used);
|
||||
} else { /* key_size > SHA384_BLOCK_SIZE */
|
||||
key_used = key;
|
||||
key_used = ( unsigned char * ) key;
|
||||
num = key_size;
|
||||
}
|
||||
fill = SHA384_BLOCK_SIZE - num;
|
||||
@@ -268,7 +268,7 @@ void hmac_sha384_reinit(hmac_sha384_ctx *ctx)
|
||||
sizeof(sha384_ctx));
|
||||
}
|
||||
|
||||
void hmac_sha384_update(hmac_sha384_ctx *ctx, unsigned char *message,
|
||||
void hmac_sha384_update(hmac_sha384_ctx *ctx, const unsigned char *message,
|
||||
unsigned int message_len)
|
||||
{
|
||||
sha384_update(&ctx->ctx_inside, message, message_len);
|
||||
@@ -286,8 +286,8 @@ void hmac_sha384_final(hmac_sha384_ctx *ctx, unsigned char *mac,
|
||||
memcpy(mac, mac_temp, mac_size);
|
||||
}
|
||||
|
||||
void hmac_sha384(unsigned char *key, unsigned int key_size,
|
||||
unsigned char *message, unsigned int message_len,
|
||||
void hmac_sha384(const unsigned char *key, unsigned int key_size,
|
||||
const unsigned char *message, unsigned int message_len,
|
||||
unsigned char *mac, unsigned mac_size)
|
||||
{
|
||||
hmac_sha384_ctx ctx;
|
||||
@@ -299,7 +299,7 @@ void hmac_sha384(unsigned char *key, unsigned int key_size,
|
||||
|
||||
/* HMAC-SHA-512 functions */
|
||||
|
||||
void hmac_sha512_init(hmac_sha512_ctx *ctx, unsigned char *key,
|
||||
void hmac_sha512_init(hmac_sha512_ctx *ctx, const unsigned char *key,
|
||||
unsigned int key_size)
|
||||
{
|
||||
unsigned int fill;
|
||||
@@ -310,7 +310,7 @@ void hmac_sha512_init(hmac_sha512_ctx *ctx, unsigned char *key,
|
||||
unsigned int i;
|
||||
|
||||
if (key_size == SHA512_BLOCK_SIZE) {
|
||||
key_used = key;
|
||||
key_used = ( unsigned char * ) key;
|
||||
num = SHA512_BLOCK_SIZE;
|
||||
} else {
|
||||
if (key_size > SHA512_BLOCK_SIZE){
|
||||
@@ -318,7 +318,7 @@ void hmac_sha512_init(hmac_sha512_ctx *ctx, unsigned char *key,
|
||||
num = SHA512_DIGEST_SIZE;
|
||||
sha512(key, key_size, key_used);
|
||||
} else { /* key_size > SHA512_BLOCK_SIZE */
|
||||
key_used = key;
|
||||
key_used = ( unsigned char * ) key;
|
||||
num = key_size;
|
||||
}
|
||||
fill = SHA512_BLOCK_SIZE - num;
|
||||
@@ -354,7 +354,7 @@ void hmac_sha512_reinit(hmac_sha512_ctx *ctx)
|
||||
sizeof(sha512_ctx));
|
||||
}
|
||||
|
||||
void hmac_sha512_update(hmac_sha512_ctx *ctx, unsigned char *message,
|
||||
void hmac_sha512_update(hmac_sha512_ctx *ctx, const unsigned char *message,
|
||||
unsigned int message_len)
|
||||
{
|
||||
sha512_update(&ctx->ctx_inside, message, message_len);
|
||||
@@ -372,8 +372,8 @@ void hmac_sha512_final(hmac_sha512_ctx *ctx, unsigned char *mac,
|
||||
memcpy(mac, mac_temp, mac_size);
|
||||
}
|
||||
|
||||
void hmac_sha512(unsigned char *key, unsigned int key_size,
|
||||
unsigned char *message, unsigned int message_len,
|
||||
void hmac_sha512(const unsigned char *key, unsigned int key_size,
|
||||
const unsigned char *message, unsigned int message_len,
|
||||
unsigned char *mac, unsigned mac_size)
|
||||
{
|
||||
hmac_sha512_ctx ctx;
|
||||
|
||||
@@ -92,48 +92,48 @@ typedef struct {
|
||||
unsigned char block_opad[SHA512_BLOCK_SIZE];
|
||||
} hmac_sha512_ctx;
|
||||
|
||||
void hmac_sha224_init(hmac_sha224_ctx *ctx, unsigned char *key,
|
||||
void hmac_sha224_init(hmac_sha224_ctx *ctx, const unsigned char *key,
|
||||
unsigned int key_size);
|
||||
void hmac_sha224_reinit(hmac_sha224_ctx *ctx);
|
||||
void hmac_sha224_update(hmac_sha224_ctx *ctx, unsigned char *message,
|
||||
void hmac_sha224_update(hmac_sha224_ctx *ctx, const unsigned char *message,
|
||||
unsigned int message_len);
|
||||
void hmac_sha224_final(hmac_sha224_ctx *ctx, unsigned char *mac,
|
||||
unsigned int mac_size);
|
||||
void hmac_sha224(unsigned char *key, unsigned int key_size,
|
||||
unsigned char *message, unsigned int message_len,
|
||||
void hmac_sha224(const unsigned char *key, unsigned int key_size,
|
||||
const unsigned char *message, unsigned int message_len,
|
||||
unsigned char *mac, unsigned mac_size);
|
||||
|
||||
void hmac_sha256_init(hmac_sha256_ctx *ctx, unsigned char *key,
|
||||
void hmac_sha256_init(hmac_sha256_ctx *ctx, const unsigned char *key,
|
||||
unsigned int key_size);
|
||||
void hmac_sha256_reinit(hmac_sha256_ctx *ctx);
|
||||
void hmac_sha256_update(hmac_sha256_ctx *ctx, unsigned char *message,
|
||||
void hmac_sha256_update(hmac_sha256_ctx *ctx, const unsigned char *message,
|
||||
unsigned int message_len);
|
||||
void hmac_sha256_final(hmac_sha256_ctx *ctx, unsigned char *mac,
|
||||
unsigned int mac_size);
|
||||
void hmac_sha256(unsigned char *key, unsigned int key_size,
|
||||
unsigned char *message, unsigned int message_len,
|
||||
void hmac_sha256(const unsigned char *key, unsigned int key_size,
|
||||
const unsigned char *message, unsigned int message_len,
|
||||
unsigned char *mac, unsigned mac_size);
|
||||
|
||||
void hmac_sha384_init(hmac_sha384_ctx *ctx, unsigned char *key,
|
||||
void hmac_sha384_init(hmac_sha384_ctx *ctx, const unsigned char *key,
|
||||
unsigned int key_size);
|
||||
void hmac_sha384_reinit(hmac_sha384_ctx *ctx);
|
||||
void hmac_sha384_update(hmac_sha384_ctx *ctx, unsigned char *message,
|
||||
void hmac_sha384_update(hmac_sha384_ctx *ctx, const unsigned char *message,
|
||||
unsigned int message_len);
|
||||
void hmac_sha384_final(hmac_sha384_ctx *ctx, unsigned char *mac,
|
||||
unsigned int mac_size);
|
||||
void hmac_sha384(unsigned char *key, unsigned int key_size,
|
||||
unsigned char *message, unsigned int message_len,
|
||||
void hmac_sha384(const unsigned char *key, unsigned int key_size,
|
||||
const unsigned char *message, unsigned int message_len,
|
||||
unsigned char *mac, unsigned mac_size);
|
||||
|
||||
void hmac_sha512_init(hmac_sha512_ctx *ctx, unsigned char *key,
|
||||
void hmac_sha512_init(hmac_sha512_ctx *ctx, const unsigned char *key,
|
||||
unsigned int key_size);
|
||||
void hmac_sha512_reinit(hmac_sha512_ctx *ctx);
|
||||
void hmac_sha512_update(hmac_sha512_ctx *ctx, unsigned char *message,
|
||||
void hmac_sha512_update(hmac_sha512_ctx *ctx, const unsigned char *message,
|
||||
unsigned int message_len);
|
||||
void hmac_sha512_final(hmac_sha512_ctx *ctx, unsigned char *mac,
|
||||
unsigned int mac_size);
|
||||
void hmac_sha512(unsigned char *key, unsigned int key_size,
|
||||
unsigned char *message, unsigned int message_len,
|
||||
void hmac_sha512(const unsigned char *key, unsigned int key_size,
|
||||
const unsigned char *message, unsigned int message_len,
|
||||
unsigned char *mac, unsigned mac_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user