src/ssl_sock.c
static int
ssl_sock_get_time(ASN1_TIME *tm, struct chunk *out)
{
	if (tm->type == V_ASN1_GENERALIZEDTIME) {
		ASN1_GENERALIZEDTIME *gentm = (ASN1_GENERALIZEDTIME *)tm;

		if (gentm->length < 12)
			return 0;
		if (gentm->data[0] != 0x32 || gentm->data[1] != 0x30)
			return 0;
		if (out->size < gentm->length-2)
			return -1;

		memcpy(out->str, gentm->data+2, gentm->length-2);
		out->len = gentm->length-2;
		return 1;
	}
	else if (tm->type == V_ASN1_UTCTIME) {
		ASN1_UTCTIME *utctm = (ASN1_UTCTIME *)tm;

		if (utctm->length < 10)
			return 0;
		if (utctm->data[0] >= 0x35)
			return 0;
		if (out->size < utctm->length)
			return -1;

		memcpy(out->str, utctm->data, utctm->length);
		out->len = utctm->length;
		return 1;
	}

	return 0;
}
/* Copy Date in ASN1_UTCTIME format in struct chunk out.
 * Returns 1 if serial is found and copied, 0 if no valid time found
 * and -1 if output is not large enough.
 */
Copy Date in ASN1_UTCTIME format in struct chunk out.
Returns 1 if serial is found and copied, 0 if no valid time found
and -1 if output is not large enough.
Copy Date in ASN1_UTCTIME format in struct chunk out . Returns 1 if serial is found and copied 0 if no valid time found and - 1 if output is not large enough .
static int
ssl_sock_get_time(ASN1_TIME *tm, struct chunk *out)
{
	if (tm->type == V_ASN1_GENERALIZEDTIME) {
		ASN1_GENERALIZEDTIME *gentm = (ASN1_GENERALIZEDTIME *)tm;
		if (gentm->length < 12)
			return 0;
		if (gentm->data[0] != 0x32 || gentm->data[1] != 0x30)
			return 0;
		if (out->size < gentm->length-2)
			return -1;
		memcpy(out->str, gentm->data+2, gentm->length-2);
		out->len = gentm->length-2;
		return 1;
	}
	else if (tm->type == V_ASN1_UTCTIME) {
		ASN1_UTCTIME *utctm = (ASN1_UTCTIME *)tm;
		if (utctm->length < 10)
			return 0;
		if (utctm->data[0] >= 0x35)
			return 0;
		if (out->size < utctm->length)
			return -1;
		memcpy(out->str, utctm->data, utctm->length);
		out->len = utctm->length;
		return 1;
	}
	return 0;
}
static int ssl_sock_get_time ( ASN1_TIME * tm , struct chunk * out ) { if ( tm -> type == V_ASN1_GENERALIZEDTIME ) { ASN1_GENERALIZEDTIME * gentm = ( ASN1_GENERALIZEDTIME * ) tm ; if ( gentm -> length < 12 ) return 0 ; if ( gentm -> data [ 0 ] != 0x32 || gentm -> data [ 1 ] != 0x30 ) return 0 ; if ( out -> size < gentm -> length - 2 ) return -1 ; memcpy ( out -> str , gentm -> data + 2 , gentm -> length - 2 ) ; out -> len = gentm -> length - 2 ; return 1 ; } else if ( tm -> type == V_ASN1_UTCTIME ) { ASN1_UTCTIME * utctm = ( ASN1_UTCTIME * ) tm ; if ( utctm -> length < 10 ) return 0 ; if ( utctm -> data [ 0 ] >= 0x35 ) return 0 ; if ( out -> size < utctm -> length ) return -1 ; memcpy ( out -> str , utctm -> data , utctm -> length ) ; out -> len = utctm -> length ; return 1 ; } return 0 ; }
Copy Date in ASN1_UTCTIME format in struct chunk out.
Copy Date in ASN1_UTCTIME format in struct chunk out .