diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-06-10 11:44:47 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-06-10 11:45:53 +1000 |
commit | d42019644bdad2b0810d054e72378026a02dc295 (patch) | |
tree | d6d64095d6af58943be93f402aa31fa628930914 | |
parent | 9e7501b2cbc52db8f63f75876a966110e35fba9f (diff) | |
download | samba-d42019644bdad2b0810d054e72378026a02dc295.tar.gz samba-d42019644bdad2b0810d054e72378026a02dc295.tar.xz samba-d42019644bdad2b0810d054e72378026a02dc295.zip |
added asn1 functions for handling booleans in a simple context
-rw-r--r-- | lib/util/asn1.c | 23 | ||||
-rw-r--r-- | lib/util/asn1.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/util/asn1.c b/lib/util/asn1.c index c687f8dc9a1..aadaf8643a0 100644 --- a/lib/util/asn1.c +++ b/lib/util/asn1.c @@ -332,6 +332,29 @@ bool asn1_read_BOOLEAN(struct asn1_data *data, bool *v) return !data->has_error; } +/* write a BOOLEAN in a simple context */ +bool asn1_write_BOOLEAN_context(struct asn1_data *data, bool v, int context) +{ + asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(context)); + asn1_write_uint8(data, v ? 0xFF : 0); + asn1_pop_tag(data); + return !data->has_error; +} + +bool asn1_read_BOOLEAN_context(struct asn1_data *data, bool *v, int context) +{ + uint8_t tmp = 0; + asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(context)); + asn1_read_uint8(data, &tmp); + if (tmp == 0xFF) { + *v = true; + } else { + *v = false; + } + asn1_end_tag(data); + return !data->has_error; +} + /* check a BOOLEAN */ bool asn1_check_BOOLEAN(struct asn1_data *data, bool v) { diff --git a/lib/util/asn1.h b/lib/util/asn1.h index 8ecb85cb812..0f41ae33e57 100644 --- a/lib/util/asn1.h +++ b/lib/util/asn1.h @@ -70,6 +70,8 @@ bool asn1_write_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *bl bool asn1_write_BOOLEAN(struct asn1_data *data, bool v); bool asn1_read_BOOLEAN(struct asn1_data *data, bool *v); bool asn1_check_BOOLEAN(struct asn1_data *data, bool v); +bool asn1_write_BOOLEAN_context(struct asn1_data *data, bool v, int context); +bool asn1_read_BOOLEAN_context(struct asn1_data *data, bool *v, int context); bool asn1_load(struct asn1_data *data, DATA_BLOB blob); bool asn1_peek(struct asn1_data *data, void *p, int len); bool asn1_read(struct asn1_data *data, void *p, int len); |