Skip to content

Commit 921f4f1

Browse files
committed
doc nits and vec init change
1 parent 2aa93d0 commit 921f4f1

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod error;
2020
/// Contains request/response types generated from the API definition of VSS.
2121
pub mod types;
2222

23-
/// Contains helper utils for encryption, requests-retries etc.
23+
/// Contains utils for encryption, requests-retries etc.
2424
pub mod util;
2525

2626
// Encryption-Decryption related crate-only helpers.

src/util/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// Contains [`StorableBuilder`] helper utility.
1+
/// Contains [`StorableBuilder`] utility.
22
///
33
/// [`StorableBuilder`]: storable_builder::StorableBuilder
44
pub mod storable_builder;

src/util/storable_builder.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::borrow::Borrow;
77
use std::io;
88
use std::io::{Error, ErrorKind};
99

10-
/// [`StorableBuilder`] is a helper utility to build and deconstruct [`Storable`] objects.
11-
/// It provides client-side `Encrypt-then-MAC` using ChaCha20-Poly1305.
10+
/// [`StorableBuilder`] is a utility to build and deconstruct [`Storable`] objects.
11+
/// It provides client-side Encrypt-then-MAC using ChaCha20-Poly1305.
1212
pub struct StorableBuilder {
1313
data_encryption_key: [u8; 32],
1414
}
@@ -18,22 +18,20 @@ const CHACHA20_CIPHER_NAME: &'static str = "ChaCha20Poly1305";
1818
impl StorableBuilder {
1919
/// Creates a [`Storable`] that can be serialized and stored as `value` in [`PutObjectRequest`].
2020
///
21-
/// Uses ChaCha20 for encrypting the `input` and Poly1305 for generating mac/tag.
21+
/// Uses ChaCha20 for encrypting `input` and Poly1305 for generating a mac/tag.
2222
///
2323
/// Refer to docs on [`Storable`] for more information.
2424
///
2525
/// [`PutObjectRequest`]: crate::types::PutObjectRequest
2626
pub fn build(&self, input: Vec<u8>, version: i64) -> Storable {
2727
let mut rng = ThreadRng::default();
28-
let mut nonce = Vec::with_capacity(12);
29-
nonce.resize(12, 0u8);
28+
let mut nonce = vec![0u8; 12];
3029
rng.fill_bytes(&mut nonce[4..]);
3130

3231
let mut data_blob = PlaintextBlob { value: input, version }.encode_to_vec();
3332

3433
let mut cipher = ChaCha20Poly1305::new(&self.data_encryption_key, &nonce, &[]);
35-
let mut tag = Vec::with_capacity(16);
36-
tag.resize(16, 0u8);
34+
let mut tag = vec![0u8; 16];
3735
cipher.encrypt_inplace(&mut data_blob, &mut tag);
3836
Storable {
3937
data: data_blob,

0 commit comments

Comments
 (0)