summaryrefslogtreecommitdiff
path: root/lib/element.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-11-24 09:41:50 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-11-24 09:41:50 +0100
commitbbfe113c2d7540c6883eb3d83d7052f49f7988fc (patch)
treee1ed054448d536181462c8983a4deccf07245382 /lib/element.c
parent435b15341e5aed9fe0f936d87a88bca31678458d (diff)
downloadlibtasn1-bbfe113c2d7540c6883eb3d83d7052f49f7988fc.tar.gz
libtasn1-bbfe113c2d7540c6883eb3d83d7052f49f7988fc.tar.bz2
libtasn1-bbfe113c2d7540c6883eb3d83d7052f49f7988fc.zip
Introduced ASN1_ETYPE_UTC_TIME and ASN1_ETYPE_GENERALIZED_TIME
Diffstat (limited to 'lib/element.c')
-rw-r--r--lib/element.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/element.c b/lib/element.c
index 2e3d48e..c1718e2 100644
--- a/lib/element.c
+++ b/lib/element.c
@@ -276,6 +276,7 @@ asn1_write_value (asn1_node node_root, const char *name,
int len2, k, k2, negative;
size_t i;
const unsigned char *value = ivalue;
+ unsigned int type;
node = asn1_find_node (node_root, name);
if (node == NULL)
@@ -286,8 +287,10 @@ asn1_write_value (asn1_node node_root, const char *name,
asn1_delete_structure (&node);
return ASN1_SUCCESS;
}
+
+ type = type_field(node->type);
- if ((type_field (node->type) == ASN1_ETYPE_SEQUENCE_OF) && (value == NULL)
+ if ((type == ASN1_ETYPE_SEQUENCE_OF) && (value == NULL)
&& (len == 0))
{
p = node->down;
@@ -301,7 +304,7 @@ asn1_write_value (asn1_node node_root, const char *name,
return ASN1_SUCCESS;
}
- switch (type_field (node->type))
+ switch (type)
{
case ASN1_ETYPE_BOOLEAN:
if (!_asn1_strcmp (value, "TRUE"))
@@ -496,8 +499,7 @@ asn1_write_value (asn1_node node_root, const char *name,
}
_asn1_set_value (node, value, _asn1_strlen (value) + 1);
break;
- case ASN1_ETYPE_TIME:
- if (node->type & CONST_UTC)
+ case ASN1_ETYPE_UTC_TIME:
{
if (_asn1_strlen (value) < 11)
return ASN1_VALUE_NOT_VALID;
@@ -536,11 +538,10 @@ asn1_write_value (asn1_node node_root, const char *name,
}
_asn1_set_value (node, value, _asn1_strlen (value) + 1);
}
- else
- { /* GENERALIZED TIME */
- if (value)
- _asn1_set_value (node, value, _asn1_strlen (value) + 1);
- }
+ break;
+ case ASN1_ETYPE_GENERALIZED_TIME:
+ if (value)
+ _asn1_set_value (node, value, _asn1_strlen (value) + 1);
break;
case ASN1_ETYPE_OCTET_STRING:
case ASN1_ETYPE_GENERALSTRING:
@@ -892,7 +893,8 @@ asn1_read_value_type (asn1_node root, const char *name, void *ivalue, int *len,
PUT_STR_VALUE (value, value_size, node->value);
}
break;
- case ASN1_ETYPE_TIME:
+ case ASN1_ETYPE_GENERALIZED_TIME:
+ case ASN1_ETYPE_UTC_TIME:
PUT_STR_VALUE (value, value_size, node->value);
break;
case ASN1_ETYPE_OCTET_STRING:
@@ -1003,14 +1005,6 @@ asn1_read_tag (asn1_node root, const char *name, int *tagValue,
CASE_HANDLED_ETYPES:
*tagValue = _asn1_tags[type].tag;
break;
- case ASN1_ETYPE_TIME:
- if (node->type & CONST_UTC)
- {
- *tagValue = ASN1_TAG_UTCTime;
- }
- else
- *tagValue = ASN1_TAG_GENERALIZEDTime;
- break;
case ASN1_ETYPE_TAG:
case ASN1_ETYPE_CHOICE:
case ASN1_ETYPE_ANY: