diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2020-10-09 06:53:23 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2020-10-09 06:57:35 +0200 |
commit | 228836f79f64559c9582ac2d475e50af57684bf8 (patch) | |
tree | 291bd42f4c0eb1fbb2c259ff5d96f5dd9e690ed2 /g10/export.c | |
parent | agent: Fix SEGV when debuging for cache enabled. (diff) | |
download | gnupg2-228836f79f64559c9582ac2d475e50af57684bf8.tar.xz gnupg2-228836f79f64559c9582ac2d475e50af57684bf8.zip |
gpg,ecc: Fix SOS handling when receiving from agent.
* g10/export.c (transfer_format_to_openpgp): It's not simple opaque
MPI, but SOS.
--
Fixes-commit: f5bc94555458123f93d8b07816a68fb7485421e1
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'g10/export.c')
-rw-r--r-- | g10/export.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/g10/export.c b/g10/export.c index 08b161835..a9eba1544 100644 --- a/g10/export.c +++ b/g10/export.c @@ -982,11 +982,26 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk) || pk->pubkey_algo == PUBKEY_ALGO_EDDSA || pk->pubkey_algo == PUBKEY_ALGO_ECDH) { - skey[skeyidx] = gcry_mpi_set_opaque_copy (NULL, value, valuelen*8); + unsigned int nbits = valuelen*8; + const unsigned char *p = value; + + if (nbits >= 8 && !(*p & 0x80)) + if (--nbits >= 7 && !(*p & 0x40)) + if (--nbits >= 6 && !(*p & 0x20)) + if (--nbits >= 5 && !(*p & 0x10)) + if (--nbits >= 4 && !(*p & 0x08)) + if (--nbits >= 3 && !(*p & 0x04)) + if (--nbits >= 2 && !(*p & 0x02)) + if (--nbits >= 1 && !(*p & 0x01)) + --nbits; + + skey[skeyidx] = gcry_mpi_set_opaque_copy (NULL, value, nbits); if (!skey[skeyidx]) goto outofmem; if (is_enc) gcry_mpi_set_flag (skey[skeyidx], GCRYMPI_FLAG_USER1); + else + gcry_mpi_set_flag (skey[skeyidx], GCRYMPI_FLAG_USER2); } else { |