mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
ed25519: Avoid timing leak when comparing private keys
This affects libgcrypt and mbedTLS backends. The OpenSSL backend is using OpenSSL implementation of the Ed25519 which is compared correctly. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
This commit is contained in:
@@ -104,9 +104,9 @@ pki_ed25519_key_cmp(const ssh_key k1, const ssh_key k2, enum ssh_keycmp_e what)
|
|||||||
}
|
}
|
||||||
/* In the internal implementation, the private key is the concatenation
|
/* In the internal implementation, the private key is the concatenation
|
||||||
* of the private seed with the public key. */
|
* of the private seed with the public key. */
|
||||||
cmp = memcmp(k1->ed25519_privkey,
|
cmp = secure_memcmp(k1->ed25519_privkey,
|
||||||
k2->ed25519_privkey,
|
k2->ed25519_privkey,
|
||||||
2 * ED25519_KEY_LEN);
|
2 * ED25519_KEY_LEN);
|
||||||
if (cmp != 0) {
|
if (cmp != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user