started with py crypto, enhanced raw.py generation, better autoconf integration

This commit is contained in:
git@daemon.de
2014-12-22 16:22:52 +01:00
parent 28a0405d55
commit 45c5daae54
11 changed files with 496 additions and 150 deletions

View File

@@ -0,0 +1,29 @@
from pypcp.dll import *
from pypcp.context import *
class PublicKey(object):
def __init__(self, pk=None, encoded=None):
self._pk = None
if pk:
self._pk = pk
elif encoded:
self.importkey(Context(), encoded)
else:
self._pk = ffi.new("struct _pcp_pubkey_t*")
for key, value in convert_to_python(self._pk).iteritems():
self.__setattr__(key, value)
def importkey(self, context, encoded=None):
ks = libpcp.pcp_import_pub(context._ctx, encoded, len(encoded))
if not ks:
context.throw(IOError, "failed to import key")
self._pk = ks.p
def dump(self):
if self._pk:
libpcp.pcp_dumppubkey(self._pk)
def __dict__(self):
return convert_to_python(self._pk)