From 2d498b827eca2e077837fb75639de1d09b8ef38c Mon Sep 17 00:00:00 2001 From: Terra Date: Thu, 24 Apr 2025 09:39:53 +1000 Subject: [PATCH] fix ed25519 export Signed-off-by: Terra --- lib/pki_evp.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pki_evp.cpp b/lib/pki_evp.cpp index 2f0b3ee4..7ba52cf5 100644 --- a/lib/pki_evp.cpp +++ b/lib/pki_evp.cpp @@ -938,14 +938,20 @@ void pki_evp::write_SSH2_ed25519_private(BIO *b, const EVP_PKEY *pkey) const { #ifndef OPENSSL_NO_EC static const char data0001[] = { 0, 0, 0, 1}; - char buf_nonce[8]; + // padding required to bring private key up to required block size for encryption + // elected to just add fixed padding as the size of the binary data should not change due to the fixed keysizes + static const char padding[] = { 1, 2, 3, 4, 5 }; + char buf_nonce[4]; QByteArray data, priv, pubfull; pubfull = SSH2publicQByteArray(true); RAND_bytes((unsigned char*)buf_nonce, sizeof buf_nonce); priv.append(buf_nonce, sizeof buf_nonce); + priv.append(buf_nonce, sizeof buf_nonce); priv += pubfull; ssh_key_QBA2data(ed25519PrivKey(pkey) + ed25519PubKey(), &priv); + ssh_key_QBA2data("", &priv); // comment (blank) + priv.append(padding, sizeof padding); data = "openssh-key-v1"; data.append('\0');