-
Notifications
You must be signed in to change notification settings - Fork 15
Split headers: libcrux-iot additions
#363
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
Open
jschneider-bensch
wants to merge
7
commits into
AeneasVerif:protz/split-headers
Choose a base branch
from
jschneider-bensch:jonas/split-headers-additions
base: protz/split-headers
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c5e82db
`core.h`: Add definition for `core_num__u32__rotate_left`
jschneider-bensch 854c69d
`slice.h`: Add macro definition `core_array___Array_T__N___as_mut_slice`
jschneider-bensch 7768abc
`slice.h`: Add macro definition `Eurydice_slice_eq_shared`
jschneider-bensch 18033fc
`core.h`: Update bit ops names, make first operand `const uint8_t*`
jschneider-bensch 788f967
`core.h`: Add macro definition `core_option__core__option__Option_T__…
jschneider-bensch a33b4d4
`slice.h`: Include `string.h`
jschneider-bensch e2fee0e
`core.h`: Add assertions on shift operand size
jschneider-bensch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this function can be called with x1 == 32 (and I think it can), then your implementation exercises undefined behavior in C (which is bad)
for instance, a well-defined Rust program such as
fn main () { assert_eq!(1u32.rotate_left(64), 1) }will generate undefined behavior hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, is it because of the
<<? Would it help toassert(x1 < 32)?And the same would apply to
core_num__u64__rotate_leftas well, I assume (where x1 should be less than 64).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, shifting by widths greater or equal than the bit width of the type is undefined behavior in C
consider the following Rust program:
if you compile and run it in Rust, you get a successful execution
Unfortunately no, because if you compile the program above to C via Eurydice, using your suggestion of adding an assert, the program will start crashing.
You cannot assume that x1 is < 64 because callers are legally allowed to pick x1 == 64; instead, the implementation must be able to deal with any x1 (because Rust's rotate_left behaves that way).
There are way to implement a rotate macro efficiently for cryptographic libraries. I think there's one called
rotlin OpenSSL. Let's see what they do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also an intrinsic apparently on some toolchains/platforms: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/rotl-rotl64-rotr-rotr64?view=msvc-170