ASN1_UTCTIME_check() -- SSLeay 0.9.0b -- January 1999

NAME

ASN1_UTCTIME_set, ASN1_UTCTIME_check, ASN1_UTCTIME_set_string,
ASN1_UTCTIME_print, ASN1_UTCTIME_dup -- ASN1 time manipulation

SYNOPSIS

#include "asn1.h"

ASN1_UTCTIME *ASN1_UTCTIME_set(s, t)
ASN1_UTCTIME *s; time_t t;

int ASN1_UTCTIME_check(d)
ASN1_UTCTIME *d;

int ASN1_UTCTIME_set_string(s, str)
ASN1_UTCTIME *s;
char *str;

int ASN1_UTCTIME_print(bp, tm)
BIO *bp;
ASN1_UTCTIME *tm;

ASN1_UTCTIME *ASN1_UTCTIME_dup(a)
ASN1_UTCTIME *a;

DESCRIPTION

All of these functions operate on an ASN1_UTCTIME structure, which is really an ASN1_STRING. See ASN.1 Types and Structures for the definition of the structure.

A UTCTIME string in the X.509 context must have one of the following formats:

YYMMDDhhmmssZ
YYMMDDhhmmss+hh'mm'
YYMMDDhhmmss-hh'mm' 

where

Z indicates that local time is GMT,
+ indicates that local time is later than GMT, and
- indicates that local time is earlier than GMT,
hh' is the absolute value of the offset from GMT in hours, and
mm' is the absolute value of the offset from GMT in minutes.

A GENERALIZEDTIME string in the X.509 context must have one of the following formats:

YYYYMMDDhhmmssZ
YYYYMMDDhhmmss+hh'mm'
YYYYMMDDhhmmss-hh'mm' 

It is used to encode values with year 2050 and greater, whereas UTCTIME is used to encode values with year 1950 through 2049.

No, I am not making this stuff up.

ASN1_UTCTIME_set converts the contents of the time_t variable t to an ASN1_UTCTIME structure and puts the address in s; if s is not NULL, the structure it points to is used.

Upon success it returns a pointer to the newly populated structure. Upon error it returns NULL.

ASN1_UTCTIME_check() examines the UTCTIME structure pointed to by d to see if the data is valid. If it is, 1 is returned; else 0 is returned.

ASN1_UTCTIME_set_string checks the string str to be sure that it is a valid UTCTIME format, and then stuffs it into the ASN1_UTCTIME structure pointed to by s. 1 is returned on success, and 0 on error.

ASN1_UTCTIME_print prints the contents of the UTCTIME structure pointed to by tm to the file represented by bp in a standard format:

Mon dd hh:mm:ss year [GMT]
for example,
Nov 21 23:59:00 1996 GMT 

If there is an error in the time data, "Bad time value" is written and 0 is returned. If any other error occurs, 0 is returned; else 1 is returned.

ASN1_UTCTIME_dup() is a macro for ASN1_STRING_dup(), which returns a pointer to a copy of the structure passed to it.

Upon error it returns NULL.

The following macros are provided for the convenience of the user:

#define ASN1_GENERALIZEDTIME_dup(a) 
  (ASN1_UTCTIME *)ASN1_STRING_dup((ASN1_STRING *)a)

The other ASN1_GENERALIZEDTIME functions (except new and free) have not been written yet.