]> www.wagner.pp.ru Git - oss/ctypescrypto.git/blobdiff - ctypescrypto/cms.py
Fix error message in str
[oss/ctypescrypto.git] / ctypescrypto / cms.py
index 1e533875ded29e44f0604b7b95fffc8dca7a6f87..4250cbee3ebd66f125cf38553b7b7ba10c029243 100644 (file)
@@ -59,6 +59,8 @@ def CMS(data, format="PEM"):
         ptr = libcrypto.PEM_read_bio_CMS(bio.bio, None, None, None)
     else:
         ptr = libcrypto.d2i_CMS_bio(bio.bio, None)
+    if ptr is None:
+        raise CMSError("Error parsing CMS data")
     typeoid = Oid(libcrypto.OBJ_obj2nid(libcrypto.CMS_get0_type(ptr)))
     if typeoid.shortname() == "pkcs7-signedData":
         return SignedData(ptr)
@@ -82,7 +84,7 @@ class CMSBase(object):
         """
         bio = Membio()
         if not libcrypto.i2d_CMS_bio(bio.bio, self.ptr):
-            raise CMSError("writing CMS to PEM")
+            raise CMSError("writing CMS to DER")
         return str(bio)
 
     def pem(self):
@@ -304,6 +306,8 @@ class EncryptedData(CMSBase):
 __all__ = ['CMS', 'CMSError', 'Flags', 'SignedData', 'EnvelopedData',
            'EncryptedData']
 
+libcrypto.CMS_get0_type.restype = c_void_p
+libcrypto.CMS_get0_type.argtypes = (c_void_p,)
 libcrypto.CMS_add1_cert.restype = c_int
 libcrypto.CMS_add1_cert.argtypes = (c_void_p, c_void_p)
 libcrypto.CMS_decrypt.restype = c_int