fix(crypto): K-02 — format v3 chunk replay protection with generation aad

This commit is contained in:
2026-09-19 00:52:13 +02:00
parent ad531d8393
commit 36a4094336
9 changed files with 553 additions and 99 deletions
+6 -1
View File
@@ -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 {