[pyOpenSSL] hit an error while passing python string with embedded NUL byte(s) to OpenSSL.crypto.sign method

CarSun C carsun_c at yahoo.com
Fri Oct 28 01:07:59 CEST 2011


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?

Would appreciate your feedback

- c

Below is the signature of the sign method
sign(key, data, digest)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pyopenssl-users/attachments/20111027/93eb37af/attachment.html>


More information about the pyopenssl-users mailing list