diff options
author | Luca Deri <deri@ntop.org> | 2023-12-23 09:15:42 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2023-12-23 09:15:42 +0100 |
commit | caa223d2baefb3ffb0bfcec6230791e0e39ef23d (patch) | |
tree | b5178653d5593ce33b40836ae2675ea63b27afd6 | |
parent | 5c7200f2bb763bfcd4e0636aebb88573e97bbcf3 (diff) |
Changes to avoid type redefinition on windows
-rw-r--r-- | src/lib/protocols/tls.c | 4 | ||||
-rw-r--r-- | src/lib/third_party/include/ndpi_sha256.h | 9 | ||||
-rw-r--r-- | src/lib/third_party/src/ndpi_sha256.c | 20 |
3 files changed, 16 insertions, 17 deletions
diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c index e3e103307..9bc948f23 100644 --- a/src/lib/protocols/tls.c +++ b/src/lib/protocols/tls.c @@ -1603,10 +1603,10 @@ static void ndpi_compute_ja4(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, u_int32_t quic_version, union ja_info *ja) { - BYTE tmp_str[JA_STR_LEN]; + u_int8_t tmp_str[JA_STR_LEN]; u_int tmp_str_len, num_extn; SHA256_CTX sha_ctx; - BYTE sha_hash[SHA256_BLOCK_SIZE]; + u_int8_t sha_hash[SHA256_BLOCK_SIZE]; char ja_str[JA_STR_LEN]; u_int16_t ja_str_len, i; int rc; diff --git a/src/lib/third_party/include/ndpi_sha256.h b/src/lib/third_party/include/ndpi_sha256.h index 0525f3fef..730c2b6b3 100644 --- a/src/lib/third_party/include/ndpi_sha256.h +++ b/src/lib/third_party/include/ndpi_sha256.h @@ -11,19 +11,18 @@ /*************************** HEADER FILES ***************************/ #include <stddef.h> +#include "ndpi_typedefs.h" /****************************** MACROS ******************************/ #define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest /**************************** DATA TYPES ****************************/ -typedef unsigned char BYTE; // 8-bit byte -typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines typedef struct { - BYTE data[64]; - WORD datalen; + u_int8_t data[64]; + u_int32_t datalen; unsigned long long bitlen; - WORD state[8]; + u_int32_t state[8]; } SHA256_CTX; /*********************** FUNCTION DECLARATIONS **********************/ diff --git a/src/lib/third_party/src/ndpi_sha256.c b/src/lib/third_party/src/ndpi_sha256.c index 3fd920bc6..b40c796a3 100644 --- a/src/lib/third_party/src/ndpi_sha256.c +++ b/src/lib/third_party/src/ndpi_sha256.c @@ -11,7 +11,7 @@ offered in this implementation. Algorithm specification can be found here: * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf - This implementation uses little endian byte order. + This implementation uses little endian u_int8_t order. *********************************************************************/ /*************************** HEADER FILES ***************************/ @@ -31,7 +31,7 @@ #define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10)) /**************************** VARIABLES *****************************/ -static const WORD k[64] = { +static const u_int32_t k[64] = { 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5, 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174, 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da, @@ -43,9 +43,9 @@ static const WORD k[64] = { }; /*********************** FUNCTION DEFINITIONS ***********************/ -void sha256_transform(SHA256_CTX *ctx, const BYTE data[]) +void sha256_transform(SHA256_CTX *ctx, const u_int8_t data[]) { - WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64]; + u_int32_t a, b, c, d, e, f, g, h, i, j, t1, t2, m[64]; for (i = 0, j = 0; i < 16; ++i, j += 4) m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]); @@ -98,9 +98,9 @@ void ndpi_sha256_init(SHA256_CTX *ctx) ctx->state[7] = 0x5be0cd19; } -void ndpi_sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len) +void ndpi_sha256_update(SHA256_CTX *ctx, const u_int8_t data[], size_t len) { - WORD i; + u_int32_t i; for (i = 0; i < len; ++i) { ctx->data[ctx->datalen] = data[i]; @@ -113,9 +113,9 @@ void ndpi_sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len) } } -void ndpi_sha256_final(SHA256_CTX *ctx, BYTE hash[]) +void ndpi_sha256_final(SHA256_CTX *ctx, u_int8_t hash[]) { - WORD i; + u_int32_t i; i = ctx->datalen; @@ -145,8 +145,8 @@ void ndpi_sha256_final(SHA256_CTX *ctx, BYTE hash[]) ctx->data[56] = ctx->bitlen >> 56; sha256_transform(ctx, ctx->data); - // Since this implementation uses little endian byte ordering and SHA uses big endian, - // reverse all the bytes when copying the final state to the output hash. + // Since this implementation uses little endian u_int8_t ordering and SHA uses big endian, + // reverse all the u_int8_ts when copying the final state to the output hash. for (i = 0; i < 4; ++i) { hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff; hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff; |