Hello!

    I've got a function to decode a byte array in base64 and the
function is the next...


ungined char *bytes=.... -> File (his size is 7Mb).
int length= 7Mb;

 BIO *bio2=BIO_new(BIO_s_mem());
 BIO_write(bio2,bytes,length);

 BIO *b64_2;
 if(!(b64_2 = BIO_new(BIO_f_base64()))) {
  return NULL;
 }
 bio2 = BIO_push(b64_2, bio2);

 char buf[4096];
 BIO *dataEnSign=BIO_new(BIO_s_mem());
 for (;;) {
  int i=BIO_read(bio2,buf,sizeof(buf));
  if (i<=0) break;
  BIO_write(dataEnSign,buf,i);
 }
 BIO_flush(bio2);
 bio2 = BIO_pop(bio2);
 BIO_free(b64_2);
 BIO_free_all(bio2);

 BUF_MEM *buf_mem3=NULL;
 BIO_get_mem_ptr(dataEnSign,&buf_mem3);

unsigned char *bytes2=buf_mem3->data;
int length2=buf_mem3->length

My questions are the next...

Is there another way of decode the byte array without using less memory?

the bio creates a copy of my array and it works with this copy...

How I can free the memory of the buf_mem3?

Thanks in advace,
regards,
Antonio.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to