Move asn1_blob() to lib/util/asn1.c
[ira/wip.git] / lib / util / asn1.c
index aadaf8643a04d31376ca5f7013fedca881fdb23e..08c4060fd1078a9156cd6d609cbc20e4ca57126f 100644 (file)
@@ -763,6 +763,22 @@ bool asn1_write_enumerated(struct asn1_data *data, uint8_t v)
        return !data->has_error;
 }
 
+/*
+  Get us the data just written without copying
+*/
+bool asn1_blob(const struct asn1_data *asn1, DATA_BLOB *blob)
+{
+       if (asn1->has_error) {
+               return false;
+       }
+       if (asn1->nesting != NULL) {
+               return false;
+       }
+       blob->data = asn1->data;
+       blob->length = asn1->length;
+       return true;
+}
+
 /*
   check if a ASN.1 blob is a full tag
 */