summaryrefslogtreecommitdiff
path: root/src/cipher.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-15 18:12:50 +0300
committerLars Wirzenius <liw@liw.fi>2021-09-18 17:52:36 +0300
commit6ed6b1bc75b1995a7740ff28bc26a908b91f37c8 (patch)
tree48575e9335123d5f6a228038f71565e42dbf9366 /src/cipher.rs
parentd6728974b98a821b8d633197abd97cf2fc9357f5 (diff)
downloadobnam2-6ed6b1bc75b1995a7740ff28bc26a908b91f37c8.tar.gz
refactor: define a Checksum type and use it where appropriate
This will make it harder to compare, say, a SHA-256 and a SHA3, later, when we add more checksum types. Sponsored-by: author
Diffstat (limited to 'src/cipher.rs')
-rw-r--r--src/cipher.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cipher.rs b/src/cipher.rs
index b8e02f2..04b2944 100644
--- a/src/cipher.rs
+++ b/src/cipher.rs
@@ -164,6 +164,7 @@ impl Nonce {
#[cfg(test)]
mod test {
+ use crate::checksummer::Checksum;
use crate::chunk::DataChunk;
use crate::chunkmeta::ChunkMeta;
use crate::cipher::{CipherEngine, CipherError, CHUNK_V1, NONCE_SIZE};
@@ -171,7 +172,8 @@ mod test {
#[test]
fn metadata_as_aad() {
- let meta = ChunkMeta::new("dummy-checksum");
+ let sum = Checksum::sha256_from_str_unchecked("dummy-checksum");
+ let meta = ChunkMeta::new(&sum);
let meta_as_aad = meta.to_json_vec();
let chunk = DataChunk::new("hello".as_bytes().to_vec(), meta);
let pass = Passwords::new("secret");
@@ -183,7 +185,8 @@ mod test {
#[test]
fn round_trip() {
- let meta = ChunkMeta::new("dummy-checksum");
+ let sum = Checksum::sha256_from_str_unchecked("dummy-checksum");
+ let meta = ChunkMeta::new(&sum);
let chunk = DataChunk::new("hello".as_bytes().to_vec(), meta);
let pass = Passwords::new("secret");