diff options
-rw-r--r-- | lib/libcrypto/Makefile | 4 | ||||
-rw-r--r-- | lib/libcrypto/Symbols.list | 8 | ||||
-rw-r--r-- | lib/libcrypto/bio/bio.h | 13 | ||||
-rw-r--r-- | lib/libcrypto/bio/bio_meth.c | 82 |
4 files changed, 104 insertions, 3 deletions
diff --git a/lib/libcrypto/Makefile b/lib/libcrypto/Makefile index 5432bab176a..85e6b0ee8d3 100644 --- a/lib/libcrypto/Makefile +++ b/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.23 2017/08/28 17:41:59 jsing Exp $ +# $OpenBSD: Makefile,v 1.24 2018/02/17 13:57:14 tb Exp $ LIB= crypto LIBREBUILD=y @@ -64,7 +64,7 @@ SRCS+= a_time_tm.c SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c # bio/ -SRCS+= bio_lib.c bio_cb.c bio_err.c +SRCS+= bio_lib.c bio_cb.c bio_err.c bio_meth.c SRCS+= bss_mem.c bss_null.c bss_fd.c SRCS+= bss_file.c bss_sock.c bss_conn.c SRCS+= bf_null.c bf_buff.c b_print.c b_dump.c diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 99930ffa17c..bee42ac1641 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -286,6 +286,14 @@ BIO_gethostbyname BIO_gets BIO_indent BIO_int_ctrl +BIO_meth_free +BIO_meth_new +BIO_meth_set_create +BIO_meth_set_ctrl +BIO_meth_set_destroy +BIO_meth_set_puts +BIO_meth_set_read +BIO_meth_set_write BIO_method_name BIO_method_type BIO_new diff --git a/lib/libcrypto/bio/bio.h b/lib/libcrypto/bio/bio.h index faca1255442..3a1577ab37c 100644 --- a/lib/libcrypto/bio/bio.h +++ b/lib/libcrypto/bio/bio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bio.h,v 1.30 2017/04/06 18:25:38 deraadt Exp $ */ +/* $OpenBSD: bio.h,v 1.31 2018/02/17 13:57:14 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -327,6 +327,17 @@ typedef struct bio_f_buffer_ctx_struct { /* Prefix and suffix callback in ASN1 BIO */ typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg); +/* BIO_METHOD accessors */ +BIO_METHOD *BIO_meth_new(int type, const char *name); +void BIO_meth_free(BIO_METHOD *biom); +int BIO_meth_set_write(BIO_METHOD *biom, + int (*write)(BIO *, const char *, int)); +int BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int)); +int BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *)); +int BIO_meth_set_ctrl(BIO_METHOD *biom, + int long (*ctrl)(BIO *, int, long, void *)); +int BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *)); +int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *)); /* connect BIO stuff */ #define BIO_CONN_S_BEFORE 1 diff --git a/lib/libcrypto/bio/bio_meth.c b/lib/libcrypto/bio/bio_meth.c new file mode 100644 index 00000000000..83e5254304b --- /dev/null +++ b/lib/libcrypto/bio/bio_meth.c @@ -0,0 +1,82 @@ +/* $OpenBSD: bio_meth.c,v 1.1 2018/02/17 13:57:14 tb Exp $ */ +/* + * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <stdlib.h> + +#include <openssl/bio.h> + +BIO_METHOD * +BIO_meth_new(int type, const char *name) +{ + BIO_METHOD *biom; + + if ((biom = calloc(1, sizeof(*biom))) == NULL) + return NULL; + + biom->type = type; + biom->name = name; + + return biom; +} + +void +BIO_meth_free(BIO_METHOD *biom) +{ + free(biom); +} + +int +BIO_meth_set_write(BIO_METHOD *biom, int (*write)(BIO *, const char *, int)) +{ + biom->bwrite = write; + return 1; +} + +int +BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int)) +{ + biom->bread = read; + return 1; +} + +int +BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *)) +{ + biom->bputs = puts; + return 1; +} + +int +BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl)(BIO *, int, long, void *)) +{ + biom->ctrl = ctrl; + return 1; +} + +int +BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *)) +{ + biom->create = create; + return 1; +} + +int +BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *)) +{ + biom->destroy = destroy; + return 1; +} |