From c7e739d82bb718f906682e16052ea26ba74bc91f Mon Sep 17 00:00:00 2001 From: tb <> Date: Thu, 24 Oct 2019 12:39:26 +0000 Subject: [PATCH] The ber_* namespace is used by liblber since time immemorial, so move our BER API to the unused ober_* prefix to avoid some breakage in ports. Problem diagnosed by jmatthew with ber_free() in samba, but there are many others as pointed out by sthen. tests & ok rob ok sthen (who had an almost identical diff for libutil) "go head hit it" deraadt --- src/lib/libutil/Makefile | 7 +- src/lib/libutil/Symbols.map | 90 +++--- src/lib/libutil/ber.c | 304 +++++++++--------- src/lib/libutil/ber.h | 92 +++--- .../{ber_add_string.3 => ober_add_string.3} | 124 +++---- .../{ber_get_string.3 => ober_get_string.3} | 98 +++--- .../libutil/{ber_oid_cmp.3 => ober_oid_cmp.3} | 38 +-- ...r_read_elements.3 => ober_read_elements.3} | 54 ++-- .../{ber_set_header.3 => ober_set_header.3} | 66 ++-- src/lib/libutil/shlib_version | 4 +- 10 files changed, 439 insertions(+), 438 deletions(-) rename src/lib/libutil/{ber_add_string.3 => ober_add_string.3} (63%) rename src/lib/libutil/{ber_get_string.3 => ober_get_string.3} (62%) rename src/lib/libutil/{ber_oid_cmp.3 => ober_oid_cmp.3} (78%) rename src/lib/libutil/{ber_read_elements.3 => ober_read_elements.3} (86%) rename src/lib/libutil/{ber_set_header.3 => ober_set_header.3} (70%) diff --git a/src/lib/libutil/Makefile b/src/lib/libutil/Makefile index 24439544..c0d889a5 100644 --- a/src/lib/libutil/Makefile +++ b/src/lib/libutil/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.43 2019/08/30 03:57:56 deraadt Exp $ +# $OpenBSD: Makefile,v 1.44 2019/10/24 12:39:26 tb Exp $ # $NetBSD: Makefile,v 1.8 1996/05/16 07:03:28 thorpej Exp $ LIB= util @@ -12,11 +12,12 @@ SRCS= bcrypt_pbkdf.c ber.c check_expire.c duid.c getmaxpartitions.c \ login_fbtab.c uucplock.c fparseln.c opendisk.c pidfile.c \ fmt_scaled.c imsg.c imsg-buffer.c pkcs5_pbkdf2.c -MAN= bcrypt_pbkdf.3 ber_add_string.3 ber_get_string.3 ber_oid_cmp.3 \ - ber_read_elements.3 ber_set_header.3 \ +MAN= bcrypt_pbkdf.3 \ check_expire.3 getmaxpartitions.3 \ getrawpartition.3 \ isduid.3 login.3 \ + ober_add_string.3 ober_get_string.3 ober_oid_cmp.3 \ + ober_read_elements.3 ober_set_header.3 \ opendev.3 openpty.3 pw_init.3 pw_lock.3 readlabelfs.3 uu_lock.3 \ fparseln.3 opendisk.3 login_fbtab.3 pidfile.3 fmt_scaled.3 imsg_init.3 \ pkcs5_pbkdf2.3 diff --git a/src/lib/libutil/Symbols.map b/src/lib/libutil/Symbols.map index 7bb60515..a9e2059a 100644 --- a/src/lib/libutil/Symbols.map +++ b/src/lib/libutil/Symbols.map @@ -9,51 +9,6 @@ { global: bcrypt_pbkdf; - ber_add_bitstring; - ber_add_boolean; - ber_add_enumerated; - ber_add_eoc; - ber_add_integer; - ber_add_noid; - ber_add_nstring; - ber_add_null; - ber_add_oid; - ber_add_oidstring; - ber_add_ostring; - ber_add_sequence; - ber_add_set; - ber_add_string; - ber_calc_len; - ber_free; - ber_free_element; - ber_free_elements; - ber_get_bitstring; - ber_get_boolean; - ber_get_element; - ber_get_enumerated; - ber_get_eoc; - ber_get_integer; - ber_get_nstring; - ber_get_null; - ber_get_oid; - ber_get_ostring; - ber_get_string; - ber_get_writebuf; - ber_getpos; - ber_link_elements; - ber_oid2ber; - ber_oid_cmp; - ber_printf_elements; - ber_read_elements; - ber_replace_elements; - ber_scanf_elements; - ber_set_application; - ber_set_header; - ber_set_readbuf; - ber_set_writecallback; - ber_string2oid; - ber_unlink_elements; - ber_write_elements; fdforkpty; fdopenpty; fmt_scaled; @@ -95,6 +50,51 @@ msgbuf_drain; msgbuf_init; msgbuf_write; + ober_add_bitstring; + ober_add_boolean; + ober_add_enumerated; + ober_add_eoc; + ober_add_integer; + ober_add_noid; + ober_add_nstring; + ober_add_null; + ober_add_oid; + ober_add_oidstring; + ober_add_ostring; + ober_add_sequence; + ober_add_set; + ober_add_string; + ober_calc_len; + ober_free; + ober_free_element; + ober_free_elements; + ober_get_bitstring; + ober_get_boolean; + ober_get_element; + ober_get_enumerated; + ober_get_eoc; + ober_get_integer; + ober_get_nstring; + ober_get_null; + ober_get_oid; + ober_get_ostring; + ober_get_string; + ober_get_writebuf; + ober_getpos; + ober_link_elements; + ober_oid2ber; + ober_oid_cmp; + ober_printf_elements; + ober_read_elements; + ober_replace_elements; + ober_scanf_elements; + ober_set_application; + ober_set_header; + ober_set_readbuf; + ober_set_writecallback; + ober_string2oid; + ober_unlink_elements; + ober_write_elements; ohash_create_entry; ohash_delete; ohash_entries; diff --git a/src/lib/libutil/ber.c b/src/lib/libutil/ber.c index 75aa64ff..0e1914c5 100644 --- a/src/lib/libutil/ber.c +++ b/src/lib/libutil/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.14 2019/08/15 06:11:18 martijn Exp $ */ +/* $OpenBSD: ber.c,v 1.15 2019/10/24 12:39:26 tb Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter @@ -38,16 +38,16 @@ #define BER_TAG_TYPE_MASK 0x7f #define BER_CLASS_SHIFT 6 -static int ber_dump_element(struct ber *ber, struct ber_element *root); -static void ber_dump_header(struct ber *ber, struct ber_element *root); -static void ber_putc(struct ber *ber, u_char c); -static void ber_write(struct ber *ber, void *buf, size_t len); +static int ober_dump_element(struct ber *ber, struct ber_element *root); +static void ober_dump_header(struct ber *ber, struct ber_element *root); +static void ober_putc(struct ber *ber, u_char c); +static void ober_write(struct ber *ber, void *buf, size_t len); static ssize_t get_id(struct ber *b, unsigned int *tag, int *class, int *cstruct); static ssize_t get_len(struct ber *b, ssize_t *len); -static ssize_t ber_read_element(struct ber *ber, struct ber_element *elm); -static ssize_t ber_getc(struct ber *b, u_char *c); -static ssize_t ber_read(struct ber *ber, void *buf, size_t len); +static ssize_t ober_read_element(struct ber *ber, struct ber_element *elm); +static ssize_t ober_getc(struct ber *b, u_char *c); +static ssize_t ober_read(struct ber *ber, void *buf, size_t len); #ifdef DEBUG #define DPRINTF(...) printf(__VA_ARGS__) @@ -56,7 +56,7 @@ static ssize_t ber_read(struct ber *ber, void *buf, size_t len); #endif struct ber_element * -ber_get_element(unsigned int encoding) +ober_get_element(unsigned int encoding) { struct ber_element *elm; @@ -64,13 +64,13 @@ ber_get_element(unsigned int encoding) return NULL; elm->be_encoding = encoding; - ber_set_header(elm, BER_CLASS_UNIVERSAL, BER_TYPE_DEFAULT); + ober_set_header(elm, BER_CLASS_UNIVERSAL, BER_TYPE_DEFAULT); return elm; } void -ber_set_header(struct ber_element *elm, int class, unsigned int type) +ober_set_header(struct ber_element *elm, int class, unsigned int type) { elm->be_class = class & BER_CLASS_MASK; if (type == BER_TYPE_DEFAULT) @@ -79,7 +79,7 @@ ber_set_header(struct ber_element *elm, int class, unsigned int type) } void -ber_link_elements(struct ber_element *prev, struct ber_element *elm) +ober_link_elements(struct ber_element *prev, struct ber_element *elm) { if (prev != NULL) { if ((prev->be_encoding == BER_TYPE_SEQUENCE || @@ -92,7 +92,7 @@ ber_link_elements(struct ber_element *prev, struct ber_element *elm) } struct ber_element * -ber_unlink_elements(struct ber_element *prev) +ober_unlink_elements(struct ber_element *prev) { struct ber_element *elm; @@ -110,53 +110,53 @@ ber_unlink_elements(struct ber_element *prev) } void -ber_replace_elements(struct ber_element *prev, struct ber_element *new) +ober_replace_elements(struct ber_element *prev, struct ber_element *new) { struct ber_element *ber, *next; - ber = ber_unlink_elements(prev); - next = ber_unlink_elements(ber); - ber_link_elements(new, next); - ber_link_elements(prev, new); + ber = ober_unlink_elements(prev); + next = ober_unlink_elements(ber); + ober_link_elements(new, next); + ober_link_elements(prev, new); /* cleanup old element */ - ber_free_elements(ber); + ober_free_elements(ber); } struct ber_element * -ber_add_sequence(struct ber_element *prev) +ober_add_sequence(struct ber_element *prev) { struct ber_element *elm; - if ((elm = ber_get_element(BER_TYPE_SEQUENCE)) == NULL) + if ((elm = ober_get_element(BER_TYPE_SEQUENCE)) == NULL) return NULL; - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } struct ber_element * -ber_add_set(struct ber_element *prev) +ober_add_set(struct ber_element *prev) { struct ber_element *elm; - if ((elm = ber_get_element(BER_TYPE_SET)) == NULL) + if ((elm = ober_get_element(BER_TYPE_SET)) == NULL) return NULL; - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } struct ber_element * -ber_add_enumerated(struct ber_element *prev, long long val) +ober_add_enumerated(struct ber_element *prev, long long val) { struct ber_element *elm; u_int i, len = 0; u_char cur, last = 0; - if ((elm = ber_get_element(BER_TYPE_ENUMERATED)) == NULL) + if ((elm = ober_get_element(BER_TYPE_ENUMERATED)) == NULL) return NULL; elm->be_numeric = val; @@ -173,19 +173,19 @@ ber_add_enumerated(struct ber_element *prev, long long val) } elm->be_len = len + 1; - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } struct ber_element * -ber_add_integer(struct ber_element *prev, long long val) +ober_add_integer(struct ber_element *prev, long long val) { struct ber_element *elm; u_int i, len = 0; u_char cur, last = 0; - if ((elm = ber_get_element(BER_TYPE_INTEGER)) == NULL) + if ((elm = ober_get_element(BER_TYPE_INTEGER)) == NULL) return NULL; elm->be_numeric = val; @@ -202,13 +202,13 @@ ber_add_integer(struct ber_element *prev, long long val) } elm->be_len = len + 1; - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } int -ber_get_integer(struct ber_element *elm, long long *n) +ober_get_integer(struct ber_element *elm, long long *n) { if (elm->be_encoding != BER_TYPE_INTEGER) return -1; @@ -218,7 +218,7 @@ ber_get_integer(struct ber_element *elm, long long *n) } int -ber_get_enumerated(struct ber_element *elm, long long *n) +ober_get_enumerated(struct ber_element *elm, long long *n) { if (elm->be_encoding != BER_TYPE_ENUMERATED) return -1; @@ -228,23 +228,23 @@ ber_get_enumerated(struct ber_element *elm, long long *n) } struct ber_element * -ber_add_boolean(struct ber_element *prev, int bool) +ober_add_boolean(struct ber_element *prev, int bool) { struct ber_element *elm; - if ((elm = ber_get_element(BER_TYPE_BOOLEAN)) == NULL) + if ((elm = ober_get_element(BER_TYPE_BOOLEAN)) == NULL) return NULL; elm->be_numeric = bool ? 0xff : 0; elm->be_len = 1; - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } int -ber_get_boolean(struct ber_element *elm, int *b) +ober_get_boolean(struct ber_element *elm, int *b) { if (elm->be_encoding != BER_TYPE_BOOLEAN) return -1; @@ -254,20 +254,20 @@ ber_get_boolean(struct ber_element *elm, int *b) } struct ber_element * -ber_add_string(struct ber_element *prev, const char *string) +ober_add_string(struct ber_element *prev, const char *string) { - return ber_add_nstring(prev, string, strlen(string)); + return ober_add_nstring(prev, string, strlen(string)); } struct ber_element * -ber_add_nstring(struct ber_element *prev, const char *string0, size_t len) +ober_add_nstring(struct ber_element *prev, const char *string0, size_t len) { struct ber_element *elm; char *string; if ((string = calloc(1, len + 1)) == NULL) return NULL; - if ((elm = ber_get_element(BER_TYPE_OCTETSTRING)) == NULL) { + if ((elm = ober_get_element(BER_TYPE_OCTETSTRING)) == NULL) { free(string); return NULL; } @@ -277,19 +277,19 @@ ber_add_nstring(struct ber_element *prev, const char *string0, size_t len) elm->be_len = len; elm->be_free = 1; /* free string on cleanup */ - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } struct ber_element * -ber_add_ostring(struct ber_element *prev, struct ber_octetstring *s) +ober_add_ostring(struct ber_element *prev, struct ber_octetstring *s) { - return ber_add_nstring(prev, s->ostr_val, s->ostr_len); + return ober_add_nstring(prev, s->ostr_val, s->ostr_len); } int -ber_get_string(struct ber_element *elm, char **s) +ober_get_string(struct ber_element *elm, char **s) { if (elm->be_encoding != BER_TYPE_OCTETSTRING) return -1; @@ -304,7 +304,7 @@ ber_get_string(struct ber_element *elm, char **s) } int -ber_get_nstring(struct ber_element *elm, void **p, size_t *len) +ober_get_nstring(struct ber_element *elm, void **p, size_t *len) { if (elm->be_encoding != BER_TYPE_OCTETSTRING) return -1; @@ -315,7 +315,7 @@ ber_get_nstring(struct ber_element *elm, void **p, size_t *len) } int -ber_get_ostring(struct ber_element *elm, struct ber_octetstring *s) +ober_get_ostring(struct ber_element *elm, struct ber_octetstring *s) { if (elm->be_encoding != BER_TYPE_OCTETSTRING) return -1; @@ -326,14 +326,14 @@ ber_get_ostring(struct ber_element *elm, struct ber_octetstring *s) } struct ber_element * -ber_add_bitstring(struct ber_element *prev, const void *v0, size_t len) +ober_add_bitstring(struct ber_element *prev, const void *v0, size_t len) { struct ber_element *elm; void *v; if ((v = calloc(1, len)) == NULL) return NULL; - if ((elm = ber_get_element(BER_TYPE_BITSTRING)) == NULL) { + if ((elm = ober_get_element(BER_TYPE_BITSTRING)) == NULL) { free(v); return NULL; } @@ -343,13 +343,13 @@ ber_add_bitstring(struct ber_element *prev, const void *v0, size_t len) elm->be_len = len; elm->be_free = 1; /* free string on cleanup */ - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } int -ber_get_bitstring(struct ber_element *elm, void **v, size_t *len) +ober_get_bitstring(struct ber_element *elm, void **v, size_t *len) { if (elm->be_encoding != BER_TYPE_BITSTRING) return -1; @@ -360,20 +360,20 @@ ber_get_bitstring(struct ber_element *elm, void **v, size_t *len) } struct ber_element * -ber_add_null(struct ber_element *prev) +ober_add_null(struct ber_element *prev) { struct ber_element *elm; - if ((elm = ber_get_element(BER_TYPE_NULL)) == NULL) + if ((elm = ober_get_element(BER_TYPE_NULL)) == NULL) return NULL; - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } int -ber_get_null(struct ber_element *elm) +ober_get_null(struct ber_element *elm) { if (elm->be_encoding != BER_TYPE_NULL) return -1; @@ -382,20 +382,20 @@ ber_get_null(struct ber_element *elm) } struct ber_element * -ber_add_eoc(struct ber_element *prev) +ober_add_eoc(struct ber_element *prev) { struct ber_element *elm; - if ((elm = ber_get_element(BER_TYPE_EOC)) == NULL) + if ((elm = ober_get_element(BER_TYPE_EOC)) == NULL) return NULL; - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return elm; } int -ber_get_eoc(struct ber_element *elm) +ober_get_eoc(struct ber_element *elm) { if (elm->be_encoding != BER_TYPE_EOC) return -1; @@ -404,7 +404,7 @@ ber_get_eoc(struct ber_element *elm) } size_t -ber_oid2ber(struct ber_oid *o, u_int8_t *buf, size_t len) +ober_oid2ber(struct ber_oid *o, u_int8_t *buf, size_t len) { u_int32_t v; u_int i, j = 0, k; @@ -431,7 +431,7 @@ ber_oid2ber(struct ber_oid *o, u_int8_t *buf, size_t len) } int -ber_string2oid(const char *oidstr, struct ber_oid *o) +ober_string2oid(const char *oidstr, struct ber_oid *o) { char *sp, *p, str[BUFSIZ]; const char *errstr; @@ -453,7 +453,7 @@ ber_string2oid(const char *oidstr, struct ber_oid *o) } int -ber_oid_cmp(struct ber_oid *a, struct ber_oid *b) +ober_oid_cmp(struct ber_oid *a, struct ber_oid *b) { size_t i; for (i = 0; i < a->bo_n && i < b->bo_n; i++) { @@ -479,16 +479,16 @@ ber_oid_cmp(struct ber_oid *a, struct ber_oid *b) } struct ber_element * -ber_add_oid(struct ber_element *prev, struct ber_oid *o) +ober_add_oid(struct ber_element *prev, struct ber_oid *o) { struct ber_element *elm; u_int8_t *buf; size_t len; - if ((elm = ber_get_element(BER_TYPE_OBJECT)) == NULL) + if ((elm = ober_get_element(BER_TYPE_OBJECT)) == NULL) return (NULL); - if ((len = ber_oid2ber(o, NULL, 0)) == 0) + if ((len = ober_oid2ber(o, NULL, 0)) == 0) goto fail; if ((buf = calloc(1, len)) == NULL) @@ -498,20 +498,20 @@ ber_add_oid(struct ber_element *prev, struct ber_oid *o) elm->be_len = len; elm->be_free = 1; - if (ber_oid2ber(o, buf, len) != len) + if (ober_oid2ber(o, buf, len) != len) goto fail; - ber_link_elements(prev, elm); + ober_link_elements(prev, elm); return (elm); fail: - ber_free_elements(elm); + ober_free_elements(elm); return (NULL); } struct ber_element * -ber_add_noid(struct ber_element *prev, struct ber_oid *o, int n) +ober_add_noid(struct ber_element *prev, struct ber_oid *o, int n) { struct ber_oid no; @@ -520,22 +520,22 @@ ber_add_noid(struct ber_element *prev, struct ber_oid *o, int n) no.bo_n = n; bcopy(&o->bo_id, &no.bo_id, sizeof(no.bo_id)); - return (ber_add_oid(prev, &no)); + return (ober_add_oid(prev, &no)); } struct ber_element * -ber_add_oidstring(struct ber_element *prev, const char *oidstr) +ober_add_oidstring(struct ber_element *prev, const char *oidstr) { struct ber_oid o; - if (ber_string2oid(oidstr, &o) == -1) + if (ober_string2oid(oidstr, &o) == -1) return (NULL); - return (ber_add_oid(prev, &o)); + return (ober_add_oid(prev, &o)); } int -ber_get_oid(struct ber_element *elm, struct ber_oid *o) +ober_get_oid(struct ber_element *elm, struct ber_oid *o) { u_int8_t *buf; size_t len, i = 0, j = 0; @@ -561,7 +561,7 @@ ber_get_oid(struct ber_element *elm, struct ber_oid *o) } struct ber_element * -ber_printf_elements(struct ber_element *ber, char *fmt, ...) +ober_printf_elements(struct ber_element *ber, char *fmt, ...) { va_list ap; int d, class; @@ -579,69 +579,69 @@ ber_printf_elements(struct ber_element *ber, char *fmt, ...) case 'B': p = va_arg(ap, void *); len = va_arg(ap, size_t); - if ((ber = ber_add_bitstring(ber, p, len)) == NULL) + if ((ber = ober_add_bitstring(ber, p, len)) == NULL) goto fail; break; case 'b': d = va_arg(ap, int); - if ((ber = ber_add_boolean(ber, d)) == NULL) + if ((ber = ober_add_boolean(ber, d)) == NULL) goto fail; break; case 'd': d = va_arg(ap, int); - if ((ber = ber_add_integer(ber, d)) == NULL) + if ((ber = ober_add_integer(ber, d)) == NULL) goto fail; break; case 'e': e = va_arg(ap, struct ber_element *); - ber_link_elements(ber, e); + ober_link_elements(ber, e); break; case 'E': i = va_arg(ap, long long); - if ((ber = ber_add_enumerated(ber, i)) == NULL) + if ((ber = ober_add_enumerated(ber, i)) == NULL) goto fail; break; case 'i': i = va_arg(ap, long long); - if ((ber = ber_add_integer(ber, i)) == NULL) + if ((ber = ober_add_integer(ber, i)) == NULL) goto fail; break; case 'O': o = va_arg(ap, struct ber_oid *); - if ((ber = ber_add_oid(ber, o)) == NULL) + if ((ber = ober_add_oid(ber, o)) == NULL) goto fail; break; case 'o': s = va_arg(ap, char *); - if ((ber = ber_add_oidstring(ber, s)) == NULL) + if ((ber = ober_add_oidstring(ber, s)) == NULL) goto fail; break; case 's': s = va_arg(ap, char *); - if ((ber = ber_add_string(ber, s)) == NULL) + if ((ber = ober_add_string(ber, s)) == NULL) goto fail; break; case 't': class = va_arg(ap, int); type = va_arg(ap, unsigned int); - ber_set_header(ber, class, type); + ober_set_header(ber, class, type); break; case 'x': s = va_arg(ap, char *); len = va_arg(ap, size_t); - if ((ber = ber_add_nstring(ber, s, len)) == NULL) + if ((ber = ober_add_nstring(ber, s, len)) == NULL) goto fail; break; case '0': - if ((ber = ber_add_null(ber)) == NULL) + if ((ber = ober_add_null(ber)) == NULL) goto fail; break; case '{': - if ((ber = sub = ber_add_sequence(ber)) == NULL) + if ((ber = sub = ober_add_sequence(ber)) == NULL) goto fail; break; case '(': - if ((ber = sub = ber_add_set(ber)) == NULL) + if ((ber = sub = ober_add_set(ber)) == NULL) goto fail; break; case '}': @@ -649,7 +649,7 @@ ber_printf_elements(struct ber_element *ber, char *fmt, ...) ber = sub; break; case '.': - if ((e = ber_add_eoc(ber)) == NULL) + if ((e = ober_add_eoc(ber)) == NULL) goto fail; ber = e; break; @@ -661,12 +661,12 @@ ber_printf_elements(struct ber_element *ber, char *fmt, ...) return (ber); fail: - ber_free_elements(ber); + ober_free_elements(ber); return (NULL); } int -ber_scanf_elements(struct ber_element *ber, char *fmt, ...) +ober_scanf_elements(struct ber_element *ber, char *fmt, ...) { #define _MAX_SEQ 128 va_list ap; @@ -690,19 +690,19 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) case 'B': ptr = va_arg(ap, void **); len = va_arg(ap, size_t *); - if (ber_get_bitstring(ber, ptr, len) == -1) + if (ober_get_bitstring(ber, ptr, len) == -1) goto fail; ret++; break; case 'b': d = va_arg(ap, int *); - if (ber_get_boolean(ber, d) == -1) + if (ober_get_boolean(ber, d) == -1) goto fail; ret++; break; case 'd': d = va_arg(ap, int *); - if (ber_get_integer(ber, &l) == -1) + if (ober_get_integer(ber, &l) == -1) goto fail; *d = l; ret++; @@ -714,19 +714,19 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) continue; case 'E': i = va_arg(ap, long long *); - if (ber_get_enumerated(ber, i) == -1) + if (ober_get_enumerated(ber, i) == -1) goto fail; ret++; break; case 'i': i = va_arg(ap, long long *); - if (ber_get_integer(ber, i) == -1) + if (ober_get_integer(ber, i) == -1) goto fail; ret++; break; case 'o': o = va_arg(ap, struct ber_oid *); - if (ber_get_oid(ber, o) == -1) + if (ober_get_oid(ber, o) == -1) goto fail; ret++; break; @@ -735,7 +735,7 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) break; case 's': s = va_arg(ap, char **); - if (ber_get_string(ber, s) == -1) + if (ober_get_string(ber, s) == -1) goto fail; ret++; break; @@ -749,7 +749,7 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) case 'x': ptr = va_arg(ap, void **); len = va_arg(ap, size_t *); - if (ber_get_nstring(ber, ptr, len) == -1) + if (ober_get_nstring(ber, ptr, len) == -1) goto fail; ret++; break; @@ -765,7 +765,7 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) break; case 'p': pos = va_arg(ap, off_t *); - *pos = ber_getpos(ber); + *pos = ober_getpos(ber); ret++; continue; case '{': @@ -802,7 +802,7 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) } ssize_t -ber_get_writebuf(struct ber *b, void **buf) +ober_get_writebuf(struct ber *b, void **buf) { if (b->br_wbuf == NULL) return -1; @@ -822,12 +822,12 @@ ber_get_writebuf(struct ber *b, void **buf) * -1 on failure and sets errno */ ssize_t -ber_write_elements(struct ber *ber, struct ber_element *root) +ober_write_elements(struct ber *ber, struct ber_element *root) { size_t len; /* calculate length because only the definite form is required */ - len = ber_calc_len(root); + len = ober_calc_len(root); DPRINTF("write ber element of %zd bytes length\n", len); if (ber->br_wbuf != NULL && ber->br_wbuf + len > ber->br_wend) { @@ -843,14 +843,14 @@ ber_write_elements(struct ber *ber, struct ber_element *root) /* reset write pointer */ ber->br_wptr = ber->br_wbuf; - if (ber_dump_element(ber, root) == -1) + if (ober_dump_element(ber, root) == -1) return -1; return (len); } void -ber_set_readbuf(struct ber *b, void *buf, size_t len) +ober_set_readbuf(struct ber *b, void *buf, size_t len) { b->br_rbuf = b->br_rptr = buf; b->br_rend = (u_int8_t *)buf + len; @@ -870,21 +870,21 @@ ber_set_readbuf(struct ber *b, void *buf, size_t len) * NULL, type mismatch or read error */ struct ber_element * -ber_read_elements(struct ber *ber, struct ber_element *elm) +ober_read_elements(struct ber *ber, struct ber_element *elm) { struct ber_element *root = elm; if (root == NULL) { - if ((root = ber_get_element(0)) == NULL) + if ((root = ober_get_element(0)) == NULL) return NULL; } DPRINTF("read ber elements, root %p\n", root); - if (ber_read_element(ber, root) == -1) { + if (ober_read_element(ber, root) == -1) { /* Cleanup if root was allocated by us */ if (elm == NULL) - ber_free_elements(root); + ober_free_elements(root); return NULL; } @@ -892,17 +892,17 @@ ber_read_elements(struct ber *ber, struct ber_element *elm) } off_t -ber_getpos(struct ber_element *elm) +ober_getpos(struct ber_element *elm) { return elm->be_offs; } void -ber_free_element(struct ber_element *root) +ober_free_element(struct ber_element *root) { if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE || root->be_encoding == BER_TYPE_SET)) - ber_free_elements(root->be_sub); + ober_free_elements(root->be_sub); if (root->be_free && (root->be_encoding == BER_TYPE_OCTETSTRING || root->be_encoding == BER_TYPE_BITSTRING || root->be_encoding == BER_TYPE_OBJECT)) @@ -911,15 +911,15 @@ ber_free_element(struct ber_element *root) } void -ber_free_elements(struct ber_element *root) +ober_free_elements(struct ber_element *root) { if (root == NULL) return; if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE || root->be_encoding == BER_TYPE_SET)) - ber_free_elements(root->be_sub); + ober_free_elements(root->be_sub); if (root->be_next) - ber_free_elements(root->be_next); + ober_free_elements(root->be_next); if (root->be_free && (root->be_encoding == BER_TYPE_OCTETSTRING || root->be_encoding == BER_TYPE_BITSTRING || root->be_encoding == BER_TYPE_OBJECT)) @@ -928,7 +928,7 @@ ber_free_elements(struct ber_element *root) } size_t -ber_calc_len(struct ber_element *root) +ober_calc_len(struct ber_element *root) { unsigned int t; size_t s; @@ -937,7 +937,7 @@ ber_calc_len(struct ber_element *root) /* calculate the real length of a sequence or set */ if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE || root->be_encoding == BER_TYPE_SET)) - root->be_len = ber_calc_len(root->be_sub); + root->be_len = ober_calc_len(root->be_sub); /* fix header length for extended types */ if (root->be_type > BER_TYPE_SINGLE_MAX) @@ -949,7 +949,7 @@ ber_calc_len(struct ber_element *root) /* calculate the length of the following elements */ if (root->be_next) - size += ber_calc_len(root->be_next); + size += ober_calc_len(root->be_next); /* This is an empty element, do not use a minimal size */ if (root->be_class == BER_CLASS_UNIVERSAL && @@ -960,13 +960,13 @@ ber_calc_len(struct ber_element *root) } void -ber_set_application(struct ber *b, unsigned int (*cb)(struct ber_element *)) +ober_set_application(struct ber *b, unsigned int (*cb)(struct ber_element *)) { b->br_application = cb; } void -ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t), +ober_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t), void *arg) { elm->be_cb = cb; @@ -974,7 +974,7 @@ ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t), } void -ber_free(struct ber *b) +ober_free(struct ber *b) { free(b->br_wbuf); } @@ -984,13 +984,13 @@ ber_free(struct ber *b) */ static int -ber_dump_element(struct ber *ber, struct ber_element *root) +ober_dump_element(struct ber *ber, struct ber_element *root) { unsigned long long l; int i; uint8_t u; - ber_dump_header(ber, root); + ober_dump_header(ber, root); if (root->be_cb) root->be_cb(root->be_cbarg, ber->br_wptr - ber->br_wbuf); @@ -1001,31 +1001,31 @@ ber_dump_element(struct ber *ber, struct ber_element *root) l = (unsigned long long)root->be_numeric; for (i = root->be_len; i > 0; i--) { u = (l >> ((i - 1) * 8)) & 0xff; - ber_putc(ber, u); + ober_putc(ber, u); } break; case BER_TYPE_BITSTRING: case BER_TYPE_OCTETSTRING: case BER_TYPE_OBJECT: - ber_write(ber, root->be_val, root->be_len); + ober_write(ber, root->be_val, root->be_len); break; case BER_TYPE_NULL: /* no payload */ case BER_TYPE_EOC: break; case BER_TYPE_SEQUENCE: case BER_TYPE_SET: - if (root->be_sub && ber_dump_element(ber, root->be_sub) == -1) + if (root->be_sub && ober_dump_element(ber, root->be_sub) == -1) return -1; break; } if (root->be_next == NULL) return 0; - return ber_dump_element(ber, root->be_next); + return ober_dump_element(ber, root->be_next); } static void -ber_dump_header(struct ber *ber, struct ber_element *root) +ober_dump_header(struct ber *ber, struct ber_element *root) { u_char id = 0, t, buf[5]; unsigned int type; @@ -1039,14 +1039,14 @@ ber_dump_header(struct ber *ber, struct ber_element *root) root->be_encoding == BER_TYPE_SET) id |= BER_TYPE_CONSTRUCTED; - ber_putc(ber, id); + ober_putc(ber, id); } else { id = BER_TAG_MASK | (root->be_class << BER_CLASS_SHIFT); if (root->be_encoding == BER_TYPE_SEQUENCE || root->be_encoding == BER_TYPE_SET) id |= BER_TYPE_CONSTRUCTED; - ber_putc(ber, id); + ober_putc(ber, id); for (t = 0, type = root->be_type; type > 0; type >>= 7) buf[t++] = type & ~BER_TAG_MORE; @@ -1054,26 +1054,26 @@ ber_dump_header(struct ber *ber, struct ber_element *root) while (t-- > 0) { if (t > 0) buf[t] |= BER_TAG_MORE; - ber_putc(ber, buf[t]); + ober_putc(ber, buf[t]); } } if (root->be_len < BER_TAG_MORE) { /* short form */ - ber_putc(ber, root->be_len); + ober_putc(ber, root->be_len); } else { for (t = 0, size = root->be_len; size > 0; size >>= 8) buf[t++] = size & 0xff; - ber_putc(ber, t | BER_TAG_MORE); + ober_putc(ber, t | BER_TAG_MORE); while (t > 0) - ber_putc(ber, buf[--t]); + ober_putc(ber, buf[--t]); } } static void -ber_putc(struct ber *ber, u_char c) +ober_putc(struct ber *ber, u_char c) { if (ber->br_wptr + 1 <= ber->br_wend) *ber->br_wptr = c; @@ -1081,7 +1081,7 @@ ber_putc(struct ber *ber, u_char c) } static void -ber_write(struct ber *ber, void *buf, size_t len) +ober_write(struct ber *ber, void *buf, size_t len) { if (ber->br_wptr + len <= ber->br_wend) bcopy(buf, ber->br_wptr, len); @@ -1098,7 +1098,7 @@ get_id(struct ber *b, unsigned int *tag, int *class, int *cstruct) size_t i = 0; unsigned int t = 0; - if (ber_getc(b, &u) == -1) + if (ober_getc(b, &u) == -1) return -1; *class = (u >> BER_CLASS_SHIFT) & BER_CLASS_MASK; @@ -1110,7 +1110,7 @@ get_id(struct ber *b, unsigned int *tag, int *class, int *cstruct) } do { - if (ber_getc(b, &u) == -1) + if (ober_getc(b, &u) == -1) return -1; /* enforce minimal number of octets for tag > 30 */ @@ -1140,7 +1140,7 @@ get_len(struct ber *b, ssize_t *len) u_char u, n; ssize_t s, r; - if (ber_getc(b, &u) == -1) + if (ober_getc(b, &u) == -1) return -1; if ((u & BER_TAG_MORE) == 0) { /* short form */ @@ -1171,7 +1171,7 @@ get_len(struct ber *b, ssize_t *len) r = n + 1; for (s = 0; n > 0; n--) { - if (ber_getc(b, &u) == -1) + if (ober_getc(b, &u) == -1) return -1; s = (s << 8) | u; } @@ -1187,7 +1187,7 @@ get_len(struct ber *b, ssize_t *len) } static ssize_t -ber_read_element(struct ber *ber, struct ber_element *elm) +ober_read_element(struct ber *ber, struct ber_element *elm) { long long val = 0; struct ber_element *next; @@ -1261,7 +1261,7 @@ ber_read_element(struct ber *ber, struct ber_element *elm) if (len > (ssize_t)sizeof(long long)) return -1; for (i = 0; i < len; i++) { - if (ber_getc(ber, &c) != 1) + if (ober_getc(ber, &c) != 1) return -1; /* smallest number of contents octets only */ @@ -1286,7 +1286,7 @@ ber_read_element(struct ber *ber, struct ber_element *elm) return -1; elm->be_free = 1; elm->be_len = len; - ber_read(ber, elm->be_val, len); + ober_read(ber, elm->be_val, len); break; case BER_TYPE_OCTETSTRING: case BER_TYPE_OBJECT: @@ -1295,7 +1295,7 @@ ber_read_element(struct ber *ber, struct ber_element *elm) return -1; elm->be_free = 1; elm->be_len = len; - ber_read(ber, elm->be_val, len); + ober_read(ber, elm->be_val, len); ((u_char *)elm->be_val)[len] = '\0'; break; case BER_TYPE_NULL: /* no payload */ @@ -1305,26 +1305,26 @@ ber_read_element(struct ber *ber, struct ber_element *elm) case BER_TYPE_SEQUENCE: case BER_TYPE_SET: if (elm->be_sub == NULL) { - if ((elm->be_sub = ber_get_element(0)) == NULL) + if ((elm->be_sub = ober_get_element(0)) == NULL) return -1; } next = elm->be_sub; while (len > 0) { /* * Prevent stack overflow from excessive recursion - * depth in ber_free_elements(). + * depth in ober_free_elements(). */ if (elements >= BER_MAX_SEQ_ELEMENTS) { errno = ERANGE; return -1; } - r = ber_read_element(ber, next); + r = ober_read_element(ber, next); if (r == -1) return -1; elements++; len -= r; if (len > 0 && next->be_next == NULL) { - if ((next->be_next = ber_get_element(0)) == + if ((next->be_next = ober_get_element(0)) == NULL) return -1; } @@ -1336,13 +1336,13 @@ ber_read_element(struct ber *ber, struct ber_element *elm) } static ssize_t -ber_getc(struct ber *b, u_char *c) +ober_getc(struct ber *b, u_char *c) { - return ber_read(b, c, 1); + return ober_read(b, c, 1); } static ssize_t -ber_read(struct ber *ber, void *buf, size_t len) +ober_read(struct ber *ber, void *buf, size_t len) { size_t sz; diff --git a/src/lib/libutil/ber.h b/src/lib/libutil/ber.h index a8348150..37352a74 100644 --- a/src/lib/libutil/ber.h +++ b/src/lib/libutil/ber.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.h,v 1.1 2019/05/11 17:46:02 rob Exp $ */ +/* $OpenBSD: ber.h,v 1.2 2019/10/24 12:39:26 tb Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter @@ -90,62 +90,62 @@ struct ber_oid { }; __BEGIN_DECLS -struct ber_element *ber_get_element(unsigned int); -void ber_set_header(struct ber_element *, int, +struct ber_element *ober_get_element(unsigned int); +void ober_set_header(struct ber_element *, int, unsigned int); -void ber_link_elements(struct ber_element *, +void ober_link_elements(struct ber_element *, struct ber_element *); -struct ber_element *ber_unlink_elements(struct ber_element *); -void ber_replace_elements(struct ber_element *, +struct ber_element *ober_unlink_elements(struct ber_element *); +void ober_replace_elements(struct ber_element *, struct ber_element *); -struct ber_element *ber_add_sequence(struct ber_element *); -struct ber_element *ber_add_set(struct ber_element *); -struct ber_element *ber_add_integer(struct ber_element *, long long); -int ber_get_integer(struct ber_element *, long long *); -struct ber_element *ber_add_enumerated(struct ber_element *, long long); -int ber_get_enumerated(struct ber_element *, long long *); -struct ber_element *ber_add_boolean(struct ber_element *, int); -int ber_get_boolean(struct ber_element *, int *); -struct ber_element *ber_add_string(struct ber_element *, const char *); -struct ber_element *ber_add_nstring(struct ber_element *, const char *, +struct ber_element *ober_add_sequence(struct ber_element *); +struct ber_element *ober_add_set(struct ber_element *); +struct ber_element *ober_add_integer(struct ber_element *, long long); +int ober_get_integer(struct ber_element *, long long *); +struct ber_element *ober_add_enumerated(struct ber_element *, long long); +int ober_get_enumerated(struct ber_element *, long long *); +struct ber_element *ober_add_boolean(struct ber_element *, int); +int ober_get_boolean(struct ber_element *, int *); +struct ber_element *ober_add_string(struct ber_element *, const char *); +struct ber_element *ober_add_nstring(struct ber_element *, const char *, size_t); -struct ber_element *ber_add_ostring(struct ber_element *, +struct ber_element *ober_add_ostring(struct ber_element *, struct ber_octetstring *); -int ber_get_string(struct ber_element *, char **); -int ber_get_nstring(struct ber_element *, void **, +int ober_get_string(struct ber_element *, char **); +int ober_get_nstring(struct ber_element *, void **, size_t *); -int ber_get_ostring(struct ber_element *, +int ober_get_ostring(struct ber_element *, struct ber_octetstring *); -struct ber_element *ber_add_bitstring(struct ber_element *, const void *, +struct ber_element *ober_add_bitstring(struct ber_element *, const void *, size_t); -int ber_get_bitstring(struct ber_element *, void **, +int ober_get_bitstring(struct ber_element *, void **, size_t *); -struct ber_element *ber_add_null(struct ber_element *); -int ber_get_null(struct ber_element *); -struct ber_element *ber_add_eoc(struct ber_element *); -int ber_get_eoc(struct ber_element *); -struct ber_element *ber_add_oid(struct ber_element *, struct ber_oid *); -struct ber_element *ber_add_noid(struct ber_element *, struct ber_oid *, int); -struct ber_element *ber_add_oidstring(struct ber_element *, const char *); -int ber_get_oid(struct ber_element *, struct ber_oid *); -size_t ber_oid2ber(struct ber_oid *, u_int8_t *, size_t); -int ber_string2oid(const char *, struct ber_oid *); -struct ber_element *ber_printf_elements(struct ber_element *, char *, ...); -int ber_scanf_elements(struct ber_element *, char *, ...); -ssize_t ber_get_writebuf(struct ber *, void **); -ssize_t ber_write_elements(struct ber *, struct ber_element *); -void ber_set_readbuf(struct ber *, void *, size_t); -struct ber_element *ber_read_elements(struct ber *, struct ber_element *); -off_t ber_getpos(struct ber_element *); -void ber_free_element(struct ber_element *); -void ber_free_elements(struct ber_element *); -size_t ber_calc_len(struct ber_element *); -void ber_set_application(struct ber *, +struct ber_element *ober_add_null(struct ber_element *); +int ober_get_null(struct ber_element *); +struct ber_element *ober_add_eoc(struct ber_element *); +int ober_get_eoc(struct ber_element *); +struct ber_element *ober_add_oid(struct ber_element *, struct ber_oid *); +struct ber_element *ober_add_noid(struct ber_element *, struct ber_oid *, int); +struct ber_element *ober_add_oidstring(struct ber_element *, const char *); +int ober_get_oid(struct ber_element *, struct ber_oid *); +size_t ober_oid2ber(struct ber_oid *, u_int8_t *, size_t); +int ober_string2oid(const char *, struct ber_oid *); +struct ber_element *ober_printf_elements(struct ber_element *, char *, ...); +int ober_scanf_elements(struct ber_element *, char *, ...); +ssize_t ober_get_writebuf(struct ber *, void **); +ssize_t ober_write_elements(struct ber *, struct ber_element *); +void ober_set_readbuf(struct ber *, void *, size_t); +struct ber_element *ober_read_elements(struct ber *, struct ber_element *); +off_t ober_getpos(struct ber_element *); +void ober_free_element(struct ber_element *); +void ober_free_elements(struct ber_element *); +size_t ober_calc_len(struct ber_element *); +void ober_set_application(struct ber *, unsigned int (*)(struct ber_element *)); -void ber_set_writecallback(struct ber_element *, +void ober_set_writecallback(struct ber_element *, void (*)(void *, size_t), void *); -void ber_free(struct ber *); -int ber_oid_cmp(struct ber_oid *, struct ber_oid *); +void ober_free(struct ber *); +int ober_oid_cmp(struct ber_oid *, struct ber_oid *); __END_DECLS diff --git a/src/lib/libutil/ber_add_string.3 b/src/lib/libutil/ober_add_string.3 similarity index 63% rename from src/lib/libutil/ber_add_string.3 rename to src/lib/libutil/ober_add_string.3 index 7dcb284e..5eb6bd32 100644 --- a/src/lib/libutil/ber_add_string.3 +++ b/src/lib/libutil/ober_add_string.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ber_add_string.3,v 1.3 2019/05/21 12:30:07 rob Exp $ +.\" $OpenBSD: ober_add_string.3,v 1.1 2019/10/24 12:39:26 tb Exp $ .\" .\" Copyright (c) 2007, 2012 Reyk Floeter .\" @@ -14,69 +14,69 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 21 2019 $ -.Dt BER_ADD_STRING 3 +.Dd $Mdocdate: October 24 2019 $ +.Dt OBER_ADD_STRING 3 .Os .Sh NAME -.Nm ber_get_element , -.Nm ber_add_sequence , -.Nm ber_add_set , -.Nm ber_add_null , -.Nm ber_add_eoc , -.Nm ber_add_integer , -.Nm ber_add_enumerated , -.Nm ber_add_boolean , -.Nm ber_add_string , -.Nm ber_add_nstring , -.Nm ber_add_ostring , -.Nm ber_add_bitstring , -.Nm ber_add_oid , -.Nm ber_add_noid , -.Nm ber_add_oidstring , -.Nm ber_printf_elements +.Nm ober_get_element , +.Nm ober_add_sequence , +.Nm ober_add_set , +.Nm ober_add_null , +.Nm ober_add_eoc , +.Nm ober_add_integer , +.Nm ober_add_enumerated , +.Nm ober_add_boolean , +.Nm ober_add_string , +.Nm ober_add_nstring , +.Nm ober_add_ostring , +.Nm ober_add_bitstring , +.Nm ober_add_oid , +.Nm ober_add_noid , +.Nm ober_add_oidstring , +.Nm ober_printf_elements .Nd create ASN.1 objects for BER encoding .Sh SYNOPSIS .In sys/types.h .In ber.h .Ft "struct ber_element *" -.Fn "ber_get_element" "unsigned int encoding" +.Fn "ober_get_element" "unsigned int encoding" .Ft "struct ber_element *" -.Fn "ber_add_sequence" "struct ber_element *prev" +.Fn "ober_add_sequence" "struct ber_element *prev" .Ft "struct ber_element *" -.Fn "ber_add_set" "struct ber_element *prev" +.Fn "ober_add_set" "struct ber_element *prev" .Ft "struct ber_element *" -.Fn "ber_add_null" "struct ber_element *prev" +.Fn "ober_add_null" "struct ber_element *prev" .Ft "struct ber_element *" -.Fn "ber_add_eoc" "struct ber_element *prev" +.Fn "ober_add_eoc" "struct ber_element *prev" .Ft "struct ber_element *" -.Fn "ber_add_integer" "struct ber_element *prev" "long long val" +.Fn "ober_add_integer" "struct ber_element *prev" "long long val" .Ft "struct ber_element *" -.Fn "ber_add_enumerated" "struct ber_element *prev" "long long val" +.Fn "ober_add_enumerated" "struct ber_element *prev" "long long val" .Ft "struct ber_element *" -.Fn "ber_add_boolean" "struct ber_element *prev" "int bool" +.Fn "ober_add_boolean" "struct ber_element *prev" "int bool" .Ft "struct ber_element *" -.Fn "ber_add_string" "struct ber_element *prev" "const char *string" +.Fn "ober_add_string" "struct ber_element *prev" "const char *string" .Ft "struct ber_element *" -.Fn "ber_add_nstring" "struct ber_element *prev" "const char *string" "size_t size" +.Fn "ober_add_nstring" "struct ber_element *prev" "const char *string" "size_t size" .Ft "struct ber_element *" -.Fo "ber_add_ostring" +.Fo "ober_add_ostring" .Fa "struct ber_element *prev" .Fa "struct ber_octetstring *ostring" .Fc .Ft "struct ber_element *" -.Fo "ber_add_bitstring" +.Fo "ober_add_bitstring" .Fa "struct ber_element *prev" .Fa "const void *buf" .Fa "size_t size" .Fc .Ft "struct ber_element *" -.Fn "ber_add_oid" "struct ber_element *prev" "struct ber_oid *oid" +.Fn "ober_add_oid" "struct ber_element *prev" "struct ber_oid *oid" .Ft "struct ber_element *" -.Fn "ber_add_noid" "struct ber_element *prev" "struct ber_oid *oid" "int n" +.Fn "ober_add_noid" "struct ber_element *prev" "struct ber_oid *oid" "int n" .Ft "struct ber_element *" -.Fn "ber_add_oidstring" "struct ber_element *prev" "const char *string" +.Fn "ober_add_oidstring" "struct ber_element *prev" "const char *string" .Ft "struct ber_element *" -.Fn "ber_printf_elements" "struct ber_element *prev" "char *format" "..." +.Fn "ober_printf_elements" "struct ber_element *prev" "char *format" "..." .Sh DESCRIPTION Intermediary storage of BER elements during encoding and decoding uses the following structure: @@ -102,7 +102,7 @@ struct ber_element { }; .Ed .Pp -.Fn ber_get_element +.Fn ober_get_element creates a new .Vt ber_element with default values, dynamically allocates required storage, and sets @@ -111,7 +111,7 @@ to .Fa encoding . .Pp The -.Fn ber_add_* +.Fn ober_add_* functions allocate a new .Vt ber_element of the respective type. @@ -128,7 +128,7 @@ they put it behind Those functions taking a second argument initialize the content of the new element from the second argument. .Pp -.Fn ber_printf_elements +.Fn ober_printf_elements creates zero or more .Vt ber_element structures. @@ -139,25 +139,25 @@ and passed to the listed function, creating one .Vt ber_element per byte. The following bytes are valid: -.Bl -column -offset indent byte ber_add_enumerated "struct ber_element *" +.Bl -column -offset indent byte ober_add_enumerated "struct ber_element *" .It Sy byte Ta Sy function Ta Sy arguments -.It B Ta Fn ber_add_bitstring Ta 2: Vt void * , size_t -.It b Ta Fn ber_add_boolean Ta 1: Vt int -.It d Ta Fn ber_add_integer Ta 1: Vt int -.It E Ta Fn ber_add_enumerated Ta 1: Vt long long -.It e Ta see below Ta 1: Vt struct ber_element * -.It i Ta Fn ber_add_integer Ta 1: Vt long long -.It O Ta Fn ber_add_oid Ta 1: Vt struct ber_oid * -.It o Ta Fn ber_add_oidstring Ta 1: Vt char * -.It s Ta Fn ber_add_string Ta 1: Vt char * -.It t Ta Xr ber_set_header 3 Ta 2: Vt int , unsigned int -.It x Ta Fn ber_add_nstring Ta 2: Vt char * , size_t -.It \&( Ta Fn ber_add_set Ta 0 -.It \&) Ta see below Ta 0 -.It \&. Ta Fn ber_add_eoc Ta 0 -.It 0 Ta Fn ber_add_null Ta 0 -.It { Ta Fn ber_add_sequence Ta 0 -.It } Ta see below Ta 0 +.It B Ta Fn ober_add_bitstring Ta 2: Vt void * , size_t +.It b Ta Fn ober_add_boolean Ta 1: Vt int +.It d Ta Fn ober_add_integer Ta 1: Vt int +.It E Ta Fn ober_add_enumerated Ta 1: Vt long long +.It e Ta see below Ta 1: Vt struct ber_element * +.It i Ta Fn ober_add_integer Ta 1: Vt long long +.It O Ta Fn ober_add_oid Ta 1: Vt struct ber_oid * +.It o Ta Fn ober_add_oidstring Ta 1: Vt char * +.It s Ta Fn ober_add_string Ta 1: Vt char * +.It t Ta Xr ober_set_header 3 Ta 2: Vt int , unsigned int +.It x Ta Fn ober_add_nstring Ta 2: Vt char * , size_t +.It \&( Ta Fn ober_add_set Ta 0 +.It \&) Ta see below Ta 0 +.It \&. Ta Fn ober_add_eoc Ta 0 +.It 0 Ta Fn ober_add_null Ta 0 +.It { Ta Fn ober_add_sequence Ta 0 +.It } Ta see below Ta 0 .El .Pp The @@ -175,7 +175,7 @@ if the is the first byte in .Fa fmt , just like the -.Fn ber_add_* +.Fn ober_add_* functions would add a new element. The .Sq t @@ -202,7 +202,7 @@ is returned and the global variable .Va errno is set to indicate the error. .Pp -.Fn ber_printf_elements +.Fn ober_printf_elements returns .Dv NULL without setting @@ -214,10 +214,10 @@ is an empty string and is .Dv NULL . .Sh SEE ALSO -.Xr ber_get_string 3 , -.Xr ber_oid_cmp 3 , -.Xr ber_read_elements 3 , -.Xr ber_set_header 3 +.Xr ober_get_string 3 , +.Xr ober_oid_cmp 3 , +.Xr ober_read_elements 3 , +.Xr ober_set_header 3 .Sh STANDARDS ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules. diff --git a/src/lib/libutil/ber_get_string.3 b/src/lib/libutil/ober_get_string.3 similarity index 62% rename from src/lib/libutil/ber_get_string.3 rename to src/lib/libutil/ober_get_string.3 index f2bd6210..c66d70cc 100644 --- a/src/lib/libutil/ber_get_string.3 +++ b/src/lib/libutil/ober_get_string.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ber_get_string.3,v 1.7 2019/08/14 17:36:04 jmc Exp $ +.\" $OpenBSD: ober_get_string.3,v 1.1 2019/10/24 12:39:26 tb Exp $ .\" .\" Copyright (c) 2007, 2012 Reyk Floeter .\" @@ -14,62 +14,62 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 14 2019 $ -.Dt BER_GET_STRING 3 +.Dd $Mdocdate: October 24 2019 $ +.Dt OBER_GET_STRING 3 .Os .Sh NAME -.Nm ber_get_null , -.Nm ber_get_eoc , -.Nm ber_get_integer , -.Nm ber_get_enumerated , -.Nm ber_get_boolean , -.Nm ber_get_string , -.Nm ber_get_nstring , -.Nm ber_get_ostring , -.Nm ber_get_bitstring , -.Nm ber_get_oid , -.Nm ber_getpos , -.Nm ber_scanf_elements +.Nm ober_get_null , +.Nm ober_get_eoc , +.Nm ober_get_integer , +.Nm ober_get_enumerated , +.Nm ober_get_boolean , +.Nm ober_get_string , +.Nm ober_get_nstring , +.Nm ober_get_ostring , +.Nm ober_get_bitstring , +.Nm ober_get_oid , +.Nm ober_getpos , +.Nm ober_scanf_elements .Nd access properties of ASN.1 objects decoded from BER .Sh SYNOPSIS .In sys/types.h .In ber.h .Ft "int" -.Fn "ber_get_null" "struct ber_element *root" +.Fn "ober_get_null" "struct ber_element *root" .Ft "int" -.Fn "ber_get_eoc" "struct ber_element *root" +.Fn "ober_get_eoc" "struct ber_element *root" .Ft "int" -.Fn "ber_get_integer" "struct ber_element *root" "long long *val" +.Fn "ober_get_integer" "struct ber_element *root" "long long *val" .Ft "int" -.Fn "ber_get_enumerated" "struct ber_element *root" "long long *val" +.Fn "ober_get_enumerated" "struct ber_element *root" "long long *val" .Ft "int" -.Fn "ber_get_boolean" "struct ber_element *root" "int *bool" +.Fn "ober_get_boolean" "struct ber_element *root" "int *bool" .Ft "int" -.Fn "ber_get_string" "struct ber_element *root" "char **charbuf" +.Fn "ober_get_string" "struct ber_element *root" "char **charbuf" .Ft "int" -.Fn "ber_get_nstring" "struct ber_element *root" "void **buf" "size_t *size" +.Fn "ober_get_nstring" "struct ber_element *root" "void **buf" "size_t *size" .Ft "int" -.Fn "ber_get_ostring" "struct ber_element *root" "struct ber_octetstring *ostring" +.Fn "ober_get_ostring" "struct ber_element *root" "struct ber_octetstring *ostring" .Ft "int" -.Fn "ber_get_bitstring" "struct ber_element *root" "void **buf" "size_t *size" +.Fn "ober_get_bitstring" "struct ber_element *root" "void **buf" "size_t *size" .Ft "int" -.Fn "ber_get_oid" "struct ber_element *root" "struct ber_oid *oid" +.Fn "ober_get_oid" "struct ber_element *root" "struct ber_oid *oid" .Ft off_t -.Fn "ber_getpos" "struct ber_element *elm" +.Fn "ober_getpos" "struct ber_element *elm" .Ft "int" -.Fn "ber_scanf_elements" "struct ber_element *root" "char *format" "..." +.Fn "ober_scanf_elements" "struct ber_element *root" "char *format" "..." .Sh DESCRIPTION Functions which take two arguments save the value contained in the .Fa root element into the storage location pointed to by the second argument. Additionally, -.Fn ber_get_nstring +.Fn ober_get_nstring and -.Fn ber_get_bitstring +.Fn ober_get_bitstring save the number of bytes contained in the string into .Pf * Fa size . .Pp -.Fn ber_scanf_elements +.Fn ober_scanf_elements retrieves the values from zero or more elements starting at .Fa root . For each byte in @@ -79,24 +79,24 @@ and passed to the function listed, processing one .Vt ber_element per byte. The following bytes are valid: -.Bl -column -offset indent bytes ber_get_enumerated() "1: struct ber_element **" +.Bl -column -offset indent bytes ober_get_enumerated() "1: struct ber_element **" .It Sy byte Ta Sy function Ta Sy arguments -.It B Ta Fn ber_get_bitstring Ta 2: Vt void ** , size_t * -.It b Ta Fn ber_get_boolean Ta 1: Vt int * -.It d Ta Fn ber_get_integer Ta 1: Vt int * -.It E Ta Fn ber_get_enumerated Ta 1: Vt long long * +.It B Ta Fn ober_get_bitstring Ta 2: Vt void ** , size_t * +.It b Ta Fn ober_get_boolean Ta 1: Vt int * +.It d Ta Fn ober_get_integer Ta 1: Vt int * +.It E Ta Fn ober_get_enumerated Ta 1: Vt long long * .It e Ta see below Ta 1: Vt struct ber_element ** -.It i Ta Fn ber_get_integer Ta 1: Vt long long * -.It o Ta Fn ber_get_oid Ta 1: Vt struct ber_oid * -.It p Ta Fn ber_getpos Ta 1: Vt off_t * +.It i Ta Fn ober_get_integer Ta 1: Vt long long * +.It o Ta Fn ober_get_oid Ta 1: Vt struct ber_oid * +.It p Ta Fn ober_getpos Ta 1: Vt off_t * .It S Ta see below Ta 0 -.It s Ta Fn ber_get_string Ta 1: Vt char ** +.It s Ta Fn ober_get_string Ta 1: Vt char ** .It t Ta see below Ta 2: Vt int * , unsigned int * -.It x Ta Fn ber_get_nstring Ta 2: Vt void **, size_t * +.It x Ta Fn ober_get_nstring Ta 2: Vt void **, size_t * .It \&( or { Ta see below Ta 0 .It \&) or } Ta see below Ta 0 -.It \&. Ta Fn ber_get_eoc Ta 0 -.It 0 Ta Fn ber_get_null Ta 0 +.It \&. Ta Fn ober_get_eoc Ta 0 +.It 0 Ta Fn ober_get_null Ta 0 .El .Pp For @@ -128,11 +128,11 @@ For a closing parenthesis or brace, parsing of the current sequence or set is ended and parsing continues with the element following the sequence or set. .Sh RETURN VALUES -.Fn ber_getpos +.Fn ober_getpos returns the value of .Vt be_offs . .Pp -.Fn ber_scanf_elements +.Fn ober_scanf_elements returns 0 for success or \-1 when encountering elements that do not agree with the expectations of .Fa fmt @@ -140,17 +140,17 @@ or when .Fa fmt is syntactically invalid. Even when -.Fn ber_scanf_elements +.Fn ober_scanf_elements fails, some of the arguments may already have been filled in. .Pp The other functions return 0 if .Va root is of the requested type or \-1 otherwise. .Sh SEE ALSO -.Xr ber_add_string 3 , -.Xr ber_oid_cmp 3 , -.Xr ber_read_elements 3 , -.Xr ber_set_header 3 +.Xr ober_add_string 3 , +.Xr ober_oid_cmp 3 , +.Xr ober_read_elements 3 , +.Xr ober_set_header 3 .Sh STANDARDS ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules. diff --git a/src/lib/libutil/ber_oid_cmp.3 b/src/lib/libutil/ober_oid_cmp.3 similarity index 78% rename from src/lib/libutil/ber_oid_cmp.3 rename to src/lib/libutil/ober_oid_cmp.3 index 7cb58588..4e32432b 100644 --- a/src/lib/libutil/ber_oid_cmp.3 +++ b/src/lib/libutil/ober_oid_cmp.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ber_oid_cmp.3,v 1.2 2019/05/21 12:30:07 rob Exp $ +.\" $OpenBSD: ober_oid_cmp.3,v 1.1 2019/10/24 12:39:26 tb Exp $ .\" .\" Copyright (c) 2007, 2012 Reyk Floeter .\" @@ -14,23 +14,23 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 21 2019 $ -.Dt BER_OID_CMP 3 +.Dd $Mdocdate: October 24 2019 $ +.Dt OBER_OID_CMP 3 .Os .Sh NAME -.Nm ber_oid_cmp , -.Nm ber_oid2ber , -.Nm ber_string2oid +.Nm ober_oid_cmp , +.Nm ober_oid2ber , +.Nm ober_string2oid .Nd OID helper functions for the BER library .Sh SYNOPSIS .In sys/types.h .In ber.h .Ft "int" -.Fn "ber_oid_cmp" "struct ber_oid *a" "struct ber_oid *b" +.Fn "ober_oid_cmp" "struct ber_oid *a" "struct ber_oid *b" .Ft "size_t" -.Fn "ber_oid2ber" "struct ber_oid *oid" "u_int8_t *buf" "size_t size" +.Fn "ober_oid2ber" "struct ber_oid *oid" "u_int8_t *buf" "size_t size" .Ft "int" -.Fn "ber_string2oid" "const char *string" "struct ber_oid *oid" +.Fn "ober_string2oid" "const char *string" "struct ber_oid *oid" .Sh DESCRIPTION Object Identifiers are commonly used in ASN.1-based protocols. These functions provide an interface to parse OIDs. @@ -48,24 +48,24 @@ struct ber_oid { .Ed .Pp The -.Fn ber_oid2ber +.Fn ober_oid2ber and -.Fn ber_string2oid +.Fn ober_string2oid functions may be used to convert from and to .Vt struct ber_oid . .Pp -.Fn ber_oid_cmp +.Fn ober_oid_cmp may be used to compare two .Vt ber_oid structures. .Sh RETURN VALUES -.Fn ber_oid2ber +.Fn ober_oid2ber returns the number of bytes written or 0 on faliure. .Pp -.Fn ber_string2oid +.Fn ober_string2oid returns 0 on success or -1 on failure. .Pp -.Fn ber_oid_cmp +.Fn ober_oid_cmp returns 0 when oids .Fa a and @@ -87,10 +87,10 @@ is larger, but a child of .Fa a , 2 is returned. .Sh SEE ALSO -.Xr ber_add_string 3 , -.Xr ber_get_string 3 , -.Xr ber_read_elements 3 , -.Xr ber_set_header 3 +.Xr ober_add_string 3 , +.Xr ober_get_string 3 , +.Xr ober_read_elements 3 , +.Xr ober_set_header 3 .Sh HISTORY These functions first appeared as internal functions in .Xr snmpd 8 diff --git a/src/lib/libutil/ber_read_elements.3 b/src/lib/libutil/ober_read_elements.3 similarity index 86% rename from src/lib/libutil/ber_read_elements.3 rename to src/lib/libutil/ober_read_elements.3 index 12b06da0..74fabe62 100644 --- a/src/lib/libutil/ber_read_elements.3 +++ b/src/lib/libutil/ober_read_elements.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ber_read_elements.3,v 1.5 2019/05/21 12:30:07 rob Exp $ +.\" $OpenBSD: ober_read_elements.3,v 1.1 2019/10/24 12:39:26 tb Exp $ .\" .\" Copyright (c) 2007, 2012 Reyk Floeter .\" @@ -14,35 +14,35 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 21 2019 $ -.Dt BER_READ_ELEMENTS 3 +.Dd $Mdocdate: October 24 2019 $ +.Dt OBER_READ_ELEMENTS 3 .Os .Sh NAME -.Nm ber_set_readbuf , -.Nm ber_set_application , -.Nm ber_read_elements , -.Nm ber_get_writebuf , -.Nm ber_write_elements , -.Nm ber_free +.Nm ober_set_readbuf , +.Nm ober_set_application , +.Nm ober_read_elements , +.Nm ober_get_writebuf , +.Nm ober_write_elements , +.Nm ober_free .Nd encode and decode ASN.1 with Basic Encoding Rules .Sh SYNOPSIS .In sys/types.h .In ber.h .Ft "void" -.Fn "ber_set_readbuf" "struct ber *ber" "void *buf" "size_t len" +.Fn "ober_set_readbuf" "struct ber *ber" "void *buf" "size_t len" .Ft "void" -.Fo "ber_set_application" +.Fo "ober_set_application" .Fa "struct ber *ber" .Fa "unsigned int (*cb)(struct ber_element *)" .Fc .Ft "struct ber_element *" -.Fn "ber_read_elements" "struct ber *ber" "struct ber_element *root" +.Fn "ober_read_elements" "struct ber *ber" "struct ber_element *root" .Ft "ssize_t" -.Fn "ber_get_writebuf" "struct ber *ber" "void **buf" +.Fn "ober_get_writebuf" "struct ber *ber" "void **buf" .Ft "ssize_t" -.Fn "ber_write_elements" "struct ber *ber" "struct ber_element *root" +.Fn "ober_write_elements" "struct ber *ber" "struct ber_element *root" .Ft "void" -.Fn "ber_free" "struct ber *ber" +.Fn "ober_free" "struct ber *ber" .Sh DESCRIPTION The BER API provides a mechanism to read and write ASN.1 using the Basic Encoding Rules. @@ -95,7 +95,7 @@ struct ber_element { }; .Ed .Pp -.Fn ber_set_readbuf +.Fn ober_set_readbuf sets .Fa br_rbuf to point an input buffer of BER encoded bytes in preparation for decoding. @@ -108,7 +108,7 @@ application, commonly obtained by or .Xr tls_read 3 . .Pp -.Fn ber_read_elements +.Fn ober_read_elements may then be called to parse, validate, and store the .Fa ber data stream into its @@ -118,12 +118,12 @@ parts for subsequent processing. The calling application must have explicit knowledge of the expected data types in order for correct decoding. .Pp -.Fn ber_get_writebuf +.Fn ober_get_writebuf sets .Fa br_wbuf to point to an output buffer for writing a BER byte stream. .Pp -.Fn ber_write_elements +.Fn ober_write_elements encodes .Fa root into a compliant BER byte stream which is written to @@ -135,23 +135,23 @@ functions such as or .Xr tls_write 3 . .Pp -.Fn ber_free +.Fn ober_free frees any dynamically allocated storage associated with .Fa ber . .Sh RETURN VALUES -.Fn ber_read_elements +.Fn ober_read_elements returns a pointer to a fully populated list of one or more .Vt ber_element structures or .Dv NULL on a type mismatch or read error. .Pp -.Fn ber_get_writebuf +.Fn ober_get_writebuf returns the number of bytes contained within the buffer .Fa buf or \-1 on failure. .Pp -.Fn ber_write_elements +.Fn ober_write_elements returns the number of bytes written. Otherwise \-1 is returned and the global variable .Va errno @@ -161,10 +161,10 @@ is set to indicate the error. .Xr recv 2 , .Xr send 2 , .Xr write 2 , -.Xr ber_add_string 3 , -.Xr ber_get_string 3 , -.Xr ber_oid_cmp 3 , -.Xr ber_set_header 3 , +.Xr ober_add_string 3 , +.Xr ober_get_string 3 , +.Xr ober_oid_cmp 3 , +.Xr ober_set_header 3 , .Xr tls_read 3 .Sh STANDARDS ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: diff --git a/src/lib/libutil/ber_set_header.3 b/src/lib/libutil/ober_set_header.3 similarity index 70% rename from src/lib/libutil/ber_set_header.3 rename to src/lib/libutil/ober_set_header.3 index 99dfdcb5..401cc71e 100644 --- a/src/lib/libutil/ber_set_header.3 +++ b/src/lib/libutil/ober_set_header.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ber_set_header.3,v 1.3 2019/08/14 19:08:03 martijn Exp $ +.\" $OpenBSD: ober_set_header.3,v 1.1 2019/10/24 12:39:26 tb Exp $ .\" .\" Copyright (c) 2007, 2012 Reyk Floeter .\" @@ -14,42 +14,42 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 14 2019 $ -.Dt BER_SET_HEADER 3 +.Dd $Mdocdate: October 24 2019 $ +.Dt OBER_SET_HEADER 3 .Os .Sh NAME -.Nm ber_set_header , -.Nm ber_calc_len , -.Nm ber_set_writecallback , -.Nm ber_link_elements , -.Nm ber_replace_elements , -.Nm ber_unlink_elements , -.Nm ber_free_element , -.Nm ber_free_elements +.Nm ober_set_header , +.Nm ober_calc_len , +.Nm ober_set_writecallback , +.Nm ober_link_elements , +.Nm ober_replace_elements , +.Nm ober_unlink_elements , +.Nm ober_free_element , +.Nm ober_free_elements .Nd change and destroy ASN.1 objects for BER encoding .Sh SYNOPSIS .In sys/types.h .In ber.h .Ft "void" -.Fn "ber_set_header" "struct ber_element *elm" "int class" "unsigned int type" +.Fn "ober_set_header" "struct ber_element *elm" "int class" "unsigned int type" .Ft "size_t" -.Fn "ber_calc_len" "struct ber_element *root" +.Fn "ober_calc_len" "struct ber_element *root" .Ft "void" -.Fo "ber_set_writecallback" +.Fo "ober_set_writecallback" .Fa "struct ber_element *elm" .Fa "void (*cb)(void *arg, size_t offs)" .Fa "void *arg" .Fc .Ft "void" -.Fn "ber_link_elements" "struct ber_element *prev" "struct ber_element *elm" +.Fn "ober_link_elements" "struct ber_element *prev" "struct ber_element *elm" .Ft "void" -.Fn "ber_replace_elements" "struct ber_element *prev" "struct ber_element *elm" +.Fn "ober_replace_elements" "struct ber_element *prev" "struct ber_element *elm" .Ft "struct ber_element *" -.Fn "ber_unlink_elements" "struct ber_element *prev" +.Fn "ober_unlink_elements" "struct ber_element *prev" .Ft "void" -.Fn "ber_free_element" "struct ber_element *root" +.Fn "ober_free_element" "struct ber_element *root" .Ft "void" -.Fn "ber_free_elements" "struct ber_element *root" +.Fn "ober_free_elements" "struct ber_element *root" .Pp .Fd #define BER_TYPE_BOOLEAN 1 .Fd #define BER_TYPE_INTEGER 2 @@ -70,7 +70,7 @@ .Fd #define BER_CLASS_CONTEXT 0x2 .Fd #define BER_CLASS_PRIVATE 0x3 .Sh DESCRIPTION -.Fn ber_set_header +.Fn ober_set_header sets the .Fa class and @@ -78,22 +78,22 @@ and of .Fa elm . .Pp -.Fn ber_calc_len +.Fn ober_calc_len determines the total length of .Fa root . .Pp -.Fn ber_set_writecallback +.Fn ober_set_writecallback registers the .Vt br_cb callback function. .Pp -.Fn ber_link_elements +.Fn ober_link_elements links .Fa prev and .Fa elm . .Pp -.Fn ber_replace_elements +.Fn ober_replace_elements replaces .Fa prev with @@ -101,30 +101,30 @@ with and frees any dynamically allocated storage assocated with .Fa prev . .Pp -.Fn ber_unlink_elements +.Fn ober_unlink_elements unlinks .Fa prev . .Pp -.Fn ber_free_element +.Fn ober_free_element and -.Fn ber_free_elements +.Fn ober_free_elements free any dynamically allocated storage associated with .Fa root . .Sh RETURN VALUES -.Fn ber_calc_len +.Fn ober_calc_len returns the total length of a fully populated .Fa root containing one or more .Vt ber_element . .Pp -.Fn ber_unlink_elements +.Fn ober_unlink_elements returns a pointer to .Vt ber_element . .Sh SEE ALSO -.Xr ber_add_string 3 , -.Xr ber_get_string 3 , -.Xr ber_oid_cmp 3 , -.Xr ber_read_elements 3 +.Xr ober_add_string 3 , +.Xr ober_get_string 3 , +.Xr ober_oid_cmp 3 , +.Xr ober_read_elements 3 .Sh STANDARDS ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules. diff --git a/src/lib/libutil/shlib_version b/src/lib/libutil/shlib_version index b91c32ce..d85251eb 100644 --- a/src/lib/libutil/shlib_version +++ b/src/lib/libutil/shlib_version @@ -1,2 +1,2 @@ -major=13 -minor=1 +major=14 +minor=0