Blame doc/man3/BIO_f_base64.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
BIO_f_base64 - base64 BIO filter
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
=for comment multiple includes
Packit c4476c
Packit c4476c
 #include <openssl/bio.h>
Packit c4476c
 #include <openssl/evp.h>
Packit c4476c
Packit c4476c
 const BIO_METHOD *BIO_f_base64(void);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
BIO_f_base64() returns the base64 BIO method. This is a filter
Packit c4476c
BIO that base64 encodes any data written through it and decodes
Packit c4476c
any data read through it.
Packit c4476c
Packit c4476c
Base64 BIOs do not support BIO_gets() or BIO_puts().
Packit c4476c
Packit c4476c
BIO_flush() on a base64 BIO that is being written through is
Packit c4476c
used to signal that no more data is to be encoded: this is used
Packit c4476c
to flush the final block through the BIO.
Packit c4476c
Packit c4476c
The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags()
Packit c4476c
to encode the data all on one line or expect the data to be all
Packit c4476c
on one line.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
Because of the format of base64 encoding the end of the encoded
Packit c4476c
block cannot always be reliably determined.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
BIO_f_base64() returns the base64 BIO method.
Packit c4476c
Packit c4476c
=head1 EXAMPLES
Packit c4476c
Packit c4476c
Base64 encode the string "Hello World\n" and write the result
Packit c4476c
to standard output:
Packit c4476c
Packit c4476c
 BIO *bio, *b64;
Packit c4476c
 char message[] = "Hello World \n";
Packit c4476c
Packit c4476c
 b64 = BIO_new(BIO_f_base64());
Packit c4476c
 bio = BIO_new_fp(stdout, BIO_NOCLOSE);
Packit c4476c
 BIO_push(b64, bio);
Packit c4476c
 BIO_write(b64, message, strlen(message));
Packit c4476c
 BIO_flush(b64);
Packit c4476c
Packit c4476c
 BIO_free_all(b64);
Packit c4476c
Packit c4476c
Read Base64 encoded data from standard input and write the decoded
Packit c4476c
data to standard output:
Packit c4476c
Packit c4476c
 BIO *bio, *b64, *bio_out;
Packit c4476c
 char inbuf[512];
Packit c4476c
 int inlen;
Packit c4476c
Packit c4476c
 b64 = BIO_new(BIO_f_base64());
Packit c4476c
 bio = BIO_new_fp(stdin, BIO_NOCLOSE);
Packit c4476c
 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
Packit c4476c
 BIO_push(b64, bio);
Packit c4476c
 while ((inlen = BIO_read(b64, inbuf, 512)) > 0)
Packit c4476c
     BIO_write(bio_out, inbuf, inlen);
Packit c4476c
Packit c4476c
 BIO_flush(bio_out);
Packit c4476c
 BIO_free_all(b64);
Packit c4476c
Packit c4476c
=head1 BUGS
Packit c4476c
Packit c4476c
The ambiguity of EOF in base64 encoded data can cause additional
Packit c4476c
data following the base64 encoded block to be misinterpreted.
Packit c4476c
Packit c4476c
There should be some way of specifying a test that the BIO can perform
Packit c4476c
to reliably determine EOF (for example a MIME boundary).
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut