You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use BitLength in FFI when transparent structs are supported #345
The FFI functions use c::uint instead of usize. I don't think there's any length that would overflow u32 but on most 64-bit platforms we would still convert from u64 to u32 (I think).
The FFI functions use c::uint instead of usize. I don't think there's any length that would overflow u32 but on most 64-bit platforms we would still convert from u64 to u32 (I think).
Yes. Unfortunately it is not trivial to switch them to usize. I think we can/should just leave those function calls the way they are because there is no real risk of screwing them up the way aes.rs is now written.
In particular, I don't want to change the representation of BitLength to be c::uint. My long-term plan is to remove all uses of non-usize/size_t variable-sized integers (c::int and c::uint in particular) from the codebase.
In BoringSSL, David Benjamin did some analysis and determined that, in general, we have to be very careful in changing the int, unsigned, size_t, etc. types in assembly language function declarations. In particular, if a function is expecting an unsigned but we change the declaration to usize then it might incorrectly zero out the high bits of the argument (if usize is larger than int/unsigned). In the case of set_encrypt_key it probably doesn't matter because the valid values are well within the range of unsigned, but also I don't see a lot of value in changing the declaration.
More generally, we now very rarely pass bit lengths to the C/asm code so I don't think it's worth even thinking about this as a TODO item.
Activity
briansmith commentedon Sep 25, 2017
The rust feature is being tracked in rust-lang/rust#43036
pietro commentedon Jan 15, 2019
The FFI functions use
c::uintinstead ofusize. I don't think there's any length that would overflowu32but on most 64-bit platforms we would still convert fromu64tou32(I think).briansmith commentedon Jan 16, 2019
Yes. Unfortunately it is not trivial to switch them to
usize. I think we can/should just leave those function calls the way they are because there is no real risk of screwing them up the wayaes.rsis now written.briansmith commentedon Jan 16, 2019
In particular, I don't want to change the representation of
BitLengthto bec::uint. My long-term plan is to remove all uses of non-usize/size_tvariable-sized integers (c::intandc::uintin particular) from the codebase.pietro commentedon Jan 16, 2019
I added the
#[repr(transparent)]toBitLenghtand changed the functions onaes.rsto useBitLenghtinstead ofc::uintin pietro/ring@0db50fa.briansmith commentedon Mar 25, 2019
In BoringSSL, David Benjamin did some analysis and determined that, in general, we have to be very careful in changing the
int,unsigned,size_t, etc. types in assembly language function declarations. In particular, if a function is expecting anunsignedbut we change the declaration tousizethen it might incorrectly zero out the high bits of the argument (ifusizeis larger thanint/unsigned). In the case ofset_encrypt_keyit probably doesn't matter because the valid values are well within the range ofunsigned, but also I don't see a lot of value in changing the declaration.More generally, we now very rarely pass bit lengths to the C/asm code so I don't think it's worth even thinking about this as a TODO item.