-
Notifications
You must be signed in to change notification settings - Fork 264
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
Internal "unsoundness" in sign_ecdsa_with_noncedata_pointer
#481
Comments
I think it'd be simpler to just mark it Alternately: making the function |
Actually, we can! rustc would complain if we couldn't but it doesn't complain. Yes this is a documented feature, guaranteed to be correct. Edit: I believe even if this wasn't true converting option would've been better. |
Ok, nice. Concept ACK doing this. I can PR if you'd like, though if you're up for it that might be faster :) |
Got a bunch of things to do, so I probably can't sooner than in 24 hours. |
So, we can't actually change the FFI signature to take a I can certainly clean up the unsafety but I don't see a way to use the nullable pointer trick. |
An internal function had a non-unsafe signature but could be called with data that would cause it to exhibit UB. Move the unsafety inside of the function so that the function signature now enforces soundness. Fixes rust-bitcoin#481
Ah, good point. |
0f29348 move some unsafe code inside an unsafe{} boundary (Andrew Poelstra) Pull request description: An internal function had a non-unsafe signature but could be called with data that would cause it to exhibit UB. Move the unsafety inside of the function so that the function signature now enforces soundness. Fixes #481 Top commit has no ACKs. Tree-SHA512: b1ffc643aa11e9c8d0b7a32965a1504da14f6ac3f9e0aa175d2c09d7d7b6bf84e228f64e1f57800d75500e2c65066a4991f0070a3a1d0a19c1bd84ca0dd44363
While
sign_ecdsa_with_noncedata_pointer
is private so consumers can't cause UB in safe code it's still considered wrong to not mark the functionunsafe
because it's confusing. From my understanding such issue caused horrible flamewar atactix-web
crate.Given that the function is called either with
&[u8; 32]
or null pointer I propose to change it to acceptOption<&[u8; 32]>
instead. Internally, it does the same thing thanks to layout optimizations but is safer. We supply null pointer if there isNone
and the pointer obtained from reference if there isSome
.The text was updated successfully, but these errors were encountered: