Merge pull request #659 from MCterra10/fix-ed25519
Some checks failed
CMake / build (build/xca-*-Linux.tar.gz, Unix Makefiles, linux, /usr, ubuntu, 5.15.2, ubuntu-latest) (push) Has been cancelled
CMake / build (build/xca-*-Linux.tar.gz, Unix Makefiles, linux, /usr, ubuntu, 6.6.2, ubuntu-latest) (push) Has been cancelled
CMake / build (build/xca-*.dmg, Unix Makefiles, mac, /opt/homebrew/opt/openssl, macos, 6.6.2, macos-latest) (push) Has been cancelled
CMake / build (build/xca-*.msi build/xca-portable-*.zip , MinGW Makefiles, windows, D:\msys2\msys64\mingw64, windows, 5.15.2, windows-2019, win64_mingw81) (push) Has been cancelled

Fixes Broken ED25519 OpenSSH Private Key Exports
This commit is contained in:
Christian Hohnstädt 2025-04-26 09:35:34 +02:00 committed by GitHub
commit 1308365015
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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');