1*2175Sjp161948=pod 2*2175Sjp161948 3*2175Sjp161948=head1 NAME 4*2175Sjp161948 5*2175Sjp161948BIO_f_base64 - base64 BIO filter 6*2175Sjp161948 7*2175Sjp161948=head1 SYNOPSIS 8*2175Sjp161948 9*2175Sjp161948 #include <openssl/bio.h> 10*2175Sjp161948 #include <openssl/evp.h> 11*2175Sjp161948 12*2175Sjp161948 BIO_METHOD * BIO_f_base64(void); 13*2175Sjp161948 14*2175Sjp161948=head1 DESCRIPTION 15*2175Sjp161948 16*2175Sjp161948BIO_f_base64() returns the base64 BIO method. This is a filter 17*2175Sjp161948BIO that base64 encodes any data written through it and decodes 18*2175Sjp161948any data read through it. 19*2175Sjp161948 20*2175Sjp161948Base64 BIOs do not support BIO_gets() or BIO_puts(). 21*2175Sjp161948 22*2175Sjp161948BIO_flush() on a base64 BIO that is being written through is 23*2175Sjp161948used to signal that no more data is to be encoded: this is used 24*2175Sjp161948to flush the final block through the BIO. 25*2175Sjp161948 26*2175Sjp161948The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags() 27*2175Sjp161948to encode the data all on one line or expect the data to be all 28*2175Sjp161948on one line. 29*2175Sjp161948 30*2175Sjp161948=head1 NOTES 31*2175Sjp161948 32*2175Sjp161948Because of the format of base64 encoding the end of the encoded 33*2175Sjp161948block cannot always be reliably determined. 34*2175Sjp161948 35*2175Sjp161948=head1 RETURN VALUES 36*2175Sjp161948 37*2175Sjp161948BIO_f_base64() returns the base64 BIO method. 38*2175Sjp161948 39*2175Sjp161948=head1 EXAMPLES 40*2175Sjp161948 41*2175Sjp161948Base64 encode the string "Hello World\n" and write the result 42*2175Sjp161948to standard output: 43*2175Sjp161948 44*2175Sjp161948 BIO *bio, *b64; 45*2175Sjp161948 char message[] = "Hello World \n"; 46*2175Sjp161948 47*2175Sjp161948 b64 = BIO_new(BIO_f_base64()); 48*2175Sjp161948 bio = BIO_new_fp(stdout, BIO_NOCLOSE); 49*2175Sjp161948 bio = BIO_push(b64, bio); 50*2175Sjp161948 BIO_write(bio, message, strlen(message)); 51*2175Sjp161948 BIO_flush(bio); 52*2175Sjp161948 53*2175Sjp161948 BIO_free_all(bio); 54*2175Sjp161948 55*2175Sjp161948Read Base64 encoded data from standard input and write the decoded 56*2175Sjp161948data to standard output: 57*2175Sjp161948 58*2175Sjp161948 BIO *bio, *b64, *bio_out; 59*2175Sjp161948 char inbuf[512]; 60*2175Sjp161948 int inlen; 61*2175Sjp161948 62*2175Sjp161948 b64 = BIO_new(BIO_f_base64()); 63*2175Sjp161948 bio = BIO_new_fp(stdin, BIO_NOCLOSE); 64*2175Sjp161948 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); 65*2175Sjp161948 bio = BIO_push(b64, bio); 66*2175Sjp161948 while((inlen = BIO_read(bio, inbuf, 512) > 0) 67*2175Sjp161948 BIO_write(bio_out, inbuf, inlen); 68*2175Sjp161948 69*2175Sjp161948 BIO_free_all(bio); 70*2175Sjp161948 71*2175Sjp161948=head1 BUGS 72*2175Sjp161948 73*2175Sjp161948The ambiguity of EOF in base64 encoded data can cause additional 74*2175Sjp161948data following the base64 encoded block to be misinterpreted. 75*2175Sjp161948 76*2175Sjp161948There should be some way of specifying a test that the BIO can perform 77*2175Sjp161948to reliably determine EOF (for example a MIME boundary). 78*2175Sjp161948 79*2175Sjp161948=head1 SEE ALSO 80*2175Sjp161948 81*2175Sjp161948TBA 82