summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BIO_f_base64.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/BIO_f_base64.3')
-rw-r--r--src/lib/libcrypto/man/BIO_f_base64.380
1 files changed, 80 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BIO_f_base64.3 b/src/lib/libcrypto/man/BIO_f_base64.3
new file mode 100644
index 0000000000..e08191b84a
--- /dev/null
+++ b/src/lib/libcrypto/man/BIO_f_base64.3
@@ -0,0 +1,80 @@
1.Dd July 17, 2014
2.Dt BIO_F_BASE64 3
3.Os
4.Sh NAME
5.Nm BIO_f_base64
6.Nd base64 BIO filter
7.Sh SYNOPSIS
8.In openssl/bio.h
9.In openssl/evp.h
10.Ft BIO_METHOD *
11.Fo BIO_f_base64
12.Fa void
13.Fc
14.Sh DESCRIPTION
15.Fn BIO_f_base64
16returns the base64 BIO method.
17This is a filter BIO that base64 encodes any data written through it
18and decodes any data read through it.
19.Pp
20Base64 BIOs do not support
21.Xr BIO_gets 3
22or
23.Xr BIO_puts 3 .
24.Pp
25.Xr BIO_flush 3
26on a base64 BIO that is being written through
27is used to signal that no more data is to be encoded:
28this is used to flush the final block through the BIO.
29.Pp
30The flag
31.Dv BIO_FLAGS_BASE64_NO_NL
32can be set with
33.Xr BIO_set_flags 3
34to encode the data all on one line
35or expect the data to be all on one line.
36.Sh NOTES
37Because of the format of base64 encoding the end of the encoded
38block cannot always be reliably determined.
39.Sh RETURN VALUES
40.Fn BIO_f_base64
41returns the base64 BIO method.
42.Sh EXAMPLES
43Base64 encode the string "Hello World\en"
44and write the result to standard output:
45.Bd -literal -offset indent
46BIO *bio, *b64;
47char message[] = "Hello World \en";
48
49b64 = BIO_new(BIO_f_base64());
50bio = BIO_new_fp(stdout, BIO_NOCLOSE);
51BIO_push(b64, bio);
52BIO_write(b64, message, strlen(message));
53BIO_flush(b64);
54
55BIO_free_all(b64);
56.Ed
57.Pp
58Read Base64 encoded data from standard input
59and write the decoded data to standard output:
60.Bd -literal -offset indent
61BIO *bio, *b64, *bio_out;
62char inbuf[512];
63int inlen;
64
65b64 = BIO_new(BIO_f_base64());
66bio = BIO_new_fp(stdin, BIO_NOCLOSE);
67bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
68BIO_push(b64, bio);
69while((inlen = BIO_read(b64, inbuf, 512)) > 0)
70 BIO_write(bio_out, inbuf, inlen);
71
72BIO_flush(bio_out);
73BIO_free_all(b64);
74.Ed
75.Sh BUGS
76The ambiguity of EOF in base64 encoded data can cause additional
77data following the base64 encoded block to be misinterpreted.
78.Pp
79There should be some way of specifying a test that the BIO can perform
80to reliably determine EOF (for example a MIME boundary).