diff options
| author | tb <> | 2022-01-14 08:40:57 +0000 |
|---|---|---|
| committer | tb <> | 2022-01-14 08:40:57 +0000 |
| commit | bf7beecb6c75655f21958cd52426578df3f1f307 (patch) | |
| tree | f4107fef050d8e49767a68206c4485731507efa2 /src/lib/libcrypto/bio/bio.h | |
| parent | 7d1004f306e7f866e13dd01c6e546fd35a43df41 (diff) | |
| download | openbsd-bf7beecb6c75655f21958cd52426578df3f1f307.tar.gz openbsd-bf7beecb6c75655f21958cd52426578df3f1f307.tar.bz2 openbsd-bf7beecb6c75655f21958cd52426578df3f1f307.zip | |
Implement new-style OpenSSL BIO callbacks
This provides support for new-style BIO callbacks in
BIO_{read,write,gets,puts}() and a helper function to
work out whether it should call the new or the old
style callback. It also adds a few typedefs and minor
code cleanup as well as the BIO_{get,set}_callback_ex()
from jsing, ok tb
Diffstat (limited to 'src/lib/libcrypto/bio/bio.h')
| -rw-r--r-- | src/lib/libcrypto/bio/bio.h | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h index 8feb98d457..679e88a3bc 100644 --- a/src/lib/libcrypto/bio/bio.h +++ b/src/lib/libcrypto/bio/bio.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bio.h,v 1.53 2022/01/14 08:18:55 tb Exp $ */ | 1 | /* $OpenBSD: bio.h,v 1.54 2022/01/14 08:40:57 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -250,21 +250,30 @@ void BIO_clear_flags(BIO *b, int flags); | |||
| 250 | #define BIO_CB_GETS 0x05 | 250 | #define BIO_CB_GETS 0x05 |
| 251 | #define BIO_CB_CTRL 0x06 | 251 | #define BIO_CB_CTRL 0x06 |
| 252 | 252 | ||
| 253 | /* The callback is called before and after the underling operation, | 253 | /* |
| 254 | * The BIO_CB_RETURN flag indicates if it is after the call */ | 254 | * The callback is called before and after the underling operation, |
| 255 | * the BIO_CB_RETURN flag indicates if it is after the call. | ||
| 256 | */ | ||
| 255 | #define BIO_CB_RETURN 0x80 | 257 | #define BIO_CB_RETURN 0x80 |
| 256 | #define BIO_CB_return(a) ((a)|BIO_CB_RETURN)) | 258 | #define BIO_CB_return(a) ((a)|BIO_CB_RETURN)) |
| 257 | #define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) | 259 | #define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) |
| 258 | #define BIO_cb_post(a) ((a)&BIO_CB_RETURN) | 260 | #define BIO_cb_post(a) ((a)&BIO_CB_RETURN) |
| 259 | 261 | ||
| 260 | long (*BIO_get_callback(const BIO *b))(struct bio_st *, int, const char *, | 262 | typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi, |
| 261 | int, long, long); | 263 | long argl, long ret); |
| 262 | void BIO_set_callback(BIO *b, | 264 | typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp, |
| 263 | long (*callback)(struct bio_st *, int, const char *, int, long, long)); | 265 | size_t len, int argi, long argl, int ret, size_t *processed); |
| 266 | |||
| 267 | BIO_callback_fn BIO_get_callback(const BIO *b); | ||
| 268 | void BIO_set_callback(BIO *b, BIO_callback_fn callback); | ||
| 269 | |||
| 270 | BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b); | ||
| 271 | void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback); | ||
| 272 | |||
| 264 | char *BIO_get_callback_arg(const BIO *b); | 273 | char *BIO_get_callback_arg(const BIO *b); |
| 265 | void BIO_set_callback_arg(BIO *b, char *arg); | 274 | void BIO_set_callback_arg(BIO *b, char *arg); |
| 266 | 275 | ||
| 267 | const char * BIO_method_name(const BIO *b); | 276 | const char *BIO_method_name(const BIO *b); |
| 268 | int BIO_method_type(const BIO *b); | 277 | int BIO_method_type(const BIO *b); |
| 269 | 278 | ||
| 270 | typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); | 279 | typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long); |
| @@ -563,8 +572,7 @@ int BIO_write(BIO *b, const void *data, int len) | |||
| 563 | int BIO_puts(BIO *bp, const char *buf); | 572 | int BIO_puts(BIO *bp, const char *buf); |
| 564 | int BIO_indent(BIO *b, int indent, int max); | 573 | int BIO_indent(BIO *b, int indent, int max); |
| 565 | long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); | 574 | long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); |
| 566 | long BIO_callback_ctrl(BIO *b, int cmd, | 575 | long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp); |
| 567 | void (*fp)(struct bio_st *, int, const char *, int, long, long)); | ||
| 568 | char * BIO_ptr_ctrl(BIO *bp, int cmd, long larg); | 576 | char * BIO_ptr_ctrl(BIO *bp, int cmd, long larg); |
| 569 | long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); | 577 | long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); |
| 570 | BIO * BIO_push(BIO *b, BIO *append); | 578 | BIO * BIO_push(BIO *b, BIO *append); |
| @@ -732,6 +740,7 @@ void ERR_load_BIO_strings(void); | |||
| 732 | #define BIO_R_INVALID_PORT_NUMBER 129 | 740 | #define BIO_R_INVALID_PORT_NUMBER 129 |
| 733 | #define BIO_R_IN_USE 123 | 741 | #define BIO_R_IN_USE 123 |
| 734 | #define BIO_R_KEEPALIVE 109 | 742 | #define BIO_R_KEEPALIVE 109 |
| 743 | #define BIO_R_LENGTH_TOO_LONG 130 | ||
| 735 | #define BIO_R_NBIO_CONNECT_ERROR 110 | 744 | #define BIO_R_NBIO_CONNECT_ERROR 110 |
| 736 | #define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 | 745 | #define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 |
| 737 | #define BIO_R_NO_HOSTNAME_SPECIFIED 112 | 746 | #define BIO_R_NO_HOSTNAME_SPECIFIED 112 |
