Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] The MinSize specified for ChaCha20Poly1305 in crypto is incorrect #4395

Closed
DCNick3 opened this issue Mar 28, 2024 · 1 comment
Closed
Assignees
Labels
Bug Something isn't working crypto iroha2-dev The re-implementation of a BFT hyperledger in RUST

Comments

@DCNick3
Copy link
Contributor

DCNick3 commented Mar 28, 2024

(identified by @Erigara)

When doing impl Encryptor for ChaCha20Poly1305 in iroha_crypto, we currently specify U36 as a MinSize (which is used to error out if a message too short is passed to the decryptor).

This, however, is incorrect. In actuality, the shortest possible message we can have is 28 bytes. Here's a breakdown:

0 + 16 + 12 = 28

This results in iroha crashing when receiving short messages.

test:

#[test]
fn test() {
    let cipher = ChaCha20Poly1305::new(&ChaCha20Poly1305::key_gen().unwrap());
    let aad = b"Iroha2 AAD".to_vec();
    // Single byte as for scale enums
    let message = b"".to_vec();
    let ciphertext = cipher.encrypt_easy(&aad, &message).unwrap();
    let decrypted_message = cipher.decrypt_easy(&aad, &ciphertext).unwrap();
    assert_eq!(message, decrypted_message);
}
@DCNick3 DCNick3 added Bug Something isn't working iroha2-dev The re-implementation of a BFT hyperledger in RUST crypto labels Mar 28, 2024
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 28, 2024
@DCNick3 DCNick3 self-assigned this Mar 28, 2024
Erigara pushed a commit to DCNick3/iroha that referenced this issue Mar 29, 2024
DCNick3 added a commit that referenced this issue Mar 29, 2024
DCNick3 added a commit to DCNick3/iroha that referenced this issue Apr 1, 2024
DCNick3 added a commit to DCNick3/iroha that referenced this issue Apr 1, 2024
This allows to pass mock time sources to parts of iroha

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Apr 1, 2024
DCNick3 added a commit to DCNick3/iroha that referenced this issue Apr 1, 2024
@DCNick3
Copy link
Contributor Author

DCNick3 commented Apr 1, 2024

Fixed in #4396

@DCNick3 DCNick3 closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working crypto iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

No branches or pull requests

1 participant