diff options
author | tb <> | 2018-02-17 13:57:14 +0000 |
---|---|---|
committer | tb <> | 2018-02-17 13:57:14 +0000 |
commit | 4bef14eaf860ad986baccf704ff3db6053976558 (patch) | |
tree | bf207cf4ea7d8419a5d46d9d2d450fc612149ea0 /src/lib/libcrypto/bio | |
parent | e1b05f77869d986a0aee6aa4076f008274e98d27 (diff) | |
download | openbsd-4bef14eaf860ad986baccf704ff3db6053976558.tar.gz openbsd-4bef14eaf860ad986baccf704ff3db6053976558.tar.bz2 openbsd-4bef14eaf860ad986baccf704ff3db6053976558.zip |
Provide BIO_meth_{free,new}() and BIO_meth_set_{create,crtl,destroy}()
and BIO_meth_set_{puts,read,write}().
ok jsing
Diffstat (limited to 'src/lib/libcrypto/bio')
-rw-r--r-- | src/lib/libcrypto/bio/bio.h | 13 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bio_meth.c | 82 |
2 files changed, 94 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h index faca125544..3a1577ab37 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.30 2017/04/06 18:25:38 deraadt Exp $ */ | 1 | /* $OpenBSD: bio.h,v 1.31 2018/02/17 13:57:14 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 | * |
@@ -327,6 +327,17 @@ typedef struct bio_f_buffer_ctx_struct { | |||
327 | /* Prefix and suffix callback in ASN1 BIO */ | 327 | /* Prefix and suffix callback in ASN1 BIO */ |
328 | typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg); | 328 | typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg); |
329 | 329 | ||
330 | /* BIO_METHOD accessors */ | ||
331 | BIO_METHOD *BIO_meth_new(int type, const char *name); | ||
332 | void BIO_meth_free(BIO_METHOD *biom); | ||
333 | int BIO_meth_set_write(BIO_METHOD *biom, | ||
334 | int (*write)(BIO *, const char *, int)); | ||
335 | int BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int)); | ||
336 | int BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *)); | ||
337 | int BIO_meth_set_ctrl(BIO_METHOD *biom, | ||
338 | int long (*ctrl)(BIO *, int, long, void *)); | ||
339 | int BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *)); | ||
340 | int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *)); | ||
330 | 341 | ||
331 | /* connect BIO stuff */ | 342 | /* connect BIO stuff */ |
332 | #define BIO_CONN_S_BEFORE 1 | 343 | #define BIO_CONN_S_BEFORE 1 |
diff --git a/src/lib/libcrypto/bio/bio_meth.c b/src/lib/libcrypto/bio/bio_meth.c new file mode 100644 index 0000000000..83e5254304 --- /dev/null +++ b/src/lib/libcrypto/bio/bio_meth.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /* $OpenBSD: bio_meth.c,v 1.1 2018/02/17 13:57:14 tb Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include <stdlib.h> | ||
19 | |||
20 | #include <openssl/bio.h> | ||
21 | |||
22 | BIO_METHOD * | ||
23 | BIO_meth_new(int type, const char *name) | ||
24 | { | ||
25 | BIO_METHOD *biom; | ||
26 | |||
27 | if ((biom = calloc(1, sizeof(*biom))) == NULL) | ||
28 | return NULL; | ||
29 | |||
30 | biom->type = type; | ||
31 | biom->name = name; | ||
32 | |||
33 | return biom; | ||
34 | } | ||
35 | |||
36 | void | ||
37 | BIO_meth_free(BIO_METHOD *biom) | ||
38 | { | ||
39 | free(biom); | ||
40 | } | ||
41 | |||
42 | int | ||
43 | BIO_meth_set_write(BIO_METHOD *biom, int (*write)(BIO *, const char *, int)) | ||
44 | { | ||
45 | biom->bwrite = write; | ||
46 | return 1; | ||
47 | } | ||
48 | |||
49 | int | ||
50 | BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int)) | ||
51 | { | ||
52 | biom->bread = read; | ||
53 | return 1; | ||
54 | } | ||
55 | |||
56 | int | ||
57 | BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *)) | ||
58 | { | ||
59 | biom->bputs = puts; | ||
60 | return 1; | ||
61 | } | ||
62 | |||
63 | int | ||
64 | BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl)(BIO *, int, long, void *)) | ||
65 | { | ||
66 | biom->ctrl = ctrl; | ||
67 | return 1; | ||
68 | } | ||
69 | |||
70 | int | ||
71 | BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *)) | ||
72 | { | ||
73 | biom->create = create; | ||
74 | return 1; | ||
75 | } | ||
76 | |||
77 | int | ||
78 | BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *)) | ||
79 | { | ||
80 | biom->destroy = destroy; | ||
81 | return 1; | ||
82 | } | ||