int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
	{
	char *v;
	int gmt=0;
	int i;
	int y=0,M=0,d=0,h=0,m=0,s=0;
	char *f = NULL;
	int f_len = 0;
	i=tm->length;
	v=(char *)tm->data;
	if (i < 12) goto err;
	if (v[i-1] == 'Z') gmt=1;
	for (i=0; i<12; i++)
		if ((v[i] > '9') || (v[i] < '0')) goto err;
	y= (v[0]-'0')*1000+(v[1]-'0')*100 + (v[2]-'0')*10+(v[3]-'0');
	M= (v[4]-'0')*10+(v[5]-'0');
	if ((M > 12) || (M < 1)) goto err;
	d= (v[6]-'0')*10+(v[7]-'0');
	h= (v[8]-'0')*10+(v[9]-'0');
	m=  (v[10]-'0')*10+(v[11]-'0');
	if (	(v[12] >= '0') && (v[12] <= '9') &&
		(v[13] >= '0') && (v[13] <= '9'))
		{
		s=  (v[12]-'0')*10+(v[13]-'0');
		if (v[14] == '.')
			{
			int l = tm->length;
			f = &v[14];
			f_len = 1;
			while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
				++f_len;
			}
		}
	if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s",
		mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0)
		return(0);
	else
		return(1);
err:
	BIO_write(bp,"Bad time value",14);
	return(0);
	}
['static int print_ocsp_summary(BIO *out, OCSP_BASICRESP *bs, OCSP_REQUEST *req,\n\t\t\t\t\tSTACK *names, STACK_OF(OCSP_CERTID) *ids,\n\t\t\t\t\tlong nsec, long maxage)\n\t{\n\tOCSP_CERTID *id;\n\tchar *name;\n\tint i;\n\tint status, reason;\n\tASN1_GENERALIZEDTIME *rev, *thisupd, *nextupd;\n\tif (!bs || !req || !sk_num(names) || !sk_OCSP_CERTID_num(ids))\n\t\treturn 1;\n\tfor (i = 0; i < sk_OCSP_CERTID_num(ids); i++)\n\t\t{\n\t\tid = sk_OCSP_CERTID_value(ids, i);\n\t\tname = sk_value(names, i);\n\t\tBIO_printf(out, "%s: ", name);\n\t\tif(!OCSP_resp_find_status(bs, id, &status, &reason,\n\t\t\t\t\t&rev, &thisupd, &nextupd))\n\t\t\t{\n\t\t\tBIO_puts(out, "ERROR: No Status found.\\n");\n\t\t\tcontinue;\n\t\t\t}\n\t\tif (!OCSP_check_validity(thisupd, nextupd, nsec, maxage))\n\t\t\t{\n\t\t\tBIO_puts(out, "WARNING: Status times invalid.\\n");\n\t\t\tERR_print_errors(out);\n\t\t\t}\n\t\tBIO_printf(out, "%s\\n", OCSP_cert_status_str(status));\n\t\tBIO_puts(out, "\\tThis Update: ");\n\t\tASN1_GENERALIZEDTIME_print(out, thisupd);\n\t\tBIO_puts(out, "\\n");\n\t\tif(nextupd)\n\t\t\t{\n\t\t\tBIO_puts(out, "\\tNext Update: ");\n\t\t\tASN1_GENERALIZEDTIME_print(out, nextupd);\n\t\t\tBIO_puts(out, "\\n");\n\t\t\t}\n\t\tif (status != V_OCSP_CERTSTATUS_REVOKED)\n\t\t\tcontinue;\n\t\tif (reason != -1)\n\t\t\tBIO_printf(out, "\\tReason: %s\\n",\n\t\t\t\tOCSP_crl_reason_str(reason));\n\t\tBIO_puts(out, "\\tRevocation Time: ");\n\t\tASN1_GENERALIZEDTIME_print(out, rev);\n\t\tBIO_puts(out, "\\n");\n\t\t}\n\treturn 1;\n\t}', 'int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,\n\t\t\t\tint *reason,\n\t\t\t\tASN1_GENERALIZEDTIME **revtime,\n\t\t\t\tASN1_GENERALIZEDTIME **thisupd,\n\t\t\t\tASN1_GENERALIZEDTIME **nextupd)\n\t{\n\tint i;\n\tOCSP_SINGLERESP *single;\n\ti = OCSP_resp_find(bs, id, -1);\n\tif(i < 0) return 0;\n\tsingle = OCSP_resp_get0(bs, i);\n\ti = OCSP_single_get0_status(single, reason, revtime, thisupd, nextupd);\n\tif(status) *status = i;\n\treturn 1;\n\t}', 'int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,\n\t\t\t\tASN1_GENERALIZEDTIME **revtime,\n\t\t\t\tASN1_GENERALIZEDTIME **thisupd,\n\t\t\t\tASN1_GENERALIZEDTIME **nextupd)\n\t{\n\tint ret;\n\tOCSP_CERTSTATUS *cst;\n\tif(!single) return -1;\n\tcst = single->certStatus;\n\tret = cst->type;\n\tif (ret == V_OCSP_CERTSTATUS_REVOKED)\n\t\t{\n\t\tOCSP_REVOKEDINFO *rev = cst->value.revoked;\n\t\tif (revtime) *revtime = rev->revocationTime;\n\t\tif (reason)\n\t\t\t{\n\t\t\tif(rev->revocationReason)\n\t\t\t\t*reason = ASN1_ENUMERATED_get(rev->revocationReason);\n\t\t\telse *reason = -1;\n\t\t\t}\n\t\t}\n\tif(thisupd) *thisupd = single->thisUpdate;\n\tif(nextupd) *nextupd = single->nextUpdate;\n\treturn ret;\n\t}', 'int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, ASN1_GENERALIZEDTIME *nextupd, long nsec, long maxsec)\n\t{\n\tint ret = 1;\n\ttime_t t_now, t_tmp;\n\ttime(&t_now);\n\tif (!ASN1_GENERALIZEDTIME_check(thisupd))\n\t\t{\n\t\tOCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_ERROR_IN_THISUPDATE_FIELD);\n\t\tret = 0;\n\t\t}\n\telse\n\t\t{\n\t\t\tt_tmp = t_now + nsec;\n\t\t\tif (X509_cmp_time(thisupd, &t_tmp) > 0)\n\t\t\t{\n\t\t\tOCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_NOT_YET_VALID);\n\t\t\tret = 0;\n\t\t\t}\n\t\tif (maxsec >= 0)\n\t\t\t{\n\t\t\tt_tmp = t_now - maxsec;\n\t\t\tif (X509_cmp_time(thisupd, &t_tmp) < 0)\n\t\t\t\t{\n\t\t\t\tOCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_TOO_OLD);\n\t\t\t\tret = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (!nextupd) return ret;\n\tif (!ASN1_GENERALIZEDTIME_check(nextupd))\n\t\t{\n\t\tOCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_ERROR_IN_NEXTUPDATE_FIELD);\n\t\tret = 0;\n\t\t}\n\telse\n\t\t{\n\t\tt_tmp = t_now - nsec;\n\t\tif (X509_cmp_time(nextupd, &t_tmp) < 0)\n\t\t\t{\n\t\t\tOCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_STATUS_EXPIRED);\n\t\t\tret = 0;\n\t\t\t}\n\t\t}\n\tif (ASN1_STRING_cmp(nextupd, thisupd) < 0)\n\t\t{\n\t\tOCSPerr(OCSP_F_OCSP_CHECK_VALIDITY, OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE);\n\t\tret = 0;\n\t\t}\n\treturn ret;\n\t}', 'int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)\n\t{\n\tchar *v;\n\tint gmt=0;\n\tint i;\n\tint y=0,M=0,d=0,h=0,m=0,s=0;\n\tchar *f = NULL;\n\tint f_len = 0;\n\ti=tm->length;\n\tv=(char *)tm->data;\n\tif (i < 12) goto err;\n\tif (v[i-1] == \'Z\') gmt=1;\n\tfor (i=0; i<12; i++)\n\t\tif ((v[i] > \'9\') || (v[i] < \'0\')) goto err;\n\ty= (v[0]-\'0\')*1000+(v[1]-\'0\')*100 + (v[2]-\'0\')*10+(v[3]-\'0\');\n\tM= (v[4]-\'0\')*10+(v[5]-\'0\');\n\tif ((M > 12) || (M < 1)) goto err;\n\td= (v[6]-\'0\')*10+(v[7]-\'0\');\n\th= (v[8]-\'0\')*10+(v[9]-\'0\');\n\tm=  (v[10]-\'0\')*10+(v[11]-\'0\');\n\tif (\t(v[12] >= \'0\') && (v[12] <= \'9\') &&\n\t\t(v[13] >= \'0\') && (v[13] <= \'9\'))\n\t\t{\n\t\ts=  (v[12]-\'0\')*10+(v[13]-\'0\');\n\t\tif (v[14] == \'.\')\n\t\t\t{\n\t\t\tint l = tm->length;\n\t\t\tf = &v[14];\n\t\t\tf_len = 1;\n\t\t\twhile (14 + f_len < l && f[f_len] >= \'0\' && f[f_len] <= \'9\')\n\t\t\t\t++f_len;\n\t\t\t}\n\t\t}\n\tif (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s",\n\t\tmon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0)\n\t\treturn(0);\n\telse\n\t\treturn(1);\nerr:\n\tBIO_write(bp,"Bad time value",14);\n\treturn(0);\n\t}']