summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-09-25 16:38:54 +0300
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2009-10-01 23:12:57 +0200
commit715c790600477b9b1ebdae7aa98779fc06be3bd1 (patch)
tree08682bafc6a6b48883f3cf05805282dbbb62e9ba /lib/util
parent2af2334522bc3d2c44bdcf7c9f1e80d2bcbf2024 (diff)
downloadsamba-715c790600477b9b1ebdae7aa98779fc06be3bd1.tar.gz
samba-715c790600477b9b1ebdae7aa98779fc06be3bd1.tar.bz2
samba-715c790600477b9b1ebdae7aa98779fc06be3bd1.zip
s4/drsuapi: ber_write_partial_OID_String() implementation
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/asn1.c35
-rw-r--r--lib/util/asn1.h1
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
index 70c2c57450..61fb9555a7 100644
--- a/lib/util/asn1.c
+++ b/lib/util/asn1.c
@@ -258,6 +258,41 @@ bool ber_write_OID_String(DATA_BLOB *blob, const char *OID)
return true;
}
+/**
+ * Serialize partial OID string.
+ * Partial OIDs are in the form:
+ * 1:2.5.6:0x81
+ * 1:2.5.6:0x8182
+ */
+bool ber_write_partial_OID_String(DATA_BLOB *blob, const char *partial_oid)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ char *oid = talloc_strdup(mem_ctx, partial_oid);
+ char *p;
+
+ /* truncate partial part so ber_write_OID_String() works */
+ p = strchr(oid, ':');
+ if (p) {
+ *p = '\0';
+ p++;
+ }
+
+ if (!ber_write_OID_String(blob, oid)) {
+ talloc_free(mem_ctx);
+ return false;
+ }
+
+ /* Add partially endcoded subidentifier */
+ if (p) {
+ DATA_BLOB tmp_blob = strhex_to_data_blob(mem_ctx, p);
+ data_blob_append(NULL, blob, tmp_blob.data, tmp_blob.length);
+ }
+
+ talloc_free(mem_ctx);
+
+ return true;
+}
+
/* write an object ID to a ASN1 buffer */
bool asn1_write_OID(struct asn1_data *data, const char *OID)
{
diff --git a/lib/util/asn1.h b/lib/util/asn1.h
index 9abae50d64..cd93195870 100644
--- a/lib/util/asn1.h
+++ b/lib/util/asn1.h
@@ -62,6 +62,7 @@ bool asn1_write_implicit_Integer(struct asn1_data *data, int i);
bool asn1_write_Integer(struct asn1_data *data, int i);
bool asn1_write_BitString(struct asn1_data *data, const void *p, size_t length, uint8_t padding);
bool ber_write_OID_String(DATA_BLOB *blob, const char *OID);
+bool ber_write_partial_OID_String(DATA_BLOB *blob, const char *partial_oid);
bool asn1_write_OID(struct asn1_data *data, const char *OID);
bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length);
bool asn1_write_LDAPString(struct asn1_data *data, const char *s);