I am in the midst of writing a wrapper around a crypto library and apparently I am either rustier at C than I thought or am missing some bit of Python C api that will make this all a lot easier.<br><br>Short version of my problem is that the various library routines expect to get keys and data as pointers to unsigned char with explicit length as an additional arg. This seems pretty reasonable since strings containing nulls are rather common in crypto as both input and output.
<br><br>My first thought was that things would be fairly easy in pyrex since python strings also have no problems with embedded nulls. The various crypto functions I am using are not changing the length of what is getting passed to them. After going through several iterations of ways I hoped I could manipulate these python strings into useful pointers to the data I wanted I am now feeling somewhat mixed up (and a bit frustrated at getting to the point where most of my tests work and some occasionally fail....)
<br><br>To assure myself that I am on the right track and get a fresh viewpoint untainted by the various ratholes I have crawled through to get to this point, does anyone have a suggestion for a good wrapper to my various input/ouput needs given a pythonic side that just takes in strings (which may contain embedded nulls like "\x00this is a key" or "\x00\x00x00\x00") and calls a C library using the follow two functions:
<br><br>setup_crypto(unsigned char *key, int keylen)<br>do_crypto(unsigned char *input, unsigned char *output)<br><br><br>Any suggestions as the "the pyrex way" regarding this would be greatly appreciated.<br><br>
Regards,<br><br>Jim<br><br><br>