diff options
author | Matt Caswell <matt@openssl.org> | 2016-03-22 09:21:29 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-03-29 17:40:54 +0100 |
commit | a146ae55ba479a5c7aa2a6afba1b2b93102a152c (patch) | |
tree | 4c0803ebfed56f2a4ff59725a763cdc78bcf0379 /crypto/bio | |
parent | f334461facc4078adbad6552563f77799c174cab (diff) | |
download | openssl-a146ae55ba479a5c7aa2a6afba1b2b93102a152c.tar.gz |
Make BIO opaque
Move the the BIO_METHOD and BIO structures into internal header files,
provide appropriate accessor methods and update all internal code to use
the new accessors where appropriate.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/bio')
-rw-r--r-- | crypto/bio/bf_buff.c | 2 | ||||
-rw-r--r-- | crypto/bio/bf_nbio.c | 2 | ||||
-rw-r--r-- | crypto/bio/bf_null.c | 2 | ||||
-rw-r--r-- | crypto/bio/bio_cb.c | 2 | ||||
-rw-r--r-- | crypto/bio/bio_lcl.h | 45 | ||||
-rw-r--r-- | crypto/bio/bio_lib.c | 42 | ||||
-rw-r--r-- | crypto/bio/bio_meth.c | 8 | ||||
-rw-r--r-- | crypto/bio/bss_bio.c | 2 | ||||
-rw-r--r-- | crypto/bio/bss_log.c | 1 | ||||
-rw-r--r-- | crypto/bio/bss_mem.c | 2 | ||||
-rw-r--r-- | crypto/bio/bss_null.c | 2 | ||||
-rw-r--r-- | crypto/bio/bss_sock.c | 1 |
12 files changed, 98 insertions, 13 deletions
diff --git a/crypto/bio/bf_buff.c b/crypto/bio/bf_buff.c index 6040c85119..361d26a5b7 100644 --- a/crypto/bio/bf_buff.c +++ b/crypto/bio/bf_buff.c @@ -57,8 +57,8 @@ #include <stdio.h> #include <errno.h> +#include "bio_lcl.h" #include "internal/cryptlib.h" -#include <openssl/bio.h> static int buffer_write(BIO *h, const char *buf, int num); static int buffer_read(BIO *h, char *buf, int size); diff --git a/crypto/bio/bf_nbio.c b/crypto/bio/bf_nbio.c index c8bf580e1d..cefd35f984 100644 --- a/crypto/bio/bf_nbio.c +++ b/crypto/bio/bf_nbio.c @@ -57,9 +57,9 @@ #include <stdio.h> #include <errno.h> +#include "bio_lcl.h" #include "internal/cryptlib.h" #include <openssl/rand.h> -#include <openssl/bio.h> /* * BIO_put and BIO_get both add to the digest, BIO_gets returns the digest diff --git a/crypto/bio/bf_null.c b/crypto/bio/bf_null.c index e3b87d24e5..162e250f9b 100644 --- a/crypto/bio/bf_null.c +++ b/crypto/bio/bf_null.c @@ -57,8 +57,8 @@ #include <stdio.h> #include <errno.h> +#include "bio_lcl.h" #include "internal/cryptlib.h" -#include <openssl/bio.h> /* * BIO_put and BIO_get both add to the digest, BIO_gets returns the digest diff --git a/crypto/bio/bio_cb.c b/crypto/bio/bio_cb.c index ec484b697b..552b66eca0 100644 --- a/crypto/bio/bio_cb.c +++ b/crypto/bio/bio_cb.c @@ -58,8 +58,8 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include "bio_lcl.h" #include "internal/cryptlib.h" -#include <openssl/bio.h> #include <openssl/err.h> long BIO_debug_callback(BIO *bio, int cmd, const char *argp, diff --git a/crypto/bio/bio_lcl.h b/crypto/bio/bio_lcl.h index 24f8b18595..1e409f8e13 100644 --- a/crypto/bio/bio_lcl.h +++ b/crypto/bio/bio_lcl.h @@ -65,7 +65,50 @@ union bio_addr_st { /* END BIO_ADDRINFO/BIO_ADDR stuff. */ #include "internal/cryptlib.h" -#include <openssl/bio.h> +#include <internal/bio.h> + +typedef struct bio_f_buffer_ctx_struct { + /*- + * Buffers are setup like this: + * + * <---------------------- size -----------------------> + * +---------------------------------------------------+ + * | consumed | remaining | free space | + * +---------------------------------------------------+ + * <-- off --><------- len -------> + */ + /*- BIO *bio; *//* + * this is now in the BIO struct + */ + int ibuf_size; /* how big is the input buffer */ + int obuf_size; /* how big is the output buffer */ + char *ibuf; /* the char array */ + int ibuf_len; /* how many bytes are in it */ + int ibuf_off; /* write/read offset */ + char *obuf; /* the char array */ + int obuf_len; /* how many bytes are in it */ + int obuf_off; /* write/read offset */ +} BIO_F_BUFFER_CTX; + +struct bio_st { + const BIO_METHOD *method; + /* bio, mode, argp, argi, argl, ret */ + long (*callback) (struct bio_st *, int, const char *, int, long, long); + char *cb_arg; /* first argument for the callback */ + int init; + int shutdown; + int flags; /* extra storage */ + int retry_reason; + int num; + void *ptr; + struct bio_st *next_bio; /* used by filter BIOs */ + struct bio_st *prev_bio; /* used by filter BIOs */ + int references; + uint64_t num_read; + uint64_t num_write; + CRYPTO_EX_DATA ex_data; + CRYPTO_RWLOCK *lock; +}; #ifndef OPENSSL_NO_SOCK # ifdef OPENSSL_SYS_VMS diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index 9357553d36..ac98cf2402 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -58,8 +58,8 @@ #include <stdio.h> #include <errno.h> #include <openssl/crypto.h> +#include "bio_lcl.h" #include "internal/cryptlib.h" -#include <openssl/bio.h> #include <openssl/stack.h> BIO *BIO_new(const BIO_METHOD *method) @@ -142,6 +142,36 @@ int BIO_free(BIO *a) return 1; } +void BIO_set_data(BIO *a, void *ptr) +{ + a->ptr = ptr; +} + +void *BIO_get_data(BIO *a) +{ + return a->ptr; +} + +void BIO_set_init(BIO *a, int init) +{ + a->init = init; +} + +int BIO_get_init(BIO *a) +{ + return a->init; +} + +void BIO_set_shutdown(BIO *a, int shut) +{ + a->shutdown = shut; +} + +int BIO_get_shutdown(BIO *a) +{ + return a->shutdown; +} + void BIO_vfree(BIO *a) { BIO_free(a); @@ -487,6 +517,11 @@ int BIO_get_retry_reason(BIO *bio) return (bio->retry_reason); } +void BIO_set_retry_reason(BIO *bio, int reason) +{ + bio->retry_reason = reason; +} + BIO *BIO_find_type(BIO *bio, int type) { int mt, mask; @@ -516,6 +551,11 @@ BIO *BIO_next(BIO *b) return b->next_bio; } +void BIO_set_next(BIO *b, BIO *next) +{ + b->next_bio = next; +} + void BIO_free_all(BIO *bio) { BIO *b; diff --git a/crypto/bio/bio_meth.c b/crypto/bio/bio_meth.c index 3d337e91f3..134c448976 100644 --- a/crypto/bio/bio_meth.c +++ b/crypto/bio/bio_meth.c @@ -82,13 +82,13 @@ int BIO_meth_set_write(BIO_METHOD *biom, return 1; } -int (*BIO_meth_get_read(BIO_METHOD *biom)) (BIO *, const char *, int) +int (*BIO_meth_get_read(BIO_METHOD *biom)) (BIO *, char *, int) { return biom->bread; } int BIO_meth_set_read(BIO_METHOD *biom, - int (*read) (BIO *, const char *, int)) + int (*read) (BIO *, char *, int)) { biom->bread = read; return 1; @@ -108,7 +108,7 @@ int BIO_meth_set_puts(BIO_METHOD *biom, int (*BIO_meth_get_gets(BIO_METHOD *biom)) (BIO *, char *, int) { - return biom->gets; + return biom->bgets; } int BIO_meth_set_gets(BIO_METHOD *biom, @@ -130,7 +130,7 @@ int BIO_meth_set_ctrl(BIO_METHOD *biom, return 1; } -int (*BIO_meth_get_create(BIO_METHOD *bion)) (BIO *) +int (*BIO_meth_get_create(BIO_METHOD *biom)) (BIO *) { return biom->create; } diff --git a/crypto/bio/bss_bio.c b/crypto/bio/bss_bio.c index 518fa35c2f..2991c3afed 100644 --- a/crypto/bio/bss_bio.c +++ b/crypto/bio/bss_bio.c @@ -65,7 +65,7 @@ #include <stdlib.h> #include <string.h> -#include <openssl/bio.h> +#include "bio_lcl.h" #include <openssl/err.h> #include <openssl/crypto.h> diff --git a/crypto/bio/bss_log.c b/crypto/bio/bss_log.c index a6bc0e779a..c2c8c79097 100644 --- a/crypto/bio/bss_log.c +++ b/crypto/bio/bss_log.c @@ -64,6 +64,7 @@ #include <stdio.h> #include <errno.h> +#include "bio_lcl.h" #include "internal/cryptlib.h" #if defined(OPENSSL_SYS_WINCE) diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c index 68ac90d0af..460e070a7d 100644 --- a/crypto/bio/bss_mem.c +++ b/crypto/bio/bss_mem.c @@ -57,8 +57,8 @@ #include <stdio.h> #include <errno.h> +#include "bio_lcl.h" #include "internal/cryptlib.h" -#include <openssl/bio.h> static int mem_write(BIO *h, const char *buf, int num); static int mem_read(BIO *h, char *buf, int size); diff --git a/crypto/bio/bss_null.c b/crypto/bio/bss_null.c index c5e24844d1..29561c7326 100644 --- a/crypto/bio/bss_null.c +++ b/crypto/bio/bss_null.c @@ -57,8 +57,8 @@ #include <stdio.h> #include <errno.h> +#include "bio_lcl.h" #include "internal/cryptlib.h" -#include <openssl/bio.h> static int null_write(BIO *h, const char *buf, int num); static int null_read(BIO *h, char *buf, int size); diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c index 85d7d661fb..c1f76a24a7 100644 --- a/crypto/bio/bss_sock.c +++ b/crypto/bio/bss_sock.c @@ -58,6 +58,7 @@ #include <stdio.h> #include <errno.h> #define USE_SOCKETS +#include "bio_lcl.h" #include "internal/cryptlib.h" #ifndef OPENSSL_NO_SOCK |