--- On Thu, 10/28/10, Dave Thompson <dthomp...@prinpay.com> wrote:

> From: Dave Thompson <dthomp...@prinpay.com>
> Subject: RE: B64_read_PKCS7 : Anyone modified the base64 reader to be more 
> forgiving?
> To: openssl-users@openssl.org
> Date: Thursday, October 28, 2010, 7:00 PM
> > From: owner-openssl-us...@openssl.org
> On Behalf Of Harakiri
> > Sent: Thursday, 28 October, 2010 07:52
> 

> > 
> BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL)
> 
> Output doesn't generate (any) linebreaks. Input doesn't 
> REQUIRE them every <80, but does ALLOW them anywhere.

i tried this - however it does not work - i patched the method in question

static PKCS7 *B64_read_PKCS7(BIO *bio)
{
      BIO *b64;
      PKCS7 *p7;
      if(!(b64 = BIO_new(BIO_f_base64()))) {
            PKCS7err(PKCS7_F_B64_READ_PKCS7,ERR_R_MALLOC_FAILURE);
            return 0;
      }
      printf("Testing..");
      BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL);
      bio = BIO_push(b64, bio);
      if(!(p7 = d2i_PKCS7_bio(bio, NULL)))
            PKCS7err(PKCS7_F_B64_READ_PKCS7,PKCS7_R_DECODE_ERROR);
      BIO_flush(bio);
      bio = BIO_pop(bio);
      BIO_free(b64);
      return p7;
}

I used a simple smime signed message where the last base64 line was faulty:

DhBgOxHXEhy/CzkNjQysNxJQ492WCybahjBwpRfJRU3i0qwW1SBG+7XL4lEZ2CfaOdheE2yM3OooAAAA
AAAA

the last 4 A should be in the next line

However, now another error is returned (header too long)

24073:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too 
long:asn1_lib.c:150:
24073:error:21078082:PKCS7 routines:B64_READ_PKCS7:decode error:pk7_mime.c:142:
24073:error:2107A08C:PKCS7 routines:SMIME_read_PKCS7:pkcs7 sig parse 
error:pk7_mime.c:349:

previously it was the not enough data error

24091:error:0D06B08E:asn1 encoding routines:ASN1_D2I_READ_BIO:not enough 
data:a_d2i_fp.c:238:
24091:error:21078082:PKCS7 routines:B64_READ_PKCS7:decode error:pk7_mime.c:140:
24091:error:2107A08C:PKCS7 routines:SMIME_read_PKCS7:pkcs7 sig parse 
error:pk7_mime.c:347:

Any ideas ?

Putting the 4 A in the last line fixed it so the base64 itself is technically 
OK.

Thanks


      
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to