From: Victor Wagner Date: Thu, 21 Jul 2016 06:18:57 +0000 (+0400) Subject: Merge pull request #4 from ChristopherMacGown/fix_create_cms X-Git-Url: http://www.wagner.pp.ru/gitweb/?a=commitdiff_plain;h=606f6346def9e8d4fea51a3afa1df9389ad47057;hp=556afe8dc2f0bcc32247ac99b649977dd3808d33;p=oss%2Fctypescrypto.git Merge pull request #4 from ChristopherMacGown/fix_create_cms Fixes to SignedData.create. --- diff --git a/ctypescrypto/cms.py b/ctypescrypto/cms.py index 4250cbe..ede20f5 100644 --- a/ctypescrypto/cms.py +++ b/ctypescrypto/cms.py @@ -120,10 +120,10 @@ class SignedData(CMSBase): raise ValueError("Certificate doesn't match public key") bio = Membio(data) if certs is not None and len(certs) > 0: - certstack = StackOfX509(certs) + certstack = StackOfX509(certs).ptr else: certstack = None - ptr = libcrypto.CMS_sign(cert.cert, pkey.ptr, certstack, bio.bio, flags) + ptr = libcrypto.CMS_sign(cert.cert, pkey.key, certstack, bio.bio, flags) if ptr is None: raise CMSError("signing message") return SignedData(ptr) @@ -142,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_add1_signer(self.ptr, cert.cert, pkey.ptr, + if libcrypto.CMS_add1_signer(self.ptr, cert.cert, pkey.key, digest_type.digest, flags) is None: raise CMSError("adding signer") if flags & Flags.REUSE_DIGEST == 0: @@ -263,7 +263,7 @@ class EnvelopedData(CMSBase): if pkey != cert.pubkey: raise ValueError("Certificate doesn't match private key") bio = Membio() - res = libcrypto.CMS_decrypt(self.ptr, pkey.ptr, cert.ccert, None, + res = libcrypto.CMS_decrypt(self.ptr, pkey.key, cert.ccert, None, bio.bio, flags) if res <= 0: raise CMSError("decrypting CMS")