diff --git a/src/hostkey.c b/src/hostkey.c index 19c855d9..41b251b0 100644 --- a/src/hostkey.c +++ b/src/hostkey.c @@ -828,7 +828,7 @@ hostkey_method_ssh_ed25519_init(LIBSSH2_SESSION * session, return _libssh2_error(session, LIBSSH2_ERROR_PROTO, "could not create ED25519 public key"); } - ctx = LIBSSH2_CALLOC(session, sizeof(libssh2_ed25519_ctx)); + ctx = _libssh2_ed25519_new_ctx(); if(ctx == NULL) { return _libssh2_error(session, LIBSSH2_ERROR_ALLOC, "could not alloc public/private key"); } diff --git a/src/openssl.c b/src/openssl.c index 0f79fc27..64a2a12c 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -1590,7 +1590,7 @@ gen_publickey_from_ed25519_openssh_priv_data(LIBSSH2_SESSION *session, goto clean_exit; } - ctx = LIBSSH2_CALLOC(session, sizeof(libssh2_ed25519_ctx)); + ctx = _libssh2_ed25519_new_ctx(); if (ctx == NULL) { _libssh2_error(session, LIBSSH2_ERROR_ALLOC, "Unable to allocate memory for ed25519 key"); diff --git a/src/openssl.h b/src/openssl.h index fe497a9b..4cd7ffde 100644 --- a/src/openssl.h +++ b/src/openssl.h @@ -325,6 +325,7 @@ typedef struct { #define libssh2_ed25519_ctx libssh2_curve25519_keys #define libssh2_x25519_ctx libssh2_curve25519_keys +#define _libssh2_ed25519_new_ctx() malloc(sizeof(libssh2_ed25519_ctx)) #define _libssh2_ed25519_free(ctx) do { \ if(ctx) { \ if(ctx->public_key) EVP_PKEY_free(ctx->public_key); \