Fix prototype for CMS_decrypt(), don't free up detached content.
This commit is contained in:
parent
a5db50d005
commit
852bd35065
@ -177,7 +177,7 @@ CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,
|
|||||||
const EVP_CIPHER *cipher, unsigned int flags);
|
const EVP_CIPHER *cipher, unsigned int flags);
|
||||||
|
|
||||||
int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
|
int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
|
||||||
BIO *data, BIO *dcont,
|
BIO *dcont, BIO *out,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);
|
int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);
|
||||||
|
@ -125,6 +125,23 @@ static int check_content(CMS_ContentInfo *cms)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void do_free_upto(BIO *f, BIO *upto)
|
||||||
|
{
|
||||||
|
if (upto)
|
||||||
|
{
|
||||||
|
BIO *tbio;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
tbio = BIO_pop(f);
|
||||||
|
BIO_free(f);
|
||||||
|
f = tbio;
|
||||||
|
}
|
||||||
|
while (f != upto);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BIO_free_all(f);
|
||||||
|
}
|
||||||
|
|
||||||
int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags)
|
int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags)
|
||||||
{
|
{
|
||||||
BIO *cont;
|
BIO *cont;
|
||||||
@ -177,7 +194,7 @@ int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
|
|||||||
r = cms_copy_content(out, cont, flags);
|
r = cms_copy_content(out, cont, flags);
|
||||||
if (r)
|
if (r)
|
||||||
r = cms_DigestedData_do_final(cms, cont, 1);
|
r = cms_DigestedData_do_final(cms, cont, 1);
|
||||||
BIO_free_all(cont);
|
do_free_upto(cont, dcont);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +240,7 @@ int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,
|
|||||||
if (!cont)
|
if (!cont)
|
||||||
return 0;
|
return 0;
|
||||||
r = cms_copy_content(out, cont, flags);
|
r = cms_copy_content(out, cont, flags);
|
||||||
BIO_free_all(cont);
|
do_free_upto(cont, dcont);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,8 +428,9 @@ int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
|
|||||||
err:
|
err:
|
||||||
|
|
||||||
if (dcont && (tmpin == dcont))
|
if (dcont && (tmpin == dcont))
|
||||||
BIO_pop(cmsbio);
|
do_free_upto(cmsbio, dcont);
|
||||||
BIO_free_all(cmsbio);
|
else
|
||||||
|
BIO_free_all(cmsbio);
|
||||||
|
|
||||||
if (cms_certs)
|
if (cms_certs)
|
||||||
sk_X509_pop_free(cms_certs, X509_free);
|
sk_X509_pop_free(cms_certs, X509_free);
|
||||||
@ -678,7 +696,7 @@ int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert,
|
|||||||
if (!cont)
|
if (!cont)
|
||||||
return 0;
|
return 0;
|
||||||
r = cms_copy_content(out, cont, flags);
|
r = cms_copy_content(out, cont, flags);
|
||||||
BIO_free_all(cont);
|
do_free_upto(cont, dcont);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +724,7 @@ int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags)
|
|||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
BIO_free_all(cmsbio);
|
do_free_upto(cmsbio, dcont);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -733,7 +751,7 @@ int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
|
|||||||
if (!cont)
|
if (!cont)
|
||||||
return 0;
|
return 0;
|
||||||
r = cms_copy_content(out, cont, flags);
|
r = cms_copy_content(out, cont, flags);
|
||||||
BIO_free_all(cont);
|
do_free_upto(cont, dcont);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user