Skip to content

Should nonce not be changed for every segment? #5

@Hoeze

Description

@Hoeze

Hi, I try to understand how the Crypt4GH standard works and therefore checked this library as a reference.

Checking the source code, I see that nonce_bytes gets initialized once:

crypt4gh-rust/src/lib.rs

Lines 153 to 155 in 2d41a17

let mut rnd = rand_chacha::ChaCha20Rng::from_entropy();
let mut nonce_bytes = [0u8; 12];
rnd.fill(&mut nonce_bytes);

However, it seems like nonce_bytes then gets used without ever changing it during looping over the data stream:
let nonce = Nonce::from_slice(&nonce_bytes);

Is this correct? Should the nonce not be changed every time, e.g. by incrementing it by 1, when encrypting a new segment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions