Hi
On 05/03/2015 01:00PM +0200, Phil wrote:
Hi, On Wed, Mar 04, 2015 at 05:50:35PM +0200, Tilemachos Charalampous
wrote:
>Hello. I'm an undergraduate student studying electrical and computer
>engineering at the NTUA.
>As part of an Operating Systems course, I worked a bit on the cryptodev
>module, and needed it to use it in a Pyhton project. After searching a
>bit on the Internet I couldn't find any cryptodev bindings, so I decided
>to develop them myself. I was encouraged by my instructor (Vangelis
>Koukis, Cc:ed) to develop the bindings to something more general, that
>supports the whole cryprtodev module.
Forgot the Cc or was it blind?
Apparently I did fill the Cc, but seems that something went wrong with
my client. I Cc:ed again. Hopefully it will show the Cc now.
>I have created two types of bindings. Static bindings and semi automated
>bindings. Static bindings are created based on cryptodev.h and ioctl.h
>(from my Linux system). Semi automated bindings are created using
>ctypesgen for python. I have created a simple makefile in which
>ctypesgen is used to create ioctl.py and cryptodev.py automatically into
>a Python module. The reason that I could not build fully automated
>bindings is because of a bug in ctypesgen, in which it cannot parse
>"sizeof" if the argument is defined in a different header file. You can
>see a more detailed explanation in README.md of the ctypesgen branch on
>my repository under "Why not fully automated way?" (links provided at
>the end). Also I have implemented some of your tests into Python that
>use the bindings.
>
>If you are interested, I would like to get this code included in
>mainline cryptodev. All my changes currently live at
>https://github.com/tchar/cryptodev-python/.
>Also the link for README.md, which explains the ctypesgen bug I
>mentioned is
>https://github.com/tchar/cryptodev-python/blob/ctypesgen/README.md
>The link for the ctypesgen module ishttps://code.google.com/p/ctypesgen/
Looks nice. How about submitting a patch? Do we have to keep the python
bindings themselfs or is it possible to have them generated upon 'make
dist'? I would prefer not having to keep them in sync manually. Maybe
this is related to your mention of 'semi automated bindings', but I
don't get it due to lack of experience in python/C interfaces.
Cheers, Phil
About the fully automated bindings. There are some concerns. I recently
added support for python-3 to the manual bindings. With the semi
automated bindings I am having some problems supporting python-3,
despite the fact that there is a ctyptesgen branch that generate
python-3 code. This is because I am getting some errors (python-3 syntax
errors, about the generated python-3 bindings) when running the tests.
About the semi automated bindings and using makefile: I am using a
makefile to generate the semi automated bindings. The only thing that
is needed by the semi automated way is a single file containing all
those constants from the cryptodev.h, that could not be parsed by
ctypesgen (those are defined in the fix file, link is provided below).
The rest: folders to contain the python module and the __init__.py,
could be, technically, generated automatically, or replaced by a single
cryptodev.py binding. As long as the definitions in the cryptodev.h do
not change, the manual bindings will work and as long as the definitions
in the fix file do not change, the semi automated bindings will, also,
work. Also, if supporting python 3 is not an issue at the moment, I
changed the ctypesgen branch to generate python-2 bindings, by changing
the makefile and by adding the fix file only. Unfortunately, without the
fix file I cannot, currently, generate automated bindings. If you want
just the bindings, without the tests and examples in python, I forked
the cryptodev repository from github and made those two changes (just a
preview) I described above (Makefile and the fix file). Running "make
python-bindings" will generate the bindings for you. You just need to
have ctypesgen and set the environment variable CTYPESGEN_PATH to point
to the ctypesgen folder.
The link for the automated bindings only (forked repository from
cryptodev): https://github.com/tchar/cryptodev-linux
The link for the fix file is:
https://github.com/tchar/cryptodev-python/blob/ctypesgen/crypto/python-bindings-fix.py
(from the initial repository)
or:
https://github.com/tchar/cryptodev-linux/blob/master/crypto/python-bindings-fix.py
(from the forked cryptodev repository)
Looking forward to your comments,
Tilemachos.
--
Tilemachos Charalampous
Undergraduate Student
School of Electrical and Computer Engineering
National Technical University of Athens
tilemachos.charalamp...@gmail.com
_______________________________________________
Cryptodev-linux-devel mailing list
Cryptodev-linux-devel@gna.org
https://mail.gna.org/listinfo/cryptodev-linux-devel