BIO_f_base64.pod 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 = BIO_push(b64, bio);
  32. BIO_write(bio, message, strlen(message));
  33. BIO_flush(bio);
  34. BIO_free_all(bio);
  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 = BIO_push(b64, bio);
  44. while((inlen = BIO_read(bio, inbuf, 512)) > 0)
  45. BIO_write(bio_out, inbuf, inlen);
  46. BIO_free_all(bio);
  47. =head1 BUGS
  48. The ambiguity of EOF in base64 encoded data can cause additional
  49. data following the base64 encoded block to be misinterpreted.
  50. There should be some way of specifying a test that the BIO can perform
  51. to reliably determine EOF (for example a MIME boundary).
  52. =head1 SEE ALSO
  53. TBA