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

feat: make chunk size user defined #391

Closed
wants to merge 1 commit into from
Closed

Conversation

joshuef
Copy link
Contributor

@joshuef joshuef commented Oct 15, 2024

BEAKING CHANGE: all APIs updated to have min/max_encryptrable bytes passed in by the user.

This allows for varying the use of the lib.

BEAKING CHANGE: all APIs updated to have min/max_encryptrable bytes
passed in by the user.

This allows for varying the use of the lib.
@joshuef joshuef marked this pull request as ready for review October 15, 2024 04:00
@joshuef joshuef requested a review from a team as a code owner October 15, 2024 04:00
@@ -411,16 +407,21 @@ pub fn decrypt_from_chunk_files(
/// Encrypts a set of bytes and returns the encrypted data together with
/// the data map that is derived from the input data, and is used to later decrypt the encrypted data.
/// Returns an error if the size is too small for self-encryption.
/// Only files larger than 3072 bytes (3 * MIN_CHUNK_SIZE) can be self-encrypted.
/// Only files larger than 3072 bytes (3 * min_chunk_size) can be self-encrypted.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the number of 3072 shall be changed (same to the other place)

@@ -51,6 +51,11 @@ use std::time::Duration;
// https://bheisler.github.io/criterion.rs/book/analysis.html#measurement
const SAMPLE_SIZE: usize = 20;

/// The maximum size (before compression) of an individual chunk of a file, defined as 1024kiB.
const MAX_CHUNK_SIZE: usize = 1024 * 1024;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better make these two as consts for test usage only ?
as I see they got used in couple of testing places

pos: usize,
len: usize,
max_chunk_size: usize,
) -> (usize, usize) {
// FIX THIS SHOULD NOT BE ALLOWED
if file_size < (3 * MIN_CHUNK_SIZE) || pos >= file_size || len == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there shall no longer be a const of MIN_CHUNK_SIZE in production code anymore ?

@dirvine dirvine closed this Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants