static int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *t) { if (t == NULL) { time_t now_t; time(&now_t); if (OPENSSL_gmtime(&now_t, tm)) return 1; return 0; } if (t->type == V_ASN1_UTCTIME) return asn1_utctime_to_tm(tm, t); else if (t->type == V_ASN1_GENERALIZEDTIME) return asn1_generalizedtime_to_tm(tm, t); return 0; }
int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) { struct tm stm, ttm; int day, sec; if (!asn1_utctime_to_tm(&stm, s)) return -2; if (!OPENSSL_gmtime(&t, &ttm)) return -2; if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm)) return -2; if (day > 0) return 1; if (day < 0) return -1; if (sec > 0) return 1; if (sec < 0) return -1; return 0; }
int ASN1_UTCTIME_check(const ASN1_UTCTIME *d) { return asn1_utctime_to_tm(NULL, d); }