BIO_f_base64.pod 1.9 KB

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