1BIO_f_base64(3) OpenSSL BIO_f_base64(3)
2
3
4
6 BIO_f_base64 - base64 BIO filter
7
9 #include <openssl/bio.h>
10 #include <openssl/evp.h>
11
12 BIO_METHOD * BIO_f_base64(void);
13
15 BIO_f_base64() returns the base64 BIO method. This is a filter BIO that
16 base64 encodes any data written through it and decodes any data read
17 through it.
18
19 Base64 BIOs do not support BIO_gets() or BIO_puts().
20
21 BIO_flush() on a base64 BIO that is being written through is used to
22 signal that no more data is to be encoded: this is used to flush the
23 final block through the BIO.
24
25 The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags() to
26 encode the data all on one line or expect the data to be all on one
27 line.
28
30 Because of the format of base64 encoding the end of the encoded block
31 cannot always be reliably determined.
32
34 BIO_f_base64() returns the base64 BIO method.
35
37 Base64 encode the string "Hello World\n" and write the result to stan‐
38 dard output:
39
40 BIO *bio, *b64;
41 char message[] = "Hello World \n";
42
43 b64 = BIO_new(BIO_f_base64());
44 bio = BIO_new_fp(stdout, BIO_NOCLOSE);
45 bio = BIO_push(b64, bio);
46 BIO_write(bio, message, strlen(message));
47 BIO_flush(bio);
48
49 BIO_free_all(bio);
50
51 Read Base64 encoded data from standard input and write the decoded data
52 to standard output:
53
54 BIO *bio, *b64, *bio_out;
55 char inbuf[512];
56 int inlen;
57
58 b64 = BIO_new(BIO_f_base64());
59 bio = BIO_new_fp(stdin, BIO_NOCLOSE);
60 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
61 bio = BIO_push(b64, bio);
62 while((inlen = BIO_read(bio, inbuf, 512)) > 0)
63 BIO_write(bio_out, inbuf, inlen);
64
65 BIO_free_all(bio);
66
68 The ambiguity of EOF in base64 encoded data can cause additional data
69 following the base64 encoded block to be misinterpreted.
70
71 There should be some way of specifying a test that the BIO can perform
72 to reliably determine EOF (for example a MIME boundary).
73
75 TBA
76
77
78
790.9.8b 2005-11-02 BIO_f_base64(3)