[pyOpenSSL] hit an error while passing python string with embedded NUL byte(s) to OpenSSL.crypto.sign method
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Fri Oct 28 05:26:38 CEST 2011
On 27 Oct, 11:07 pm, carsun_c at yahoo.com wrote:
>With pyOpenSSL 0.13, passing a python string with embedded NUL byte(s)
>to crypto.sign method will generate an error saying "must be string
>without null bytes, not str".
>
>Initially I thought the API is meant to support C-string (NUL-
>terminated) only, though it isn't explicitly mentioned in the
>documentation, above error seems to say so. However, looking into the
>crypto_sign function (within "crypto.c"), that doesn't seem to be the
>case, as the format string being used (enclosed below) put a "#" right
>after BYTESTRING_FMT...
>
>"O!" BYTESTRING_FMT "#s:sign"
>
>
>Unsurprisingly, once I modify the format string to "O!s#s:sign",
>signing a python string with embedded NUL byte(s) works perfectly fine.
>
>Am I over looking something? or is this a bug?
This sounds like a bug that was fixed in 0.13:
https://bugs.launchpad.net/pyopenssl/+bug/653830
Can you double check that you observed the problem with that version and
not an earlier version?
BYTESTRING_FMT is defined as "s" on Python 2.x, so your change shouldn't
have made any difference. If you were using an older version of
pyOpenSSL before, though, and then switched to a custom build based on
0.13, that would explain why it started working (it would have worked
without the edit, too).
If this isn't the case, a minimal reproducing example would be nice,
perhaps attached to a new bug report in Launchpad.
Thanks,
Jean-Paul
More information about the pyopenssl-users
mailing list