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

Expand ID range to harden brute forcing #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cgzones
Copy link
Contributor

@cgzones cgzones commented Sep 22, 2024

Expand the value space from 2^32 to 2^64, resulting in keys of length 11 instead of 6.
In particular important for one-time-pastes.
i64 is used as inner type since sqlite does not support storing u64.

@matze
Copy link
Owner

matze commented Sep 23, 2024

If I see correctly, this will break all existing paste ids?

@cgzones
Copy link
Contributor Author

cgzones commented Sep 25, 2024

Added backwards compatibility.

Expand the domain for IDs from 2^32 to 2^64, resulting in keys of length
11 instead of 6.
In particular important for one-time-pastes.
i64 is used as inner type since sqlite does not support storing u64.
}

#[test]
fn convert_id_from_string() {
assert!(Id::from_str("abDE+-").is_ok());
/* Support ID generated in the old 32-bit format */
//assert!(Id::from_str("abDE+-").is_ok());
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this outcommented? Also, please use proper Rust comments, i.e. // instead of /* */.

s.push(CHAR_TABLE[(self.n & 0x3) as usize]);

write!(f, "{s}")
#[allow(clippy::cast_sign_loss)]
Copy link
Owner

Choose a reason for hiding this comment

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

🤔


/// Represents a 32-bit integer either numerically or mapped to a 6 character string.
pub type Inner = i64;
Copy link
Owner

Choose a reason for hiding this comment

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

Stupid question: what's the point of this type alias?

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.

2 participants