]> git.ipfire.org Git - thirdparty/openssl.git/blob - include/internal/bio.h
Update copyright year
[thirdparty/openssl.git] / include / internal / bio.h
1 /*
2 * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10 #ifndef OSSL_INTERNAL_BIO_H
11 # define OSSL_INTERNAL_BIO_H
12 # pragma once
13
14 # include <openssl/bio.h>
15
16 struct bio_method_st {
17 int type;
18 char *name;
19 int (*bwrite) (BIO *, const char *, size_t, size_t *);
20 int (*bwrite_old) (BIO *, const char *, int);
21 int (*bread) (BIO *, char *, size_t, size_t *);
22 int (*bread_old) (BIO *, char *, int);
23 int (*bputs) (BIO *, const char *);
24 int (*bgets) (BIO *, char *, int);
25 long (*ctrl) (BIO *, int, long, void *);
26 int (*create) (BIO *);
27 int (*destroy) (BIO *);
28 long (*callback_ctrl) (BIO *, int, BIO_info_cb *);
29 };
30
31 void bio_free_ex_data(BIO *bio);
32 void bio_cleanup(void);
33
34
35 /* Old style to new style BIO_METHOD conversion functions */
36 int bwrite_conv(BIO *bio, const char *data, size_t datal, size_t *written);
37 int bread_conv(BIO *bio, char *data, size_t datal, size_t *read);
38
39 /* Changes to these internal BIOs must also update include/openssl/bio.h */
40 # define BIO_CTRL_SET_KTLS 72
41 # define BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG 74
42 # define BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG 75
43
44 /*
45 * This is used with socket BIOs:
46 * BIO_FLAGS_KTLS_TX means we are using ktls with this BIO for sending.
47 * BIO_FLAGS_KTLS_TX_CTRL_MSG means we are about to send a ctrl message next.
48 * BIO_FLAGS_KTLS_RX means we are using ktls with this BIO for receiving.
49 */
50 # define BIO_FLAGS_KTLS_TX 0x800
51 # define BIO_FLAGS_KTLS_TX_CTRL_MSG 0x1000
52 # define BIO_FLAGS_KTLS_RX 0x2000
53
54 /* KTLS related controls and flags */
55 # define BIO_set_ktls_flag(b, is_tx) \
56 BIO_set_flags(b, (is_tx) ? BIO_FLAGS_KTLS_TX : BIO_FLAGS_KTLS_RX)
57 # define BIO_should_ktls_flag(b, is_tx) \
58 BIO_test_flags(b, (is_tx) ? BIO_FLAGS_KTLS_TX : BIO_FLAGS_KTLS_RX)
59 # define BIO_set_ktls_ctrl_msg_flag(b) \
60 BIO_set_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG)
61 # define BIO_should_ktls_ctrl_msg_flag(b) \
62 BIO_test_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG)
63 # define BIO_clear_ktls_ctrl_msg_flag(b) \
64 BIO_clear_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG)
65
66 # define BIO_set_ktls(b, keyblob, is_tx) \
67 BIO_ctrl(b, BIO_CTRL_SET_KTLS, is_tx, keyblob)
68 # define BIO_set_ktls_ctrl_msg(b, record_type) \
69 BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG, record_type, NULL)
70 # define BIO_clear_ktls_ctrl_msg(b) \
71 BIO_ctrl(b, BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG, 0, NULL)
72
73 #endif