From e9ec63961be610bbd386f482335772bc23dc095e Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Tue, 25 Feb 2003 19:03:31 +0000 Subject: [PATCH] Fix indefinite length encoding so EOC correctly updates the buffer pointer. Rename PKCS7_PARTSIGN to PKCS7_STREAM. Guess what that's for :-) --- CHANGES | 2 +- apps/smime.c | 4 ++-- crypto/asn1/tasn_enc.c | 6 ++++-- crypto/pkcs7/pk7_mime.c | 2 +- crypto/pkcs7/pk7_smime.c | 2 +- crypto/pkcs7/pkcs7.h | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 98b44d561c..b032498a2e 100644 --- a/CHANGES +++ b/CHANGES @@ -18,7 +18,7 @@ cleartext signing (multipart/signed type) is effectively streaming and the signed data does not need to be all held in memory. - This is done with a new flag PKCS7_PARTSIGN. When this flag is set + This is done with a new flag PKCS7_STREAM. When this flag is set PKCS7_sign() only initializes the PKCS7 structure and the actual signing is done after the data is output (and digests calculated) in SMIME_write_PKCS7(). diff --git a/apps/smime.c b/apps/smime.c index 83daa71ca1..1d7d828e01 100644 --- a/apps/smime.c +++ b/apps/smime.c @@ -482,10 +482,10 @@ int MAIN(int argc, char **argv) * signing. */ if ((flags & PKCS7_DETACHED) && (outformat == FORMAT_SMIME)) - flags |= PKCS7_PARTSIGN; + flags |= PKCS7_STREAM; p7 = PKCS7_sign(signer, key, other, in, flags); /* Don't need to rewind for partial signing */ - if (!(flags & PKCS7_PARTSIGN) && (BIO_reset(in) != 0)) { + if (!(flags & PKCS7_STREAM) && (BIO_reset(in) != 0)) { BIO_printf(bio_err, "Can't rewind input file\n"); goto end; } diff --git a/crypto/asn1/tasn_enc.c b/crypto/asn1/tasn_enc.c index 5ce38e1920..2e80655074 100644 --- a/crypto/asn1/tasn_enc.c +++ b/crypto/asn1/tasn_enc.c @@ -494,7 +494,10 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const A if(out) { if(usetag) ASN1_put_object(out, ndef, len, tag, aclass); asn1_ex_i2c(pval, *out, &utype, it); - *out += len; + if (ndef) + ASN1_put_eoc(out); + else + *out += len; } if(usetag) return ASN1_object_size(ndef, len, tag); @@ -598,7 +601,6 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype, const ASN1_ { strtmp->data = cout; strtmp->length = 0; - ASN1_put_eoc(&cout); } /* Special return code */ return -2; diff --git a/crypto/pkcs7/pk7_mime.c b/crypto/pkcs7/pk7_mime.c index 51be777687..431aff94f0 100644 --- a/crypto/pkcs7/pk7_mime.c +++ b/crypto/pkcs7/pk7_mime.c @@ -202,7 +202,7 @@ static int pkcs7_output_data(BIO *out, BIO *data, PKCS7 *p7, int flags) { BIO *tmpbio, *p7bio; - if (!(flags & PKCS7_PARTSIGN)) + if (!(flags & PKCS7_STREAM)) { SMIME_crlf_copy(data, out, flags); return 1; diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c index b170fe285d..333a8aa38d 100644 --- a/crypto/pkcs7/pk7_smime.c +++ b/crypto/pkcs7/pk7_smime.c @@ -125,7 +125,7 @@ PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, } } - if (flags & PKCS7_PARTSIGN) + if (flags & PKCS7_STREAM) return p7; if (!(p7bio = PKCS7_dataInit(p7, NULL))) { diff --git a/crypto/pkcs7/pkcs7.h b/crypto/pkcs7/pkcs7.h index a2956589ab..e6f6572666 100644 --- a/crypto/pkcs7/pkcs7.h +++ b/crypto/pkcs7/pkcs7.h @@ -260,7 +260,7 @@ DECLARE_PKCS12_STACK_OF(PKCS7) #define PKCS7_BINARY 0x80 #define PKCS7_NOATTR 0x100 #define PKCS7_NOSMIMECAP 0x200 -#define PKCS7_PARTSIGN 0x400 +#define PKCS7_STREAM 0x400 /* Flags: for compatibility with older code */ -- 2.25.1