Skip to content

Commit

Permalink
Use adequate const qualifiers for pbkdf2 functions arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
idrassi committed Nov 13, 2024
1 parent c63b74b commit 75152f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions src/Common/Pkcs5.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void hmac_sha256
}
#endif

static void derive_u_sha256 (unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_sha256_ctx* hmac)
static void derive_u_sha256 (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_sha256_ctx* hmac)
{
unsigned char* k = hmac->k;
unsigned char* u = hmac->u;
Expand Down Expand Up @@ -196,7 +196,7 @@ static void derive_u_sha256 (unsigned char *salt, int salt_len, uint32 iteration
}


void derive_key_sha256 (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
void derive_key_sha256 (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
{
hmac_sha256_ctx hmac;
sha256_ctx* ctx;
Expand Down Expand Up @@ -395,7 +395,7 @@ void hmac_sha512
burn (key, sizeof(key));
}

static void derive_u_sha512 (unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_sha512_ctx* hmac)
static void derive_u_sha512 (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_sha512_ctx* hmac)
{
unsigned char* k = hmac->k;
unsigned char* u = hmac->u;
Expand All @@ -422,7 +422,7 @@ static void derive_u_sha512 (unsigned char *salt, int salt_len, uint32 iteration
}


void derive_key_sha512 (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
void derive_key_sha512 (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
{
hmac_sha512_ctx hmac;
sha512_ctx* ctx;
Expand Down Expand Up @@ -619,7 +619,7 @@ void hmac_blake2s
}
#endif

static void derive_u_blake2s (unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_blake2s_ctx* hmac)
static void derive_u_blake2s (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_blake2s_ctx* hmac)
{
unsigned char* k = hmac->k;
unsigned char* u = hmac->u;
Expand Down Expand Up @@ -670,7 +670,7 @@ static void derive_u_blake2s (unsigned char *salt, int salt_len, uint32 iteratio
}


void derive_key_blake2s (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
void derive_key_blake2s (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
{
hmac_blake2s_ctx hmac;
blake2s_state* ctx;
Expand Down Expand Up @@ -859,7 +859,7 @@ void hmac_whirlpool
burn(&hmac, sizeof(hmac));
}

static void derive_u_whirlpool (unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_whirlpool_ctx* hmac)
static void derive_u_whirlpool (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_whirlpool_ctx* hmac)
{
unsigned char* u = hmac->u;
unsigned char* k = hmac->k;
Expand All @@ -885,7 +885,7 @@ static void derive_u_whirlpool (unsigned char *salt, int salt_len, uint32 iterat
}
}

void derive_key_whirlpool (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
void derive_key_whirlpool (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
{
hmac_whirlpool_ctx hmac;
WHIRLPOOL_CTX* ctx;
Expand Down Expand Up @@ -1053,7 +1053,7 @@ void hmac_streebog
burn(&hmac, sizeof(hmac));
}

static void derive_u_streebog (unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_streebog_ctx* hmac)
static void derive_u_streebog (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_streebog_ctx* hmac)
{
unsigned char* u = hmac->u;
unsigned char* k = hmac->k;
Expand All @@ -1079,7 +1079,7 @@ static void derive_u_streebog (unsigned char *salt, int salt_len, uint32 iterati
}
}

void derive_key_streebog (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
void derive_key_streebog (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen)
{
hmac_streebog_ctx hmac;
STREEBOG_CTX* ctx;
Expand Down
12 changes: 6 additions & 6 deletions src/Common/Pkcs5.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ extern "C"
#endif
/* output written to input_digest which must be at lease 32 bytes long */
void hmac_blake2s (unsigned char *key, int keylen, unsigned char *input_digest, int len);
void derive_key_blake2s (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);
void derive_key_blake2s (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);

/* output written to d which must be at lease 32 bytes long */
void hmac_sha256 (unsigned char *k, int lk, unsigned char *d, int ld);
void derive_key_sha256 (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);
void derive_key_sha256 (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);

#ifndef TC_WINDOWS_BOOT
/* output written to d which must be at lease 64 bytes long */
void hmac_sha512 (unsigned char *k, int lk, unsigned char *d, int ld);
void derive_key_sha512 (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);
void derive_key_sha512 (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);

/* output written to d which must be at lease 64 bytes long */
void hmac_whirlpool (unsigned char *k, int lk, unsigned char *d, int ld);
void derive_key_whirlpool (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);
void derive_key_whirlpool (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);

void hmac_streebog (unsigned char *k, int32 lk, unsigned char *d, int32 ld);
void derive_key_streebog (unsigned char *pwd, int pwd_len, unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);
void hmac_streebog (unsigned char *k, int lk, unsigned char *d, int ld);
void derive_key_streebog (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen);

int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL bBoot);
wchar_t *get_pkcs5_prf_name (int pkcs5_prf_id);
Expand Down

0 comments on commit 75152f7

Please sign in to comment.