BIO_s_core.pod 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. =pod
  2. =head1 NAME
  3. BIO_s_core, BIO_new_from_core_bio - OSSL_CORE_BIO functions
  4. =head1 SYNOPSIS
  5. #include <openssl/bio.h>
  6. const BIO_METHOD *BIO_s_core(void);
  7. BIO *BIO_new_from_core_bio(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio);
  8. =head1 DESCRIPTION
  9. BIO_s_core() returns the core BIO method function.
  10. A core BIO is treated as source/sink BIO which communicates to some external
  11. BIO. This is primarily useful to provider authors. A number of calls from
  12. libcrypto into a provider supply an OSSL_CORE_BIO parameter. This represents
  13. a BIO within libcrypto, but cannot be used directly by a provider. Instead it
  14. should be wrapped using a BIO_s_core().
  15. Once a BIO is constructed based on BIO_s_core(), the associated OSSL_CORE_BIO
  16. object should be set on it using BIO_set_data(3). Note that the BIO will only
  17. operate correctly if it is associated with a library context constructed using
  18. OSSL_LIB_CTX_new_from_dispatch(3). To associate the BIO with a library context
  19. construct it using BIO_new_ex(3).
  20. BIO_new_from_core_bio() is a convenience function that constructs a new BIO
  21. based on BIO_s_core() and that is associated with the given library context. It
  22. then also sets the OSSL_CORE_BIO object on the BIO using BIO_set_data(3).
  23. =head1 RETURN VALUES
  24. BIO_s_core() return a core BIO B<BIO_METHOD> structure.
  25. BIO_new_from_core_bio() returns a BIO structure on success or NULL on failure.
  26. A failure will most commonly be because the library context was not constructed
  27. using OSSL_LIB_CTX_new_from_dispatch(3).
  28. =head1 HISTORY
  29. BIO_s_core() and BIO_new_from_core_bio() were added in OpenSSL 3.0.
  30. =head1 EXAMPLES
  31. Create a core BIO and write some data to it:
  32. int some_function(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio) {
  33. BIO *cbio = BIO_new_from_core_bio(libctx, corebio);
  34. if (cbio == NULL)
  35. return 0;
  36. BIO_puts(cbio, "Hello World\n");
  37. BIO_free(cbio);
  38. return 1;
  39. }
  40. =head1 COPYRIGHT
  41. Copyright 2021-2022 The OpenSSL Project Authors. All Rights Reserved.
  42. Licensed under the Apache License 2.0 (the "License"). You may not use
  43. this file except in compliance with the License. You can obtain a copy
  44. in the file LICENSE in the source distribution or at
  45. L<https://www.openssl.org/source/license.html>.
  46. =cut