From 38f134e6a96c08fdd7d4ed07ca3550e8434d56e9 Mon Sep 17 00:00:00 2001 From: Maksym Mamontov Date: Fri, 22 Jul 2022 22:38:27 +0300 Subject: [PATCH] Cryptography with void* in the interfaces. --- libs/crypto/blowfish.c | 5 +++-- libs/crypto/include/stg/blowfish.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/crypto/blowfish.c b/libs/crypto/blowfish.c index 384d3a10..42b9158a 100644 --- a/libs/crypto/blowfish.c +++ b/libs/crypto/blowfish.c @@ -384,10 +384,11 @@ Xl = Xl ^ ctx->P[0]; *xr = Xr; } //----------------------------------------------------------------------------- -void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen) +void Blowfish_Init(BLOWFISH_CTX *ctx, void* key, int keyLen) { int i, j, k; uint32_t data, datal, datar; +unsigned char* keyPtr = key; memset(ctx->S, 0, sizeof(ctx->S)); @@ -406,7 +407,7 @@ for (i = 0; i < N + 2; ++i) for (k = 0; k < 4; ++k) { - data = (data << 8) | key[j]; + data = (data << 8) | keyPtr[j]; j = j + 1; if (j >= keyLen) j = 0; diff --git a/libs/crypto/include/stg/blowfish.h b/libs/crypto/include/stg/blowfish.h index 6a4e6f31..101b2f6f 100644 --- a/libs/crypto/include/stg/blowfish.h +++ b/libs/crypto/include/stg/blowfish.h @@ -24,7 +24,7 @@ typedef struct { uint32_t S[4][256]; } BLOWFISH_CTX; -void Blowfish_Init(BLOWFISH_CTX * ctx, unsigned char * key, int keyLen); +void Blowfish_Init(BLOWFISH_CTX * ctx, void* key, int keyLen); void Blowfish_Encrypt(const BLOWFISH_CTX * ctx, uint32_t * xl, uint32_t * xr); void Blowfish_Decrypt(const BLOWFISH_CTX * ctx, uint32_t * xl, uint32_t * xr); -- 2.43.2