diff options
author | Richard Levitte <levitte@openssl.org> | 2020-07-09 18:55:44 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-07-24 16:32:01 +0200 |
commit | 853ca12813dee0ec7ac75cfe5f1c9685ffb2d420 (patch) | |
tree | f197c54972ae83f64fac3cbba5c54d0b18b2bb0a | |
parent | 072a9fde7d67a621ebd2c8d1ba22ab6e17da5a88 (diff) |
CORE: Add upcalls for BIO_gets() and BIO_puts()
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12410)
-rw-r--r-- | crypto/provider_core.c | 2 | ||||
-rw-r--r-- | include/openssl/core_dispatch.h | 5 | ||||
-rw-r--r-- | providers/common/bio_prov.c | 32 | ||||
-rw-r--r-- | providers/common/include/prov/bio.h | 2 |
4 files changed, 35 insertions, 6 deletions
diff --git a/crypto/provider_core.c b/crypto/provider_core.c index b6586f904e..79c330383c 100644 --- a/crypto/provider_core.c +++ b/crypto/provider_core.c @@ -1061,6 +1061,8 @@ static const OSSL_DISPATCH core_dispatch_[] = { { OSSL_FUNC_BIO_NEW_MEMBUF, (void (*)(void))BIO_new_mem_buf }, { OSSL_FUNC_BIO_READ_EX, (void (*)(void))BIO_read_ex }, { OSSL_FUNC_BIO_WRITE_EX, (void (*)(void))BIO_write_ex }, + { OSSL_FUNC_BIO_GETS, (void (*)(void))BIO_gets }, + { OSSL_FUNC_BIO_PUTS, (void (*)(void))BIO_puts }, { OSSL_FUNC_BIO_FREE, (void (*)(void))BIO_free }, { OSSL_FUNC_BIO_VPRINTF, (void (*)(void))BIO_vprintf }, { OSSL_FUNC_BIO_VSNPRINTF, (void (*)(void))BIO_vsnprintf }, diff --git a/include/openssl/core_dispatch.h b/include/openssl/core_dispatch.h index 8dba65b556..c3f6c88f46 100644 --- a/include/openssl/core_dispatch.h +++ b/include/openssl/core_dispatch.h @@ -135,6 +135,9 @@ OSSL_CORE_MAKE_FUNC(void, #define OSSL_FUNC_BIO_FREE 44 #define OSSL_FUNC_BIO_VPRINTF 45 #define OSSL_FUNC_BIO_VSNPRINTF 46 +#define OSSL_FUNC_BIO_PUTS 47 +#define OSSL_FUNC_BIO_GETS 48 + OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, (const char *filename, const char *mode)) @@ -143,6 +146,8 @@ OSSL_CORE_MAKE_FUNC(int, BIO_read_ex, (OSSL_CORE_BIO *bio, void *data, size_t data_len, size_t *bytes_read)) OSSL_CORE_MAKE_FUNC(int, BIO_write_ex, (OSSL_CORE_BIO *bio, const void *data, size_t data_len, size_t *written)) +OSSL_CORE_MAKE_FUNC(int, BIO_gets, (OSSL_CORE_BIO *bio, char *buf, int size)) +OSSL_CORE_MAKE_FUNC(int, BIO_puts, (OSSL_CORE_BIO *bio, const char *str)) OSSL_CORE_MAKE_FUNC(int, BIO_free, (OSSL_CORE_BIO *bio)) OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, (OSSL_CORE_BIO *bio, const char *format, va_list args)) diff --git a/providers/common/bio_prov.c b/providers/common/bio_prov.c index c193658c58..fc1f8b2b26 100644 --- a/providers/common/bio_prov.c +++ b/providers/common/bio_prov.c @@ -16,6 +16,8 @@ static OSSL_FUNC_BIO_new_file_fn *c_bio_new_file = NULL; static OSSL_FUNC_BIO_new_membuf_fn *c_bio_new_membuf = NULL; static OSSL_FUNC_BIO_read_ex_fn *c_bio_read_ex = NULL; static OSSL_FUNC_BIO_write_ex_fn *c_bio_write_ex = NULL; +static OSSL_FUNC_BIO_gets_fn *c_bio_gets = NULL; +static OSSL_FUNC_BIO_puts_fn *c_bio_puts = NULL; static OSSL_FUNC_BIO_free_fn *c_bio_free = NULL; static OSSL_FUNC_BIO_vprintf_fn *c_bio_vprintf = NULL; @@ -39,6 +41,14 @@ int ossl_prov_bio_from_dispatch(const OSSL_DISPATCH *fns) if (c_bio_write_ex == NULL) c_bio_write_ex = OSSL_FUNC_BIO_write_ex(fns); break; + case OSSL_FUNC_BIO_GETS: + if (c_bio_gets == NULL) + c_bio_gets = OSSL_FUNC_BIO_gets(fns); + break; + case OSSL_FUNC_BIO_PUTS: + if (c_bio_puts == NULL) + c_bio_puts = OSSL_FUNC_BIO_puts(fns); + break; case OSSL_FUNC_BIO_FREE: if (c_bio_free == NULL) c_bio_free = OSSL_FUNC_BIO_free(fns); @@ -83,6 +93,20 @@ int ossl_prov_bio_write_ex(OSSL_CORE_BIO *bio, const void *data, size_t data_len return c_bio_write_ex(bio, data, data_len, written); } +int ossl_prov_bio_gets(OSSL_CORE_BIO *bio, char *buf, int size) +{ + if (c_bio_gets == NULL) + return -1; + return c_bio_gets(bio, buf, size); +} + +int ossl_prov_bio_puts(OSSL_CORE_BIO *bio, const char *str) +{ + if (c_bio_puts == NULL) + return -1; + return c_bio_puts(bio, str); +} + int ossl_prov_bio_free(OSSL_CORE_BIO *bio) { if (c_bio_free == NULL) @@ -134,16 +158,12 @@ static long bio_core_ctrl(BIO *bio, int cmd, long num, void *ptr) static int bio_core_gets(BIO *bio, char *buf, int size) { - /* We don't support this */ - assert(0); - return -1; + return ossl_prov_bio_gets(BIO_get_data(bio), buf, size); } static int bio_core_puts(BIO *bio, const char *str) { - /* We don't support this */ - assert(0); - return -1; + return ossl_prov_bio_puts(BIO_get_data(bio), str); } static int bio_core_new(BIO *bio) diff --git a/providers/common/include/prov/bio.h b/providers/common/include/prov/bio.h index c63f6b5da5..3cef89ce18 100644 --- a/providers/common/include/prov/bio.h +++ b/providers/common/include/prov/bio.h @@ -20,6 +20,8 @@ int ossl_prov_bio_read_ex(OSSL_CORE_BIO *bio, void *data, size_t data_len, size_t *bytes_read); int ossl_prov_bio_write_ex(OSSL_CORE_BIO *bio, const void *data, size_t data_len, size_t *written); +int ossl_prov_bio_gets(OSSL_CORE_BIO *bio, char *buf, int size); +int ossl_prov_bio_puts(OSSL_CORE_BIO *bio, const char *str); int ossl_prov_bio_free(OSSL_CORE_BIO *bio); int ossl_prov_bio_vprintf(OSSL_CORE_BIO *bio, const char *format, va_list ap); int ossl_prov_bio_printf(OSSL_CORE_BIO *bio, const char *format, ...); |