Repository navigation
Conversation
There was a problem hiding this comment.
BN_BLINDING_new() might return NULL. We need to check that.
The Mutex will only become poisoned if some code panics while it is holding the mutex, right? And, (1) we avoid holding the mutex for a long time, and (2) we avoid panicing as much as possible. So, this can basically never happen, right? If you agree, I am fine with panicing on a poisoned mutex. |
Well, first, I'm not sure such a test is necessary. But, if we want to do it, we could create a C function |
I usually don't do that. Instead I would do them at the module level in the |
|
Coverage increased (+0.02%) to 89.948% when pulling 99d19e480eec75c7d9af0b35282091a135762c87 on ranweiler:issue234-rsa-blinding-reuse into 08c729e on briansmith:master. |
I agree with this. |
I really like the idea of only touching the Since with either approach we're relying on manual inspection for the correctness of |
I'm going to move them to the module level to be less surprising, as I don't have an actual reason to make them function local. |
|
Coverage decreased (-0.3%) to 89.615% when pulling dacdf61e3a8bab83849ba638465dacfae9bede94 on ranweiler:issue234-rsa-blinding-reuse into 08c729e on briansmith:master. |
That's fine with me. I think this is a good strategy because I think it will motivate somebody to convert I see that you made a bunch of fixes to the code. Could you please fold them into the original commits that they are relevant to? e.g. Fold "Check for Thanks! |
We will use this when testing to ensure that foreign blinding management and recreation occurs as expected. I agree to license my contributions to each file under the terms given at the top of each file I changed.
dacdf61 to
4bdeffc
Compare
Squashed and force pushed, continuing with remaining work. |
|
Coverage decreased (-0.3%) to 89.653% when pulling 4bdeffc9c0bb1818387ae94b668d597e07420419 on ranweiler:issue234-rsa-blinding-reuse into f87e2e8 on briansmith:master. |
There was a problem hiding this comment.
Please change the C definition to use uint32_t instead of unsigned just out of an abundance of caution.
In anticipation of testing blinding reuse, we want to be able to detect field-level updates to the C data. Encode the C fields in our Rust type so we can observe that the counter is updated correctly. I agree to license my contributions to each file under the terms given at the top of each file I changed.
We want to save blindings and reuse them, relying on the C code to update and recreate them as needed. Prepare for this by adding an `RSAKeyPair` field that lets us save a mutex-protected pointer to the blinding, and make sure we free its referent when the keypair drops. I agree to license my contributions to each file under the terms given at the top of each file I changed.
Note: the existing test only checks that the blinding counter is incremented modulo `BN_BLINDING_COUNTER`, which does not imply that the actual `A` and `Ai` values are updated when the counter is reset. I agree to license my contributions to each file under the terms given at the top of each file I changed.
I agree to license my contributions to each file under the terms given at the top of each file I changed.
d8742d2 to
a0f4f69
Compare
| for _ in 0 .. GFp_BN_BLINDING_COUNTER + 1 { | ||
| let prev_counter = unsafe { | ||
| let blinding = *(key_pair.blinding.lock().unwrap()); | ||
| (*blinding).counter |
There was a problem hiding this comment.
Since the type annotations for blinding ended up being unnecessary, we could make this a one-liner, as well as the similar line below. I tried it and found it less readable, but don't feel strongly about it.
There was a problem hiding this comment.
When I commit this, I'm going to move the let blinding... out of the unsafe block. Our convention is to only put lines in the unsafe block if they are required to be unsafe.
There was a problem hiding this comment.
Oh...maybe not, because then I'd need another block, I think. Never mind.
|
@briansmith, comments addressed and squashed into the relevant commits. |
|
Great. Are you the copyright holder on this? If not, who is? And do you have permission to license it? (Same questions I ask everybody.) |
I am the copyright holder, and I do have permission to license it. I hereby assign copyright in this code to the project, to be licensed under the same terms as the rest of the code. |
Closes #234.
Todo:
Mutex-wrapped pointer toBN_BLINDINGinRSAKeyPairBN_BLINDING_COUNTERas an externGFp_BN_BLINDING_COUNTERBN_BLINDINGat leastGFp_BN_BLINDING_COUNTER+1 times, to exercise all the code paths in blinding.ctest_agreement_suite_b_ecdh_generate, where theRANDreturns unusable values forever, to test the logic where the blinding gives up after a bunch of tries.BN_BLINDINGcoverage via coveralls reportQuestions:
How do we want to handle a poisonedMutex? Right now this work just propagates a panic withunwrap().We agreed that a poisoned mutex warrants a panic.
Right now the blinding reuse test is inadequate— it only checks that theBN_BLINDINGcounter is updated. Ideally we'd check that the actualAandAiblinding values have been regenerated when the counter is reset. What's the "cheapest" way to do this, wrt minimizing extraneous FFI work in this PR?We are accepting the committed
BN_BLINDINGsync burden in exchange for the level of assurance offered by checking the counter, and stopping there for now.There is a function-localextern(forGFp_BN_BLINDING_COUNTER) anduse(forBN_BLINDING) intest_signature_rsa_pkcs1_sign_blinding_reuse. We should make sure we're happy with that code style.Reverted to module-level imports.