summaryrefslogtreecommitdiffstats
path: root/providers/common
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-07-09 18:55:44 +0200
committerRichard Levitte <levitte@openssl.org>2020-07-24 16:32:01 +0200
commit853ca12813dee0ec7ac75cfe5f1c9685ffb2d420 (patch)
treef197c54972ae83f64fac3cbba5c54d0b18b2bb0a /providers/common
parent072a9fde7d67a621ebd2c8d1ba22ab6e17da5a88 (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)
Diffstat (limited to 'providers/common')
-rw-r--r--providers/common/bio_prov.c32
-rw-r--r--providers/common/include/prov/bio.h2
2 files changed, 28 insertions, 6 deletions
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, ...);