summaryrefslogtreecommitdiff
path: root/contrib/smimeplus.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/smimeplus.py')
-rw-r--r--contrib/smimeplus.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/contrib/smimeplus.py b/contrib/smimeplus.py
index 57adb50..2cb7fd7 100644
--- a/contrib/smimeplus.py
+++ b/contrib/smimeplus.py
@@ -17,7 +17,7 @@ class smimeplus(object):
self.setcacert(cacert)
self.randfile = randfile
self.__loadrand()
-
+
def __passcallback(self, v):
"""private key passphrase callback function"""
return self.passphrase
@@ -43,7 +43,7 @@ class smimeplus(object):
return _data
def __pack(self, msg):
- """Convert 'msg' to string and put it into an memory buffer for
+ """Convert 'msg' to string and put it into an memory buffer for
openssl operation"""
return M2Crypto.BIO.MemoryBuffer(self.__gettext(msg))
@@ -72,7 +72,7 @@ class smimeplus(object):
def verify(self, smsg, scert):
"""Verify to see if 'smsg' was signed by 'scert', and scert was
- issued by cacert of this object. Return message signed if success,
+ issued by cacert of this object. Return message signed if success,
None otherwise"""
# Load signer's cert.
_x509 = M2Crypto.X509.load_cert_bio(self.__pack(scert))
@@ -89,7 +89,7 @@ class smimeplus(object):
_sender = M2Crypto.SMIME.SMIME()
_sender.set_x509_stack(_stack)
_sender.set_x509_store(_store)
-
+
# Load signed message, verify it, and return result
_p7, _data = M2Crypto.SMIME.smime_load_pkcs7_bio(self.__pack(smsg))
try:
@@ -100,23 +100,23 @@ class smimeplus(object):
def encrypt(self, rcert, msg):
# Instantiate an SMIME object.
_sender = M2Crypto.SMIME.SMIME()
-
+
# Load target cert to encrypt to.
_x509 = M2Crypto.X509.load_cert_bio(self.__pack(rcert))
_stack = M2Crypto.X509.X509_Stack()
_stack.push(_x509)
_sender.set_x509_stack(_stack)
-
+
_sender.set_cipher(M2Crypto.SMIME.Cipher(self.cipher))
-
+
# Encrypt the buffer.
_buf = self.__pack(self.__gettext(msg))
_p7 = _sender.encrypt(_buf)
-
+
# Output p7 in mail-friendly format.
_out = self.__pack('')
_sender.write(_out, _p7)
-
+
# Save the PRNG's state.
self.__saverand()
@@ -129,10 +129,10 @@ class smimeplus(object):
_sender = M2Crypto.SMIME.SMIME()
_sender.load_key_bio(self.__pack(self.key), self.__pack(self.cert),
callback=self.__passcallback)
-
+
# Load the encrypted data.
_p7, _data = M2Crypto.SMIME.smime_load_pkcs7_bio(self.__pack(emsg))
-
+
# Decrypt p7.
try:
return _sender.decrypt(_p7)