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

crypto.blowfish: apply @[direct_array_access] to very commonly used functions #21771

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vlib/crypto/blowfish/block.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module blowfish

// expand_key performs a key expansion on the given Blowfish cipher.
@[direct_array_access]
pub fn expand_key(key []u8, mut bf Blowfish) {
mut j := 0
for i := 0; i < 18; i++ {
@@ -41,6 +42,7 @@ pub fn expand_key(key []u8, mut bf Blowfish) {
}

// expand_key_with_salt using salt to expand the key.
@[direct_array_access]
pub fn expand_key_with_salt(key []u8, salt []u8, mut bf Blowfish) {
mut j := 0
for i := 0; i < 18; i++ {
@@ -85,6 +87,7 @@ pub fn expand_key_with_salt(key []u8, salt []u8, mut bf Blowfish) {
}

// setup_tables sets up the Blowfish cipher's pi and substitution tables.
@[direct_array_access]
fn setup_tables(l u32, r u32, mut bf Blowfish) (u32, u32) {
mut xl := l
mut xr := r
@@ -111,6 +114,7 @@ fn setup_tables(l u32, r u32, mut bf Blowfish) (u32, u32) {

// get_next_word returns the next big-endian u32 value from the byte
// slice at the given position in a circular manner, updating the position.
@[direct_array_access]
fn get_next_word(b []u8, pos &int) u32 {
mut w := u32(0)
mut j := 0