diff options
-rw-r--r-- | lib/decoding.c | 23 | ||||
-rw-r--r-- | lib/libtasn1.h | 4 | ||||
-rw-r--r-- | lib/libtasn1.map | 2 |
3 files changed, 23 insertions, 6 deletions
diff --git a/lib/decoding.c b/lib/decoding.c index 5cc7c89..55a9b00 100644 --- a/lib/decoding.c +++ b/lib/decoding.c @@ -275,11 +275,22 @@ asn1_get_octet_der (const unsigned char *der, int der_len, return ASN1_SUCCESS; } -/* Returns ASN1_SUCCESS on success or an error code on error. - * type should be one of ASN1_ETYPE_GENERALIZED_TIME or ASN1_ETYPE_UTC_TIME. - */ -static int -_asn1_get_time_der (unsigned type, const unsigned char *der, int der_len, int *ret_len, +/** + * asn1_get_time_der: + * @type: %ASN1_ETYPE_GENERALIZED_TIME or %ASN1_ETYPE_UTC_TIME + * @der: DER data to decode containing the time + * @der_len: Length of DER data to decode. + * @ret_len: Output variable containing the length of the DER data. + * @str: Pre-allocated output buffer to put the textual time in. + * @str_size: Length of pre-allocated output buffer. + * @flags: Zero or %ASN1_DECODE_FLAG_STRICT_DER + * + * Converts a DER encoded time object to its textual form. + * + * Returns: %ASN1_SUCCESS on success, or an error. + **/ +int +asn1_get_time_der (unsigned type, const unsigned char *der, int der_len, int *ret_len, char *str, int str_size, unsigned flags) { int len_len, str_len; @@ -1256,7 +1267,7 @@ asn1_der_decoding2 (asn1_node *element, const void *ider, int *max_ider_len, case ASN1_ETYPE_GENERALIZED_TIME: case ASN1_ETYPE_UTC_TIME: result = - _asn1_get_time_der (type_field (p->type), der + counter, ider_len, &len2, temp, + asn1_get_time_der (type_field (p->type), der + counter, ider_len, &len2, temp, sizeof (temp) - 1, flags); if (result != ASN1_SUCCESS) { diff --git a/lib/libtasn1.h b/lib/libtasn1.h index 4d3772b..364ce4e 100644 --- a/lib/libtasn1.h +++ b/lib/libtasn1.h @@ -379,6 +379,10 @@ extern "C" int der_len, int *ret_len, char *str, int str_size); + extern ASN1_API int + asn1_get_time_der (unsigned type, const unsigned char *der, int der_len, int *ret_len, + char *str, int str_size, unsigned flags); + /* Compatibility types */ typedef int asn1_retCode; /* type returned by libtasn1 functions */ diff --git a/lib/libtasn1.map b/lib/libtasn1.map index d5ffa9e..eb71493 100644 --- a/lib/libtasn1.map +++ b/lib/libtasn1.map @@ -57,6 +57,8 @@ LIBTASN1_0_3 asn1_delete_structure2; asn1_dup_node; asn1_decode_simple_ber; + asn1_get_time_der; + asn1_get_object_id_der; local: *; }; |