summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2015-06-08 11:57:21 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2015-06-08 11:57:21 +0200
commit1015d1fd053e4bcc792bb41eca225ef3ccc10fc4 (patch)
tree732525f285ff0884fe23aec0206837cbfe14e37a
parent1b852ffe9e806a727b3f4f601cfb2567535b14ec (diff)
downloadlibtasn1-1015d1fd053e4bcc792bb41eca225ef3ccc10fc4.tar.gz
simplified asn1_get_time_der
-rw-r--r--lib/decoding.c47
-rw-r--r--lib/libtasn1.h2
2 files changed, 31 insertions, 18 deletions
diff --git a/lib/decoding.c b/lib/decoding.c
index 55a9b00..bb5f68b 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -275,22 +275,13 @@ asn1_get_octet_der (const unsigned char *der, int der_len,
return ASN1_SUCCESS;
}
-/**
- * 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.
+
+/* As with asn1_get_time_der().
*
- * 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,
+ * @flags: Zero or %ASN1_DECODE_FLAG_STRICT_DER
+ */
+static 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;
@@ -340,7 +331,7 @@ asn1_get_time_der (unsigned type, const unsigned char *der, int der_len, int *re
}
warn();
- return ASN1_DER_ERROR;
+ return ASN1_DER_ERROR;
}
}
@@ -358,6 +349,28 @@ asn1_get_time_der (unsigned type, const unsigned char *der, int der_len, int *re
}
/**
+ * 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.
+ *
+ * Performs basic checks in the DER encoded time object and returns its textual form.
+ * The textual form will be in the YYYYMMDD000000Z format for GeneralizedTime
+ * and YYMMDD000000Z for UTCTime.
+ *
+ * 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)
+{
+ return _asn1_get_time_der(type, der, der_len, ret_len, str, str_size, ASN1_DECODE_FLAG_STRICT_DER);
+}
+
+/**
* asn1_get_objectid_der:
* @der: DER data to decode containing the OBJECT IDENTIFIER
* @der_len: Length of DER data to decode.
@@ -1267,7 +1280,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 364ce4e..6dcccc6 100644
--- a/lib/libtasn1.h
+++ b/lib/libtasn1.h
@@ -381,7 +381,7 @@ extern "C"
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);
+ char *str, int str_size);
/* Compatibility types */