New ndpi_sha256() nDPI API call (#2230)
* Added ndpi_sha256.c to the Windows project * Added ndpi_sha256() nDPI API call
This commit is contained in:
+6
-5
@@ -14,7 +14,8 @@
|
||||
#include "ndpi_typedefs.h"
|
||||
|
||||
/****************************** MACROS ******************************/
|
||||
#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
|
||||
|
||||
#define NDPI_SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
|
||||
|
||||
/**************************** DATA TYPES ****************************/
|
||||
|
||||
@@ -23,12 +24,12 @@ typedef struct {
|
||||
u_int32_t datalen;
|
||||
unsigned long long bitlen;
|
||||
u_int32_t state[8];
|
||||
} SHA256_CTX;
|
||||
} ndpi_SHA256_CTX;
|
||||
|
||||
/*********************** FUNCTION DECLARATIONS **********************/
|
||||
|
||||
void ndpi_sha256_init(SHA256_CTX *ctx);
|
||||
void ndpi_sha256_update(SHA256_CTX *ctx, const u_int8_t data[], size_t len);
|
||||
void ndpi_sha256_final(SHA256_CTX *ctx, u_int8_t hash[]);
|
||||
void ndpi_sha256_init(ndpi_SHA256_CTX *ctx);
|
||||
void ndpi_sha256_update(ndpi_SHA256_CTX *ctx, const u_int8_t data[], size_t len);
|
||||
void ndpi_sha256_final(ndpi_SHA256_CTX *ctx, u_int8_t hash[]);
|
||||
|
||||
#endif // SHA256_H
|
||||
|
||||
+4
-4
@@ -43,7 +43,7 @@ static const u_int32_t k[64] = {
|
||||
};
|
||||
|
||||
/*********************** FUNCTION DEFINITIONS ***********************/
|
||||
void sha256_transform(SHA256_CTX *ctx, const u_int8_t data[])
|
||||
void sha256_transform(ndpi_SHA256_CTX *ctx, const u_int8_t data[])
|
||||
{
|
||||
u_int32_t a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
|
||||
|
||||
@@ -84,7 +84,7 @@ void sha256_transform(SHA256_CTX *ctx, const u_int8_t data[])
|
||||
ctx->state[7] += h;
|
||||
}
|
||||
|
||||
void ndpi_sha256_init(SHA256_CTX *ctx)
|
||||
void ndpi_sha256_init(ndpi_SHA256_CTX *ctx)
|
||||
{
|
||||
ctx->datalen = 0;
|
||||
ctx->bitlen = 0;
|
||||
@@ -98,7 +98,7 @@ void ndpi_sha256_init(SHA256_CTX *ctx)
|
||||
ctx->state[7] = 0x5be0cd19;
|
||||
}
|
||||
|
||||
void ndpi_sha256_update(SHA256_CTX *ctx, const u_int8_t data[], size_t len)
|
||||
void ndpi_sha256_update(ndpi_SHA256_CTX *ctx, const u_int8_t data[], size_t len)
|
||||
{
|
||||
u_int32_t i;
|
||||
|
||||
@@ -113,7 +113,7 @@ void ndpi_sha256_update(SHA256_CTX *ctx, const u_int8_t data[], size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
void ndpi_sha256_final(SHA256_CTX *ctx, u_int8_t hash[])
|
||||
void ndpi_sha256_final(ndpi_SHA256_CTX *ctx, u_int8_t hash[])
|
||||
{
|
||||
u_int32_t i;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user