From 53814839bb043f73750de2b678be2035aca83c4a Mon Sep 17 00:00:00 2001 From: John Safranek Date: Tue, 15 Sep 2026 15:09:54 -0700 Subject: [PATCH] echoserver: add Ed25519 sample public keys The example server loads hansel's and gretel's Ed25519 public keys when neither RSA nor ECDSA is compiled in, so public key auth works there instead of falling back to passwords. That arm is the "#if" and the userEcc choice the "#else", so no empty if/else is left behind. --- examples/echoserver/echoserver.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index e40e607d..76156bd4 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -2705,6 +2705,17 @@ static const char samplePublicKeyEccBuffer[] = #endif /* WOLFSSH_TPM */ #endif /* WOLFSSH_NO_RSA */ +/* Ed25519 is the only signing algorithm left when neither RSA nor ECDSA + * is compiled in, so the server needs sample keys of its own. */ +#if defined(WOLFSSH_NO_RSA) && defined(WOLFSSH_NO_ECDSA) && \ + !defined(WOLFSSH_NO_ED25519) +static const char samplePublicKeyEd25519Buffer[] = + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHTSoBZIJBO2V0Jb2OWyMWNbkD" + "d6ReDfKxnrAPlbPuCe hansel\n" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFD8Bwir++gzNJmif9ooAZdaRi" + "sFZjlp9XU2seaec7/m gretel\n"; +#endif + #ifdef WOLFSSH_ALLOW_USERAUTH_NONE static const char sampleNoneBuffer[] = @@ -4306,6 +4317,13 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args) keyLoadBuf[bufSz] = 0; LoadPasswordBuffer(keyLoadBuf, bufSz, &pwMapList); + #if defined(WOLFSSH_NO_RSA) && defined(WOLFSSH_NO_ECDSA) + /* Ed25519 is the only sample key left, so -e has nothing to pick + * between and is ignored. */ + #ifndef WOLFSSH_NO_ED25519 + bufName = samplePublicKeyEd25519Buffer; + #endif + #else if (userEcc) { #ifndef WOLFSSH_NO_ECDSA bufName = samplePublicKeyEccBuffer; @@ -4320,6 +4338,7 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args) #endif #endif } + #endif if (bufName != NULL) { bufSz = (word32)WSTRLEN(bufName); WMEMCPY(keyLoadBuf, bufName, bufSz);