Issue using ssh_key_cmp with ED25519 certificate
Hi
I ran into an issue with ssh_pki_copy_cert_to_privkey failing when using with a ed25519 key & certificate. Using a RSA key & certificate worked fine.
After some investigation, I narrowed it down to the ssh_key_cmp call failing.
After some more digging I found this check, which should handle ed25519 keys, but isn't called in my case. It instead calls the generic pki_key_compare function which fails for ed25519 keys here because they should have been handled before.
The problem here is this check only catching the SSH_KEYTYPE_ED25519 type, but the certificate is of the SSH_KEYTYPE_ED25519_CERT01 type. My fix was to update the check to the following to catch the type correctly:
if (ssh_key_type_plain(k1->type) == SSH_KEYTYPE_ED25519 ||
ssh_key_type_plain(k1->type) == SSH_KEYTYPE_SK_ED25519) {
return pki_ed25519_key_cmp(k1, k2, what);
}
Using this fix, the compare worked and the ssh_pki_copy_cert_to_privkey call was successful.