summaryrefslogtreecommitdiffstats
path: root/crypto/asn1/a_utctm.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2015-09-22 16:05:33 +0100
committerDr. Stephen Henson <steve@openssl.org>2015-09-22 16:05:33 +0100
commit0d0099ea3b1825fe51bce11e076292e408b55feb (patch)
treeab8f54fdbc335fbe23b15a791a72c478640776ee /crypto/asn1/a_utctm.c
parent035014cd22c502bca93c73e6475da73ee31f1078 (diff)
Move functions.
Move various functions tagged onto t_x509.c to more appropriate places. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/asn1/a_utctm.c')
-rw-r--r--crypto/asn1/a_utctm.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/crypto/asn1/a_utctm.c b/crypto/asn1/a_utctm.c
index 9144922ab4..cf52c19296 100644
--- a/crypto/asn1/a_utctm.c
+++ b/crypto/asn1/a_utctm.c
@@ -261,3 +261,44 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)
return -1;
return 0;
}
+
+int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)
+{
+ const char *v;
+ int gmt = 0;
+ int i;
+ int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;
+
+ i = tm->length;
+ v = (const char *)tm->data;
+
+ if (i < 10)
+ goto err;
+ if (v[i - 1] == 'Z')
+ gmt = 1;
+ for (i = 0; i < 10; i++)
+ if ((v[i] > '9') || (v[i] < '0'))
+ goto err;
+ y = (v[0] - '0') * 10 + (v[1] - '0');
+ if (y < 50)
+ y += 100;
+ M = (v[2] - '0') * 10 + (v[3] - '0');
+ if ((M > 12) || (M < 1))
+ goto err;
+ d = (v[4] - '0') * 10 + (v[5] - '0');
+ h = (v[6] - '0') * 10 + (v[7] - '0');
+ m = (v[8] - '0') * 10 + (v[9] - '0');
+ if (tm->length >= 12 &&
+ (v[10] >= '0') && (v[10] <= '9') && (v[11] >= '0') && (v[11] <= '9'))
+ s = (v[10] - '0') * 10 + (v[11] - '0');
+
+ if (BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s",
+ _asn1_mon[M - 1], d, h, m, s, y + 1900,
+ (gmt) ? " GMT" : "") <= 0)
+ return (0);
+ else
+ return (1);
+ err:
+ BIO_write(bp, "Bad time value", 14);
+ return (0);
+}