summaryrefslogtreecommitdiff
path: root/lib/util/asn1.c
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-09-25 17:29:05 +0300
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-01 23:12:58 +0200
commit540759ec4d0ea432ad0cd3eb10ed2f977f7b6d29 (patch)
tree4a161a7f9b53e0f9e7f030378c2193db26305021 /lib/util/asn1.c
parent55dfc116f47b7c7242567f596c82bfd8f81d7b98 (diff)
downloadsamba-540759ec4d0ea432ad0cd3eb10ed2f977f7b6d29.tar.gz
samba-540759ec4d0ea432ad0cd3eb10ed2f977f7b6d29.tar.bz2
samba-540759ec4d0ea432ad0cd3eb10ed2f977f7b6d29.zip
s4/drsuapi: ber_read_partial_OID_String() implementation
Diffstat (limited to 'lib/util/asn1.c')
-rw-r--r--lib/util/asn1.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
index 0d08027a07..93d96c2bdf 100644
--- a/lib/util/asn1.c
+++ b/lib/util/asn1.c
@@ -656,6 +656,42 @@ nomem:
return false;
}
+/**
+ * Deserialize partial OID string.
+ * Partial OIDs are in the form:
+ * 1:2.5.6:0x81
+ * 1:2.5.6:0x8182
+ */
+bool ber_read_partial_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **partial_oid)
+{
+ size_t bytes_left;
+ size_t bytes_eaten;
+ char *identifier = NULL;
+ char *tmp_oid = NULL;
+
+ if (!_ber_read_OID_String_impl(mem_ctx, blob, (const char **)&tmp_oid, &bytes_eaten))
+ return false;
+
+ if (bytes_eaten < blob.length) {
+ bytes_left = blob.length - bytes_eaten;
+ identifier = hex_encode_talloc(mem_ctx, &blob.data[bytes_eaten], bytes_left);
+ if (!identifier) goto nomem;
+
+ *partial_oid = talloc_asprintf_append_buffer(tmp_oid, ":0x%s", identifier);
+ if (!*partial_oid) goto nomem;
+ TALLOC_FREE(identifier);
+ } else {
+ *partial_oid = tmp_oid;
+ }
+
+ return true;
+
+nomem:
+ TALLOC_FREE(identifier);
+ TALLOC_FREE(tmp_oid);
+ return false;
+}
+
/* read an object ID from a ASN1 buffer */
bool asn1_read_OID(struct asn1_data *data, TALLOC_CTX *mem_ctx, const char **OID)
{