Initial validator code for rust side hooks for chacha cuda parallel encrypt

This commit is contained in:
Stephen Akridge
2018-10-08 13:12:33 -07:00
committed by sakridge
parent c30b605047
commit 37a0b7b132
9 changed files with 196 additions and 29 deletions

View File

@@ -45,6 +45,9 @@ pub fn sample_file(in_path: &Path, sample_offsets: &[u64]) -> io::Result<Hash> {
let mut buf = vec![0; sample_size];
let file_len = metadata.len();
if file_len < sample_size64 {
return Err(Error::new(ErrorKind::Other, "file too short!"));
}
for offset in sample_offsets {
if *offset > (file_len - sample_size64) / sample_size64 {
return Err(Error::new(ErrorKind::Other, "offset too large"));