On Mon, 2021-04-12 at 14:34 +0300, Dmitry Timoshkov wrote:
Dmitry Timoshkov dmitry@baikal.ru wrote:
Hans Leidekker hans@codeweavers.com wrote:
On Mon, 2021-04-12 at 12:48 +0300, Dmitry Timoshkov wrote:
v2:
- Fixed calculation of cbPublicExp and cbModulus.
- pass PublicExp in BE format to follow MSDN.
Should the modulus also be converted to BE format?
I'm not sure, though MSDN claims that the modulus provided by PUBLICKEYBLOB is also in LE format: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-mqqb/ade9efd...
I'd guess that gnutls verifies the modulus during the key creation. If the modulus also should be converted, taking into account that its length is variable, how would you propose to handle the conversion?
Taking into account that the modulus goes straight from the certificate data, I'd guess that the conversion is not needed.
You get a PUBLICKEYBLOB which is little-endian, so you do need to convert. You have calculated cbModulus already, so you can just replace the memcpy with a loop that stores the bytes in reverse order.