diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-12-04 16:47:50 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-12-07 15:57:42 +0100 |
commit | b222796002d9276f55a2b961aabfac6890d9b527 (patch) | |
tree | aa0bac07262de2c671976950f2c1f5e3e397cdc1 /openpgp/src/crypto/backend | |
parent | 551f29499a3ca9c5b15692ac7877730808dda8cb (diff) |
openpgp: Make digest computation more robust.
Diffstat (limited to 'openpgp/src/crypto/backend')
-rw-r--r-- | openpgp/src/crypto/backend/cng/hash.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/openpgp/src/crypto/backend/cng/hash.rs b/openpgp/src/crypto/backend/cng/hash.rs index a88c1524..3c797797 100644 --- a/openpgp/src/crypto/backend/cng/hash.rs +++ b/openpgp/src/crypto/backend/cng/hash.rs @@ -48,7 +48,8 @@ impl Digest for Hash { let buffer = old.finish() .expect("CNG to not fail internally"); - digest.copy_from_slice(&buffer.as_slice()[..digest.len()]); + let l = buffer.len().min(digest.len()); + &mut digest[..l].copy_from_slice(&buffer.as_slice()[..l]); Ok(()) } } |