mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-08 03:42:12 +03:00
CVE-2023-6918: kdf: Reformat
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
a8b9d13687
commit
a16f34c57a
20
src/kdf.c
20
src/kdf.c
@@ -58,7 +58,7 @@ static ssh_mac_ctx ssh_mac_ctx_init(enum ssh_kdf_digest type)
|
||||
}
|
||||
|
||||
ctx->digest_type = type;
|
||||
switch(type){
|
||||
switch (type) {
|
||||
case SSH_KDF_SHA1:
|
||||
ctx->ctx.sha1_ctx = sha1_init();
|
||||
return ctx;
|
||||
@@ -79,7 +79,7 @@ static ssh_mac_ctx ssh_mac_ctx_init(enum ssh_kdf_digest type)
|
||||
|
||||
static void ssh_mac_update(ssh_mac_ctx ctx, const void *data, size_t len)
|
||||
{
|
||||
switch(ctx->digest_type){
|
||||
switch (ctx->digest_type) {
|
||||
case SSH_KDF_SHA1:
|
||||
sha1_update(ctx->ctx.sha1_ctx, data, len);
|
||||
break;
|
||||
@@ -97,26 +97,28 @@ static void ssh_mac_update(ssh_mac_ctx ctx, const void *data, size_t len)
|
||||
|
||||
static void ssh_mac_final(unsigned char *md, ssh_mac_ctx ctx)
|
||||
{
|
||||
switch(ctx->digest_type){
|
||||
switch (ctx->digest_type) {
|
||||
case SSH_KDF_SHA1:
|
||||
sha1_final(md,ctx->ctx.sha1_ctx);
|
||||
sha1_final(md, ctx->ctx.sha1_ctx);
|
||||
break;
|
||||
case SSH_KDF_SHA256:
|
||||
sha256_final(md,ctx->ctx.sha256_ctx);
|
||||
sha256_final(md, ctx->ctx.sha256_ctx);
|
||||
break;
|
||||
case SSH_KDF_SHA384:
|
||||
sha384_final(md,ctx->ctx.sha384_ctx);
|
||||
sha384_final(md, ctx->ctx.sha384_ctx);
|
||||
break;
|
||||
case SSH_KDF_SHA512:
|
||||
sha512_final(md,ctx->ctx.sha512_ctx);
|
||||
sha512_final(md, ctx->ctx.sha512_ctx);
|
||||
break;
|
||||
}
|
||||
SAFE_FREE(ctx);
|
||||
}
|
||||
|
||||
int sshkdf_derive_key(struct ssh_crypto_struct *crypto,
|
||||
unsigned char *key, size_t key_len,
|
||||
uint8_t key_type, unsigned char *output,
|
||||
unsigned char *key,
|
||||
size_t key_len,
|
||||
uint8_t key_type,
|
||||
unsigned char *output,
|
||||
size_t requested_len)
|
||||
{
|
||||
/* Can't use VLAs with Visual Studio, so allocate the biggest
|
||||
|
||||
Reference in New Issue
Block a user