fix(crypto): K-02 — format v3 chunk replay protection with generation aad
This commit is contained in:
+6
-1
@@ -57,6 +57,7 @@ fn calc_vault_node_sha256(
|
||||
&record.nonce,
|
||||
&record.tag,
|
||||
version,
|
||||
record.generation,
|
||||
)?;
|
||||
hasher.update(&decrypted);
|
||||
}
|
||||
@@ -313,12 +314,15 @@ pub fn sync_single_file_to_vault(
|
||||
}
|
||||
|
||||
let chunk_data = &buffer[..n];
|
||||
let (ciphertext, nonce, tag) = encrypt_chunk(dek, node_id, chunk_idx, chunk_data, version)?;
|
||||
let gen = db.next_chunk_generation(node_id, chunk_idx)?;
|
||||
let (ciphertext, nonce, tag) =
|
||||
encrypt_chunk(dek, node_id, chunk_idx, chunk_data, version, gen)?;
|
||||
bytes_written += n as u64;
|
||||
|
||||
db.write_chunk_and_update_size(
|
||||
node_id,
|
||||
chunk_idx,
|
||||
gen,
|
||||
&nonce,
|
||||
&tag,
|
||||
&ciphertext,
|
||||
@@ -409,6 +413,7 @@ pub fn sync_single_file_to_host(
|
||||
&record.nonce,
|
||||
&record.tag,
|
||||
version,
|
||||
record.generation,
|
||||
)?;
|
||||
out_file.write_all(&plaintext)?;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user