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