diff --git a/lib/asn1/der.h b/lib/asn1/der.h index 0ce875778..7ca7ee6f7 100644 --- a/lib/asn1/der.h +++ b/lib/asn1/der.h @@ -243,4 +243,7 @@ int der_get_tag_num(const char *); int der_parse_hex_heim_integer(const char *, heim_integer *); int der_print_hex_heim_integer(const heim_integer *, char **); +int der_print_heim_oid (const heim_oid *data, char **); + + #endif /* __DER_H__ */ diff --git a/lib/asn1/der_format.c b/lib/asn1/der_format.c index 97ee7c6a1..32bbc1e93 100644 --- a/lib/asn1/der_format.c +++ b/lib/asn1/der_format.c @@ -103,3 +103,25 @@ der_print_hex_heim_integer (const heim_integer *data, char **p) } return 0; } + +int +der_print_heim_oid (const heim_oid *oid, char **str) +{ + struct rk_strpool *p = NULL; + int i; + + for (i = 0; i < oid->length ; i++) { + p = rk_strpoolprintf(p, "%d%s", + oid->components[i], + i < oid->length - 1 ? " " : ""); + if (p == NULL) { + *str = NULL; + return ENOMEM; + } + } + + *str = rk_strpoolcollect(p); + if (*str == NULL) + return ENOMEM; + return 0; +}