Skip to content

Conversation

@tarcieri
Copy link
Member

Pushes the unsafety down to the hybrid-array level, using the newly added Array::slice_as_flattened.

Also adds forbid(unsafe_code).

@tarcieri tarcieri requested a review from newpavlov September 23, 2025 15:39
@tarcieri
Copy link
Member Author

Spot checking this for RustCrypto/hybrid-array#148

Pushes the unsafety down to the `hybrid-array` level, using the newly
added `Array::slice_as_flattened`.

Also adds `forbid(unsafe_code)`.
@tarcieri tarcieri force-pushed the block-padding/remove-unsafe-usage branch from 3b89259 to 7084f59 Compare September 23, 2025 16:49
@tarcieri
Copy link
Member Author

@newpavlov updated to use hybrid-array v0.4.3

Comment on lines +83 to +84
// Note: `res_len` is always smaller or equal to `bs * blocks.len()`
Ok(&Array::slice_as_flattened(blocks)[..res_len])
Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps we could do something like this instead?

Suggested change
// Note: `res_len` is always smaller or equal to `bs * blocks.len()`
Ok(&Array::slice_as_flattened(blocks)[..res_len])
Array::slice_as_flattened(blocks).get(..res_len).ok_or(UnpadError)

Copy link
Member

Choose a reason for hiding this comment

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

If res_len is bigger than data.len() than it's a bug, so we should panic.

@newpavlov
Copy link
Member

Closing in favor of #1222.

@newpavlov newpavlov closed this Sep 23, 2025
@newpavlov newpavlov deleted the block-padding/remove-unsafe-usage branch September 24, 2025 12:58
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