Closed mpeylo closed 5 years ago
fixed in 84b6bb67ed0ab73f633e87e3b1c233a3c330bcf7
Glad that you've been able to fix this already!
In retrospect, very strange that EVP_PKEY_size(pkey)
apparently was sufficient when compilation was done using --debug
, since the signature size for EC is not the same as the key size, but double of that.
It turns out that the API of EVP_DigestSign*
is even more awkward than what its documentation suggests :-(
And even the knowledgeable reviewers of our branch didn't notice this pitfall.
Actually, that EVP_PKEY_size(pkey) result was completely irrelevant.
Note the following hidden in EVP_DigestSignInit.pod - a bit misleading with the "should" I guess.
If sig is not NULL then before the call the siglen parameter should contain the length of the sig buffer.
Ah, so sig_len
was used without initialization, and it was just luck that most times it worked.
Thank you @mpeylo - this thread is one of the few places on the Internet where this bug was talked about, and it pointed me to the exact problem. I assumed I should pass a size of 0 in, and that it would be ignored and reset to the output parameter. But no - once I set that to my max buffer size, life was good.
After 795706a0a1c PoP for EC and RSA keys is not working anymore when building without --debug flag
Validated with rebase at d616bb6611a4e3ddeb6dabb563813b384c429ee5 that nothing related to this issue would have been fixed by upstream within a month.