diff --git a/keys/id_barney b/keys/id_barney new file mode 100644 index 00000000..07c504bb --- /dev/null +++ b/keys/id_barney @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACBs8gsipHiL/VP0nvJOeDeR0EYF9AXtXnjGlGmqHru5NQAAAJghFgrDIRYK +wwAAAAtzc2gtZWQyNTUxOQAAACBs8gsipHiL/VP0nvJOeDeR0EYF9AXtXnjGlGmqHru5NQ +AAAEDuTSTiIfkHZlxI+gjjETACk3F3PPU7jgOHG6NH/THSXWzyCyKkeIv9U/Se8k54N5HQ +RgX0Be1eeMaUaaoeu7k1AAAAEGJhcm5leUBsb2NhbGhvc3QBAgMEBQ== +-----END OPENSSH PRIVATE KEY----- diff --git a/keys/id_barney.pub b/keys/id_barney.pub new file mode 100644 index 00000000..64a15f34 --- /dev/null +++ b/keys/id_barney.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGzyCyKkeIv9U/Se8k54N5HQRgX0Be1eeMaUaaoeu7k1 barney@localhost diff --git a/src/internal.c b/src/internal.c index 866a3044..82f39420 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1409,8 +1409,7 @@ static int GetOpenSshKeyRsa(RsaKey* key, } #endif - -#if !defined(WOLFSSH_NO_ECDSA) && !defined(WOLFSSH_NO_ECC) +#ifndef WOLFSSH_NO_ECDSA /* * Utility for GetOpenSshKey() to read in ECDSA keys. */ @@ -1440,6 +1439,35 @@ static int GetOpenSshKeyEcc(ecc_key* key, } #endif +#ifndef WOLFSSH_NO_ED25519 +/* + * Utility for GetOpenSshKey() to read in Ed25519 keys. + */ +static int GetOpenSshKeyEd25519(ed25519_key* key, + const byte* buf, word32 len, word32* idx) +{ + const byte *name = NULL, *priv = NULL, *pub = NULL; + word32 nameSz = 0, privSz = 0, pubSz = 0; + int ret; + + ret = wc_ed25519_init_ex(key, ssh->ctx->heap, INVALID_DEVID); + if (ret == WS_SUCCESS) + ret = GetStringRef(&nameSz, &name, buf, len, idx); /* curve name */ + if (ret == WS_SUCCESS) + ret = GetStringRef(&pubSz, &pub, buf, len, idx); /* ENC(A) */ + if (ret == WS_SUCCESS) + ret = GetMpint(&privSz, &priv, buf, len, idx); /* k || ENC(A) */ + + if (ret == WS_SUCCESS) + ret = wc_ecc_import_private_key_ex(priv, privSz, pub, pubSz, + key, ECC_CURVE_DEF); + + if (ret != WS_SUCCESS) + ret = WS_ECC_E; + + return ret; +} +#endif /* * Decodes an OpenSSH format key. */ @@ -1522,11 +1550,18 @@ static int GetOpenSshKey(WS_KeySignature *key, str, strSz, &subIdx); break; #endif - #if !defined(WOLFSSH_NO_ECDSA) && !defined(WOLFSSH_NO_ECC) + #ifndef WOLFSSH_NO_ECDSA case ID_ECDSA_SHA2_NISTP256: + case ID_ECDSA_SHA2_NISTP384: + case ID_ECDSA_SHA2_NISTP521: ret = GetOpenSshKeyEcc(&key->ks.ecc.key, str, strSz, &subIdx); break; + #endif + #ifndef WOLFSSH_NO_ED25519 + ret = GetOpenSshKeyEd25519(&key->ks.ed25519.key, + str, strSz, &subIdx); + break; #endif default: ret = WS_UNIMPLEMENTED_E; diff --git a/wolfssh/internal.h b/wolfssh/internal.h index a7f85407..e617a4cf 100644 --- a/wolfssh/internal.h +++ b/wolfssh/internal.h @@ -239,8 +239,7 @@ extern "C" { #endif #if defined(WOLFSSH_NO_ECDSA_SHA2_NISTP256) && \ defined(WOLFSSH_NO_ECDSA_SHA2_NISTP384) && \ - defined(WOLFSSH_NO_ECDSA_SHA2_NISTP521) && \ - !defined(HAVE_ED25519) + defined(WOLFSSH_NO_ECDSA_SHA2_NISTP521) #undef WOLFSSH_NO_ECDSA #define WOLFSSH_NO_ECDSA #endif