2
0

BIO_f_base64.pod 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. =pod
  2. =head1 NAME
  3. BIO_f_base64 - base64 BIO filter
  4. =head1 SYNOPSIS
  5. =for comment multiple includes
  6. #include <openssl/bio.h>
  7. #include <openssl/evp.h>
  8. const BIO_METHOD *BIO_f_base64(void);
  9. =head1 DESCRIPTION
  10. BIO_f_base64() returns the base64 BIO method. This is a filter
  11. BIO that base64 encodes any data written through it and decodes
  12. any data read through it.
  13. Base64 BIOs do not support BIO_gets() or BIO_puts().
  14. BIO_flush() on a base64 BIO that is being written through is
  15. used to signal that no more data is to be encoded: this is used
  16. to flush the final block through the BIO.
  17. The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags()
  18. to encode the data all on one line or expect the data to be all
  19. on one line.
  20. =head1 NOTES
  21. Because of the format of base64 encoding the end of the encoded
  22. block cannot always be reliably determined.
  23. =head1 RETURN VALUES
  24. BIO_f_base64() returns the base64 BIO method.
  25. =head1 EXAMPLES
  26. Base64 encode the string "Hello World\n" and write the result
  27. to standard output:
  28. BIO *bio, *b64;
  29. char message[] = "Hello World \n";
  30. b64 = BIO_new(BIO_f_base64());
  31. bio = BIO_new_fp(stdout, BIO_NOCLOSE);
  32. BIO_push(b64, bio);
  33. BIO_write(b64, message, strlen(message));
  34. BIO_flush(b64);
  35. BIO_free_all(b64);
  36. Read Base64 encoded data from standard input and write the decoded
  37. data to standard output:
  38. BIO *bio, *b64, *bio_out;
  39. char inbuf[512];
  40. int inlen;
  41. b64 = BIO_new(BIO_f_base64());
  42. bio = BIO_new_fp(stdin, BIO_NOCLOSE);
  43. bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
  44. BIO_push(b64, bio);
  45. while ((inlen = BIO_read(b64, inbuf, 512)) > 0)
  46. BIO_write(bio_out, inbuf, inlen);
  47. BIO_flush(bio_out);
  48. BIO_free_all(b64);
  49. =head1 BUGS
  50. The ambiguity of EOF in base64 encoded data can cause additional
  51. data following the base64 encoded block to be misinterpreted.
  52. There should be some way of specifying a test that the BIO can perform
  53. to reliably determine EOF (for example a MIME boundary).
  54. =head1 COPYRIGHT
  55. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  56. Licensed under the OpenSSL license (the "License"). You may not use
  57. this file except in compliance with the License. You can obtain a copy
  58. in the file LICENSE in the source distribution or at
  59. L<https://www.openssl.org/source/license.html>.
  60. =cut