summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-11-20 08:46:02 +0000
committerAndrew Tridgell <tridge@samba.org>2001-11-20 08:46:02 +0000
commit4254f9151b4b355b78e494f7c05dacc59fe546e1 (patch)
tree7ce18522040258534834df34f6a7db076c27522a
parentfcbcfb667feaa5f670d589d084aa85cdb66443e0 (diff)
downloadsamba-4254f9151b4b355b78e494f7c05dacc59fe546e1.tar.gz
samba-4254f9151b4b355b78e494f7c05dacc59fe546e1.tar.bz2
samba-4254f9151b4b355b78e494f7c05dacc59fe546e1.zip
add asn1 integer handling ready for the ldap netjoin code
(This used to be commit 74303b75e43856bfb127c143d27e5c5fdcf32c91)
-rw-r--r--source3/libsmb/asn1.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source3/libsmb/asn1.c b/source3/libsmb/asn1.c
index 50cf6a7142..93e95b52bb 100644
--- a/source3/libsmb/asn1.c
+++ b/source3/libsmb/asn1.c
@@ -108,6 +108,18 @@ BOOL asn1_pop_tag(ASN1_DATA *data)
return True;
}
+
+/* write an integer */
+BOOL asn1_write_Integer(ASN1_DATA *data, int i)
+{
+ if (!asn1_push_tag(data, ASN1_INTEGER)) return False;
+ do {
+ asn1_write_uint8(data, i);
+ i = i >> 8;
+ } while (i);
+ return asn1_pop_tag(data);
+}
+
/* write an object ID to a ASN1 buffer */
BOOL asn1_write_OID(ASN1_DATA *data, const char *OID)
{
@@ -368,6 +380,20 @@ BOOL asn1_read_OctetString(ASN1_DATA *data, DATA_BLOB *blob)
return !data->has_error;
}
+/* read an interger */
+BOOL asn1_read_Integer(ASN1_DATA *data, int *i)
+{
+ uint8 b;
+ *i = 0;
+
+ if (!asn1_start_tag(data, ASN1_INTEGER)) return False;
+ while (asn1_tag_remaining(data)>0) {
+ *i = (*i << 8) + asn1_read_uint8(data, &b);
+ }
+ return asn1_end_tag(data);
+
+}
+
/* check a enumarted value is correct */
BOOL asn1_check_enumerated(ASN1_DATA *data, int v)
{