mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-08 03:42:12 +03:00
libgcrypt: Prevent signature blob to start with 1 bit
This should prevent the long standing random failures of libgcrypt pipeline. I was recently able to reproduce it only with dropbear, which sounds like choking on the signature starting with bit 1, possibly interpretting it as a negative value. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
@@ -1664,7 +1664,13 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
|
||||
return NULL;
|
||||
}
|
||||
s = gcry_sexp_nth_data(sexp, 1, &size);
|
||||
if (*s == 0) {
|
||||
|
||||
/*
|
||||
* Remove leading zeroes, but only the ones that do not make the MPI
|
||||
* representation look like a negative value (first bit is one),
|
||||
* which might confuse some implementations.
|
||||
*/
|
||||
while (size > 1 && s[0] == 0 && (s[1] & 0x80) == 0) {
|
||||
size--;
|
||||
s++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user