Make streaming support in cms cleaner.
Note errors in various S/MIME functions if CMS_final() fails.
Add streaming support for enveloped data.
char *passargin = NULL, *passin = NULL;
char *inrand = NULL;
int need_rand = 0;
char *passargin = NULL, *passin = NULL;
char *inrand = NULL;
int need_rand = 0;
const EVP_MD *sign_md = NULL;
int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
int keyform = FORMAT_PEM;
const EVP_MD *sign_md = NULL;
int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;
int keyform = FORMAT_PEM;
else if (!strcmp (*args, "-no_attr_verify"))
flags |= CMS_NO_ATTR_VERIFY;
else if (!strcmp (*args, "-stream"))
else if (!strcmp (*args, "-no_attr_verify"))
flags |= CMS_NO_ATTR_VERIFY;
else if (!strcmp (*args, "-stream"))
else if (!strcmp (*args, "-indef"))
else if (!strcmp (*args, "-indef"))
else if (!strcmp (*args, "-noindef"))
else if (!strcmp (*args, "-noindef"))
else if (!strcmp (*args, "-nooldmime"))
flags |= CMS_NOOLDMIMETYPE;
else if (!strcmp (*args, "-crlfeol"))
else if (!strcmp (*args, "-nooldmime"))
flags |= CMS_NOOLDMIMETYPE;
else if (!strcmp (*args, "-crlfeol"))
if (operation == SMIME_DATA_CREATE)
{
if (operation == SMIME_DATA_CREATE)
{
- if (indef)
- flags |= CMS_STREAM;
cms = CMS_data_create(in, flags);
}
else if (operation == SMIME_DIGEST_CREATE)
{
cms = CMS_data_create(in, flags);
}
else if (operation == SMIME_DIGEST_CREATE)
{
- if (indef)
- flags |= CMS_STREAM;
cms = CMS_digest_create(in, sign_md, flags);
}
else if (operation == SMIME_COMPRESS)
{
cms = CMS_digest_create(in, sign_md, flags);
}
else if (operation == SMIME_COMPRESS)
{
- if (indef)
- flags |= CMS_STREAM;
cms = CMS_compress(in, -1, flags);
}
else if (operation == SMIME_ENCRYPT)
{
cms = CMS_compress(in, -1, flags);
}
else if (operation == SMIME_ENCRYPT)
{
- if (indef)
- flags |= CMS_STREAM;
cms = CMS_encrypt(encerts, in, cipher, flags);
}
else if (operation == SMIME_ENCRYPTED_ENCRYPT)
{
cms = CMS_encrypt(encerts, in, cipher, flags);
}
else if (operation == SMIME_ENCRYPTED_ENCRYPT)
{
- if (indef)
- flags |= CMS_STREAM;
cms = CMS_EncryptedData_encrypt(in, cipher,
secret_key, secret_keylen,
flags);
cms = CMS_EncryptedData_encrypt(in, cipher,
secret_key, secret_keylen,
flags);
{
if (flags & CMS_DETACHED)
{
{
if (flags & CMS_DETACHED)
{
- if (outformat == FORMAT_SMIME)
- flags |= CMS_STREAM;
+ if (outformat != FORMAT_SMIME)
+ flags &= ~CMS_STREAM;
- else if (indef)
- flags |= CMS_STREAM;
flags |= CMS_PARTIAL;
cms = CMS_sign(NULL, NULL, other, in, flags);
if (!cms)
flags |= CMS_PARTIAL;
cms = CMS_sign(NULL, NULL, other, in, flags);
if (!cms)
IMPLEMENT_PEM_rw_const(CMS, CMS_ContentInfo, PEM_STRING_CMS, CMS_ContentInfo)
IMPLEMENT_PEM_rw_const(CMS, CMS_ContentInfo, PEM_STRING_CMS, CMS_ContentInfo)
-#if 0
-/* Streaming encode support for CMS */
-
-static BIO *cmsbio_init(ASN1_VALUE *val, BIO *out)
- {
- return CMS_dataInit((CMS_ContentInfo *)val, out);
- }
-
-static int cmsbio_final(ASN1_VALUE *val, BIO *cmsbio)
- {
- return CMS_dataFinal((CMS_ContentInfo *)val, cmsbio);
- }
-#endif
-
BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms)
{
return BIO_new_NDEF(out, (ASN1_VALUE *)cms,
BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms)
{
return BIO_new_NDEF(out, (ASN1_VALUE *)cms,
+ case NID_pkcs7_enveloped:
case NID_pkcs7_encrypted:
case NID_id_smime_ct_compressedData:
/* Nothing to do */
case NID_pkcs7_encrypted:
case NID_id_smime_ct_compressedData:
/* Nothing to do */
if ((flags & (CMS_STREAM|CMS_PARTIAL)) || CMS_final(cms, data, flags))
return cms;
if ((flags & (CMS_STREAM|CMS_PARTIAL)) || CMS_final(cms, data, flags))
return cms;
merr:
CMSerr(CMS_F_CMS_SIGN, ERR_R_MALLOC_FAILURE);
merr:
CMSerr(CMS_F_CMS_SIGN, ERR_R_MALLOC_FAILURE);
if ((flags & (CMS_STREAM|CMS_PARTIAL)) || CMS_final(cms, data, flags))
return cms;
if ((flags & (CMS_STREAM|CMS_PARTIAL)) || CMS_final(cms, data, flags))
return cms;
merr:
CMSerr(CMS_F_CMS_ENCRYPT, ERR_R_MALLOC_FAILURE);
merr:
CMSerr(CMS_F_CMS_ENCRYPT, ERR_R_MALLOC_FAILURE);
break;
if (cert)
return 0;
break;
if (cert)
return 0;