Latest update.
This commit is contained in:
+31
-21
@@ -14,7 +14,7 @@
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/cms.h>
|
||||
#include "cms_lcl.h"
|
||||
#include "cms_local.h"
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(CMS_ContentInfo)
|
||||
IMPLEMENT_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
|
||||
@@ -39,15 +39,16 @@ CMS_ContentInfo *cms_Data_create(void)
|
||||
BIO *cms_content_bio(CMS_ContentInfo *cms)
|
||||
{
|
||||
ASN1_OCTET_STRING **pos = CMS_get0_content(cms);
|
||||
if (!pos)
|
||||
|
||||
if (pos == NULL)
|
||||
return NULL;
|
||||
/* If content detached data goes nowhere: create NULL BIO */
|
||||
if (!*pos)
|
||||
if (*pos == NULL)
|
||||
return BIO_new(BIO_s_null());
|
||||
/*
|
||||
* If content not detached and created return memory BIO
|
||||
*/
|
||||
if (!*pos || ((*pos)->flags == ASN1_STRING_FLAG_CONT))
|
||||
if (*pos == NULL || ((*pos)->flags == ASN1_STRING_FLAG_CONT))
|
||||
return BIO_new(BIO_s_mem());
|
||||
/* Else content was read in: return read only BIO for it */
|
||||
return BIO_new_mem_buf((*pos)->data, (*pos)->length);
|
||||
@@ -108,7 +109,8 @@ BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont)
|
||||
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio)
|
||||
{
|
||||
ASN1_OCTET_STRING **pos = CMS_get0_content(cms);
|
||||
if (!pos)
|
||||
|
||||
if (pos == NULL)
|
||||
return 0;
|
||||
/* If embedded content find memory BIO and set content */
|
||||
if (*pos && ((*pos)->flags & ASN1_STRING_FLAG_CONT)) {
|
||||
@@ -234,13 +236,14 @@ const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms)
|
||||
int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid)
|
||||
{
|
||||
ASN1_OBJECT **petype, *etype;
|
||||
|
||||
petype = cms_get0_econtent_type(cms);
|
||||
if (!petype)
|
||||
if (petype == NULL)
|
||||
return 0;
|
||||
if (!oid)
|
||||
if (oid == NULL)
|
||||
return 1;
|
||||
etype = OBJ_dup(oid);
|
||||
if (!etype)
|
||||
if (etype == NULL)
|
||||
return 0;
|
||||
ASN1_OBJECT_free(*petype);
|
||||
*petype = etype;
|
||||
@@ -250,10 +253,11 @@ int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid)
|
||||
int CMS_is_detached(CMS_ContentInfo *cms)
|
||||
{
|
||||
ASN1_OCTET_STRING **pos;
|
||||
|
||||
pos = CMS_get0_content(cms);
|
||||
if (!pos)
|
||||
if (pos == NULL)
|
||||
return -1;
|
||||
if (*pos)
|
||||
if (*pos != NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -261,8 +265,9 @@ int CMS_is_detached(CMS_ContentInfo *cms)
|
||||
int CMS_set_detached(CMS_ContentInfo *cms, int detached)
|
||||
{
|
||||
ASN1_OCTET_STRING **pos;
|
||||
|
||||
pos = CMS_get0_content(cms);
|
||||
if (!pos)
|
||||
if (pos == NULL)
|
||||
return 0;
|
||||
if (detached) {
|
||||
ASN1_OCTET_STRING_free(*pos);
|
||||
@@ -362,12 +367,13 @@ CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms)
|
||||
{
|
||||
STACK_OF(CMS_CertificateChoices) **pcerts;
|
||||
CMS_CertificateChoices *cch;
|
||||
|
||||
pcerts = cms_get0_certificate_choices(cms);
|
||||
if (!pcerts)
|
||||
if (pcerts == NULL)
|
||||
return NULL;
|
||||
if (!*pcerts)
|
||||
if (*pcerts == NULL)
|
||||
*pcerts = sk_CMS_CertificateChoices_new_null();
|
||||
if (!*pcerts)
|
||||
if (*pcerts == NULL)
|
||||
return NULL;
|
||||
cch = M_ASN1_new_of(CMS_CertificateChoices);
|
||||
if (!cch)
|
||||
@@ -384,8 +390,9 @@ int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert)
|
||||
CMS_CertificateChoices *cch;
|
||||
STACK_OF(CMS_CertificateChoices) **pcerts;
|
||||
int i;
|
||||
|
||||
pcerts = cms_get0_certificate_choices(cms);
|
||||
if (!pcerts)
|
||||
if (pcerts == NULL)
|
||||
return 0;
|
||||
for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++) {
|
||||
cch = sk_CMS_CertificateChoices_value(*pcerts, i);
|
||||
@@ -439,15 +446,16 @@ CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms)
|
||||
{
|
||||
STACK_OF(CMS_RevocationInfoChoice) **pcrls;
|
||||
CMS_RevocationInfoChoice *rch;
|
||||
|
||||
pcrls = cms_get0_revocation_choices(cms);
|
||||
if (!pcrls)
|
||||
if (pcrls == NULL)
|
||||
return NULL;
|
||||
if (!*pcrls)
|
||||
if (*pcrls == NULL)
|
||||
*pcrls = sk_CMS_RevocationInfoChoice_new_null();
|
||||
if (!*pcrls)
|
||||
if (*pcrls == NULL)
|
||||
return NULL;
|
||||
rch = M_ASN1_new_of(CMS_RevocationInfoChoice);
|
||||
if (!rch)
|
||||
if (rch == NULL)
|
||||
return NULL;
|
||||
if (!sk_CMS_RevocationInfoChoice_push(*pcrls, rch)) {
|
||||
M_ASN1_free_of(rch, CMS_RevocationInfoChoice);
|
||||
@@ -482,8 +490,9 @@ STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms)
|
||||
CMS_CertificateChoices *cch;
|
||||
STACK_OF(CMS_CertificateChoices) **pcerts;
|
||||
int i;
|
||||
|
||||
pcerts = cms_get0_certificate_choices(cms);
|
||||
if (!pcerts)
|
||||
if (pcerts == NULL)
|
||||
return NULL;
|
||||
for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++) {
|
||||
cch = sk_CMS_CertificateChoices_value(*pcerts, i);
|
||||
@@ -510,8 +519,9 @@ STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms)
|
||||
STACK_OF(CMS_RevocationInfoChoice) **pcrls;
|
||||
CMS_RevocationInfoChoice *rch;
|
||||
int i;
|
||||
|
||||
pcrls = cms_get0_revocation_choices(cms);
|
||||
if (!pcrls)
|
||||
if (pcrls == NULL)
|
||||
return NULL;
|
||||
for (i = 0; i < sk_CMS_RevocationInfoChoice_num(*pcrls); i++) {
|
||||
rch = sk_CMS_RevocationInfoChoice_value(*pcrls, i);
|
||||
|
||||
Reference in New Issue
Block a user