summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-12-04 16:47:50 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-12-07 15:57:42 +0100
commitb222796002d9276f55a2b961aabfac6890d9b527 (patch)
treeaa0bac07262de2c671976950f2c1f5e3e397cdc1
parent551f29499a3ca9c5b15692ac7877730808dda8cb (diff)
openpgp: Make digest computation more robust.
-rw-r--r--openpgp/src/crypto/backend/cng/hash.rs3
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(())
}
}