X-Git-Url: https://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=ctypescrypto%2Fcms.py;h=f7e5e166325cf4f057e3dc5d3b55addd8e7ea7d1;hb=0b71a493c4661ee64d8ec27c364c01af11e80737;hp=bc27e9e34f8d14cd09e63e6343fc8465610ba755;hpb=287e8a5b1d7f5a8129619f733adbfc8b2de3e4c7;p=oss%2Fctypescrypto.git diff --git a/ctypescrypto/cms.py b/ctypescrypto/cms.py index bc27e9e..f7e5e16 100644 --- a/ctypescrypto/cms.py +++ b/ctypescrypto/cms.py @@ -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) @@ -140,7 +142,7 @@ class SignedData(CMSBase): raise ValueError("Specified keypair has no private part") if cert.pubkey != pkey: raise ValueError("Certificate doesn't match public key") - if libcrypto.CMS_sign_add1_Signer(self.ptr, cert.cert, pkey.ptr, + if libcrypto.CMS_add1_signer(self.ptr, cert.cert, pkey.ptr, digest_type.digest, flags) is None: raise CMSError("adding signer") if flags & Flags.REUSE_DIGEST == 0: @@ -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 @@ -325,8 +329,8 @@ libcrypto.CMS_get1_certs.restype = c_void_p libcrypto.CMS_get1_certs.argtypes = (c_void_p, ) libcrypto.CMS_sign.restype = c_void_p libcrypto.CMS_sign.argtypes = (c_void_p, c_void_p, c_void_p, c_void_p, c_uint) -libcrypto.CMS_sign_add1_Signer.restype = c_void_p -libcrypto.CMS_sign_add1_Signer.argtypes = (c_void_p, c_void_p, c_void_p, +libcrypto.CMS_add1_signer.restype = c_void_p +libcrypto.CMS_add1_signer.argtypes = (c_void_p, c_void_p, c_void_p, c_void_p, c_uint) libcrypto.CMS_verify.restype = c_int libcrypto.CMS_verify.argtypes = (c_void_p, c_void_p, c_void_p, c_void_p,