From 5e79220ede7efe3bf4703344c7963049a6e71545 Mon Sep 17 00:00:00 2001 From: Victor Wagner Date: Thu, 5 Jun 2014 17:41:25 +0400 Subject: [PATCH] callback implemented --- README.md | 48 +++++++++++++++++++---- ctypescrypto/pkey.py | 22 ++++++++--- tests/testpkey.py | 90 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 tests/testpkey.py diff --git a/README.md b/README.md index 91336ba..9abd63b 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,45 @@ It is aimed to provide Python interface to OpenSSL libcrypto function Now supported: -Digests -Ciphers -Low-level private key operations (like pkey and pkeyutl command line ops) -(all via algorithm-agnostic EVP interface). -Engine loading -OpenSSL error stack to python exception conversion -X509 certificates partially +bio.py - interfase to OpenSSL stream abstraction BIO. Now supports + memory BIOs this module intended to use for parsing/serializing + various ASN.1 based formats like private keys or certificates + Status: bare minimum functionality is implemented and covered by + rests + +oid.py - interface to OpenSSL ASN.1 Object Identifier databsase. + Allows to convert numeric identifier (NIDs) returned by various + OpenSSL function to readable names or dotted-decimal OIDs and back + Status: Fully implemented and covered by tests. + +engine.py - interface to loadable modules with alternate implementations + of cryptoalgorithms. + Status: Bare minumum, neccessary to use GOST algorithms is + implemented. + +rand.py - interface to pseudo-random number generator. + Status: Implemented. Tests now only ensure that no segfault occurs + if arugments are passed correctly + +digests.py - Interface to EVP\_Digest\* family of functions. + Really does almost same as hashlib, which even is able to take + advantage of loaded engines if compiled against dynamic libcrypto + Status: fully implemented and covered by tests + +ciphers.py - Interface to EVP\_Cipher family of function. + Status: Needs complete rewriting and test coverage. Idea to keep + cleartext in python variable until entire text would be passed to + update is EVIL. + +pkey.py - Low-level private key operations (like pkey, genpkey and p + keyutl command line ops), all via algorithm-agnostic EVP interface. + Status: Designed and mostly implemented but not yet covered by tests + +exception.py OpenSSL error stack to python exception conversion + Implemented. + +x509 X509 certificates. Support parsing of X509 certificates, + verification and extracting of field values. Possible extnesion - + support creattion of PKCS10 certificate requests. + Status: Interface designed and partially implemented diff --git a/ctypescrypto/pkey.py b/ctypescrypto/pkey.py index d5e09ce..676d324 100644 --- a/ctypescrypto/pkey.py +++ b/ctypescrypto/pkey.py @@ -6,6 +6,16 @@ from ctypescrypto.bio import Membio class PKeyError(LibCryptoError): pass +CALLBACK_FUNC=CFUNCTYPE(c_int,c_char_p,c_int,c_int,c_char_p) +def password_callback(buf,length,rwflag,u) + cnt=len(u) + if length