[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-11 Thread David Wood
Change by David Wood : Removed file: https://bugs.python.org/file49861/crypt.tar.gz ___ Python tracker ___ ___ Python-bugs-list mailing

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-10 Thread Christian Heimes
Christian Heimes added the comment: Don't feel bad about it. Nintendo made a very similar mistake. The trucha bug made it trivial to bypass DRM of Wii games. -- ___ Python tracker

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-10 Thread David Wood
David Wood added the comment: Christian/Eric - Thank you both so much for taking time on this. Christian had pointed out the use of memcpy vs strncpy. It turns out that while strncpy is designed to copy a specific number of chars, it turns out that it stops on null. I did make the

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-10 Thread Christian Heimes
Christian Heimes added the comment: Could you please give us an example for an incorrect output and corresponding correct output as bytes representation? -- ___ Python tracker

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-09 Thread David Wood
Change by David Wood : Removed file: https://bugs.python.org/file49862/crypt.tar.gz ___ Python tracker ___ ___ Python-bugs-list mailing

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-09 Thread David Wood
David Wood added the comment: Attached are the basic files. As you can see in the example test9.py, I am generating a random string, encrypting it, decrypting it, and comparing the decrypted result with the original value. This is intended to run on linux and requires the mcrypt library

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-09 Thread David Wood
Change by David Wood : Added file: https://bugs.python.org/file49862/crypt.tar.gz ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-09 Thread Christian Heimes
Christian Heimes added the comment: A sleep(1) call affects exactly one aspect of the program: the state of the PRNG rand(). You re-initialize the process globale RNG in every function call with srand((unsigned) time()). time() has a granularity of one second. --

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-09 Thread Eric V. Smith
Eric V. Smith added the comment: David: If you could give us an example showing the inputs, the actual outputs, and how they differ from what you expect, that would be helpful. Otherwise it's a lot of guessing on our part. -- nosy: +eric.smith

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-08 Thread David Wood
David Wood added the comment: Still no bueno. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-08 Thread Christian Heimes
Christian Heimes added the comment: Py_BuildValue("y#", output, count) is equivalent to PyBytes_FromStringAndSize(output, count). The function returns a copy of the input string as a new bytes object. It's very unlikely that the code is broken. It's been around for ages and it's a core

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-08 Thread David Wood
David Wood added the comment: Christian - Thank you for this. I did as you suggested however, I still have the same problem. As I pointed out in my original message, the problem does not exist if I insert a sleep(1) statement prior to returning from the function. Additional to that, I

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-08 Thread Christian Heimes
Christian Heimes added the comment: Does mcrypt_generic() output base64 or ASCII-only data? Since you are converting the output to bytes, I assume the output may contain any byte. In that case strcpy() is not safe. You have to use memcpy(). Fun fact: Nintendo had a similar bug many years

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-08 Thread David Wood
David Wood added the comment: I have not gone to the extent of comparing the direct output against what python gets, although it appears to be incomplete. The following is my encrypt function which has been used successfully for many years in a separate c program, so I have high confidence

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-08 Thread Christian Heimes
Christian Heimes added the comment: What do you mean by "incomplete"? Does it return less data or invalid data? Could you please paste your implementation of encryptBlowfishCfb(), too? -- nosy: +christian.heimes ___ Python tracker

[issue43435] Py_BuildValue("y#".... returns incomplete result

2021-03-08 Thread David Wood
New submission from David Wood : I have a c function to encrypt values which returns an array of bytes. The function returns proper values outside of python. When used as a python function, the result is incomplete usually 10-20% of the time. If I add a sleep(1) call before returning from