mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-12 11:10:28 +09:00
CVE-2023-6918: Remove unused evp functions and types
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
a16f34c57a
commit
10c200037a
@@ -51,80 +51,6 @@ void ssh_reseed(void)
|
||||
mbedtls_ctr_drbg_reseed(&ssh_mbedtls_ctr_drbg, NULL, 0);
|
||||
}
|
||||
|
||||
static mbedtls_md_type_t nid_to_md_algo(int nid)
|
||||
{
|
||||
switch (nid) {
|
||||
case NID_mbedtls_nistp256:
|
||||
return MBEDTLS_MD_SHA256;
|
||||
case NID_mbedtls_nistp384:
|
||||
return MBEDTLS_MD_SHA384;
|
||||
case NID_mbedtls_nistp521:
|
||||
return MBEDTLS_MD_SHA512;
|
||||
}
|
||||
return MBEDTLS_MD_NONE;
|
||||
}
|
||||
|
||||
void evp(int nid, unsigned char *digest, size_t len,
|
||||
unsigned char *hash, unsigned int *hlen)
|
||||
{
|
||||
mbedtls_md_type_t algo = nid_to_md_algo(nid);
|
||||
const mbedtls_md_info_t *md_info =
|
||||
mbedtls_md_info_from_type(algo);
|
||||
|
||||
|
||||
if (md_info != NULL) {
|
||||
*hlen = mbedtls_md_get_size(md_info);
|
||||
mbedtls_md(md_info, digest, len, hash);
|
||||
}
|
||||
}
|
||||
|
||||
EVPCTX evp_init(int nid)
|
||||
{
|
||||
EVPCTX ctx = NULL;
|
||||
int rc;
|
||||
mbedtls_md_type_t algo = nid_to_md_algo(nid);
|
||||
const mbedtls_md_info_t *md_info =
|
||||
mbedtls_md_info_from_type(algo);
|
||||
|
||||
if (md_info == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx = malloc(sizeof(mbedtls_md_context_t));
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mbedtls_md_init(ctx);
|
||||
|
||||
rc = mbedtls_md_setup(ctx, md_info, 0);
|
||||
if (rc != 0) {
|
||||
SAFE_FREE(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = mbedtls_md_starts(ctx);
|
||||
if (rc != 0) {
|
||||
SAFE_FREE(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void evp_update(EVPCTX ctx, const void *data, size_t len)
|
||||
{
|
||||
mbedtls_md_update(ctx, data, len);
|
||||
}
|
||||
|
||||
void evp_final(EVPCTX ctx, unsigned char *md, unsigned int *mdlen)
|
||||
{
|
||||
*mdlen = mbedtls_md_get_size(ctx->MBEDTLS_PRIVATE(md_info));
|
||||
mbedtls_md_finish(ctx, md);
|
||||
mbedtls_md_free(ctx);
|
||||
SAFE_FREE(ctx);
|
||||
}
|
||||
|
||||
int ssh_kdf(struct ssh_crypto_struct *crypto,
|
||||
unsigned char *key, size_t key_len,
|
||||
uint8_t key_type, unsigned char *output,
|
||||
|
||||
Reference in New Issue
Block a user