diff options
author | Rob Austein <sra@hactrn.net> | 2011-01-09 20:28:06 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2011-01-09 20:28:06 +0000 |
commit | f05001f84d966a0b0c80b9d5212c2f3ac11d1660 (patch) | |
tree | ea34ff5b7bf803ae94f839f34f46e145209536a3 /pow/POW-0.7/pkix-m2crypto-driver.py | |
parent | a852889d670f6dd1955bb430240798d7f69d342f (diff) |
Rework POW build so that we can use static libraries again.
svn path=/configure; revision=3602
Diffstat (limited to 'pow/POW-0.7/pkix-m2crypto-driver.py')
-rw-r--r-- | pow/POW-0.7/pkix-m2crypto-driver.py | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/pow/POW-0.7/pkix-m2crypto-driver.py b/pow/POW-0.7/pkix-m2crypto-driver.py deleted file mode 100644 index 61dabac7..00000000 --- a/pow/POW-0.7/pkix-m2crypto-driver.py +++ /dev/null @@ -1,42 +0,0 @@ -# $Id$ - -"""Crypto driver for POW.pkix using M2Crypto. - -This driver is part of an attempt to salvage the (really nice) -POW.pkix code from the POW package. I like POW well enough, but it's -old and missing some pieces and the Python world seems to have moved -to M2Crypto. But M2Crypto has nothing like POW.pkix, so I whacked -together an interface to let POW.pkix run over other crypto packages. - -This module is a driver for M2Crypto. -""" - -# NB: Module names may change eventually - -import POW.pkix - -class M2CryptoCryptoDriver(POW.pkix.CryptoDriver): - """Dispatcher for crypto calls using M2Crypto package.""" - - def __init__(self): - import M2Crypto - self.driver2OID = { - "md5" : (1, 2, 840, 113549, 1, 1, 4), # md5WithRSAEncryption - "sha1" : (1, 2, 840, 113549, 1, 1, 5), # sha1withRSAEncryption - "ripemd160" : (1, 2, 840, 113549, 1, 1, 6), # ripemd160WithRSAEncryption - "sha256" : (1, 2, 840, 113549, 1, 1, 11), # sha256WithRSAEncryption - } - self.OID2driver = dict((v,k) for k,v in self.driver2OID.iteritems()) - - def sign(self, key, oid, plaintext): - digest = M2Crypto.EVP.MessageDigest(self.OID2driver[oid]) - digest.update(plaintext) - return key.sign(digest.final(), self.OID2driver[oid]) - - def verify(self, key, oid, plaintext, signature): - return key.verify(plaintext, signature, self.OID2driver[oid]) - - def keyDER(self, key): - bio = M2Crypto.BIO.MemoryBuffer() - key.save_key_der_bio(bio) - return bio.read() |