xref: /aosp_15_r20/external/libbrillo/brillo/streams/openssl_stream_bio.h (revision 1a96fba65179ea7d3f56207137718607415c5953)
1*1a96fba6SXin Li // Copyright 2015 The Chromium OS Authors. All rights reserved.
2*1a96fba6SXin Li // Use of this source code is governed by a BSD-style license that can be
3*1a96fba6SXin Li // found in the LICENSE file.
4*1a96fba6SXin Li 
5*1a96fba6SXin Li #ifndef LIBBRILLO_BRILLO_STREAMS_OPENSSL_STREAM_BIO_H_
6*1a96fba6SXin Li #define LIBBRILLO_BRILLO_STREAMS_OPENSSL_STREAM_BIO_H_
7*1a96fba6SXin Li 
8*1a96fba6SXin Li #include <brillo/brillo_export.h>
9*1a96fba6SXin Li 
10*1a96fba6SXin Li // Forward-declare BIO as an alias to OpenSSL's internal bio_st structure.
11*1a96fba6SXin Li using BIO = struct bio_st;
12*1a96fba6SXin Li 
13*1a96fba6SXin Li namespace brillo {
14*1a96fba6SXin Li 
15*1a96fba6SXin Li class Stream;
16*1a96fba6SXin Li 
17*1a96fba6SXin Li // Creates a new BIO that uses the brillo::Stream as the back-end storage.
18*1a96fba6SXin Li // The created BIO does *NOT* own the |stream| and the stream must out-live
19*1a96fba6SXin Li // the BIO.
20*1a96fba6SXin Li // At the moment, only BIO_read and BIO_write operations are supported as well
21*1a96fba6SXin Li // as BIO_flush. More functionality could be added to this when/if needed.
22*1a96fba6SXin Li // The returned BIO performs *NON-BLOCKING* IO on the underlying stream.
23*1a96fba6SXin Li BRILLO_EXPORT BIO* BIO_new_stream(brillo::Stream* stream);
24*1a96fba6SXin Li 
25*1a96fba6SXin Li }  // namespace brillo
26*1a96fba6SXin Li 
27*1a96fba6SXin Li #endif  // LIBBRILLO_BRILLO_STREAMS_OPENSSL_STREAM_BIO_H_
28