Repository navigation
Conversation
|
Coverage decreased (-0.5%) to 88.351% when pulling 18b532126106a68cd8e734eb4b4fff03bdb85dd7 on Ms2ger:bitshift into 9a468a7 on briansmith:master. |
The bitshift-assignment in the middle of an expression is unneccesarily confusing, and in any case is not necessary if BN_BYTES is not 8. I agree to license my contributions to each file under the terms given at the top of each file I changed.
| str[i + 7] = (d >> 24) & 0xff; | ||
| } | ||
| str[i + 3] = (d >> 24) & 0xff; | ||
| #if BN_BYTES == 8 |
There was a problem hiding this comment.
Hi. AGL decided that we should avoid #if in favor of using if in these situations. I don't know if it is in the official style guide or not. Basically, we only use the preprocessor the minimal amount.
Otherwise, I agree with the main part of your change.
There was a problem hiding this comment.
That was what I did first, but then you get a warning-as-error about shifting by the width of the integer. I could try to trick that warning if you prefer.
There was a problem hiding this comment.
I see.
Let's zoom out a bit. In the Rust code, we store private keys as arrays of bytes already. For P-256 and P-384, we store them in big-endian order, for Curve25519 we store them in little-endian order. For P-256 and P-384, we take the big-endian byte arrays and convert them to an array of Limbs (Limb == GFp_Limb == BN_ULONG). Then, this function converts them into a little-endian byte array. So, you see, it is circuitous.
In the p384 branch, I have new code that builds on this code. And, in the upcoming ecdsa_verify branch I will have more code to make it easier to switch the callers of this code to pass in byte arrays instead of Limb arrays. So, it doesn't look like this code will have a long life. Maybe we should just leave it as it is, and wait for this grossness to die a natural death?
(FWIW, this isn't new code, but instead code that was inherited from BoringSSL & OpenSSL.)
|
OK, I'm going to close this. The discussion above showed why the code is the way it is; it's basically an unfortunate artifact of the BoringSSL coding style. I don't think it's worth changing just this little bit, especially because I expect soon we'll be able to get rid of this function completely. |
The bitshift-assignment in the middle of an expression is
unneccesarily confusing, and in any case is not necessary if BN_BYTES
is not 8.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.