mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-21 14:00:51 +03:00
ssh-ed25519: Support PKIX + calc pubkey from private (#416)
Files: openssl.c/h Author: Zenju Notes: Adds support for PKIX key reading by fixing: _libssh2_pub_priv_keyfile() is missing the code to extract the ed25519 public key from a given private key _libssh2_ed25519_new_private_frommemory is only parsing the openssh key format but does not understand PKIX (as retrieved via PEM_read_bio_PrivateKey)
This commit is contained in:
@@ -322,26 +322,11 @@ libssh2_curve_type;
|
||||
#endif /* LIBSSH2_ECDSA */
|
||||
|
||||
#if LIBSSH2_ED25519
|
||||
#define libssh2_ed25519_ctx EVP_PKEY
|
||||
#define libssh2_x25519_ctx EVP_PKEY
|
||||
|
||||
typedef struct {
|
||||
EVP_PKEY *public_key;
|
||||
EVP_PKEY *private_key;
|
||||
} libssh2_curve25519_keys;
|
||||
|
||||
#define libssh2_ed25519_ctx libssh2_curve25519_keys
|
||||
#define libssh2_x25519_ctx libssh2_curve25519_keys
|
||||
|
||||
#define _libssh2_ed25519_new_ctx() calloc(1, sizeof(libssh2_ed25519_ctx))
|
||||
#define _libssh2_ed25519_free(ctx) do { \
|
||||
if(ctx) { \
|
||||
if(ctx->public_key) EVP_PKEY_free(ctx->public_key); \
|
||||
if(ctx->private_key) EVP_PKEY_free(ctx->private_key); \
|
||||
free(ctx); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define _libssh2_x25519_free(ctx) _libssh2_ed25519_free(ctx)
|
||||
|
||||
#define _libssh2_ed25519_free(ctx) EVP_PKEY_free(ctx)
|
||||
#define _libssh2_x25519_free(ctx) EVP_PKEY_free(ctx)
|
||||
#endif /* ED25519 */
|
||||
|
||||
#define _libssh2_cipher_type(name) const EVP_CIPHER *(*name)(void)
|
||||
|
||||
Reference in New Issue
Block a user