mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
CVE-2023-6918: kdf: Detect context init failures
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
8b66d037d5
commit
8977e246b6
18
src/kdf.c
18
src/kdf.c
@@ -61,20 +61,32 @@ static ssh_mac_ctx ssh_mac_ctx_init(enum ssh_kdf_digest type)
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case SSH_KDF_SHA1:
|
case SSH_KDF_SHA1:
|
||||||
ctx->ctx.sha1_ctx = sha1_init();
|
ctx->ctx.sha1_ctx = sha1_init();
|
||||||
|
if (ctx->ctx.sha1_ctx == NULL) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
case SSH_KDF_SHA256:
|
case SSH_KDF_SHA256:
|
||||||
ctx->ctx.sha256_ctx = sha256_init();
|
ctx->ctx.sha256_ctx = sha256_init();
|
||||||
|
if (ctx->ctx.sha256_ctx == NULL) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
case SSH_KDF_SHA384:
|
case SSH_KDF_SHA384:
|
||||||
ctx->ctx.sha384_ctx = sha384_init();
|
ctx->ctx.sha384_ctx = sha384_init();
|
||||||
|
if (ctx->ctx.sha384_ctx == NULL) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
case SSH_KDF_SHA512:
|
case SSH_KDF_SHA512:
|
||||||
ctx->ctx.sha512_ctx = sha512_init();
|
ctx->ctx.sha512_ctx = sha512_init();
|
||||||
|
if (ctx->ctx.sha512_ctx == NULL) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
default:
|
|
||||||
SAFE_FREE(ctx);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
err:
|
||||||
|
SAFE_FREE(ctx);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ssh_mac_ctx_free(ssh_mac_ctx ctx)
|
static void ssh_mac_ctx_free(ssh_mac_ctx ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user