early-access version 2698
This commit is contained in:
53
externals/libressl/crypto/asn1/a_time.c
vendored
53
externals/libressl/crypto/asn1/a_time.c
vendored
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: a_time.c,v 1.27 2015/10/19 16:32:37 beck Exp $ */
|
||||
/* $OpenBSD: a_time.c,v 1.33 2021/12/25 07:48:09 jsing Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
@@ -80,6 +80,45 @@ const ASN1_ITEM ASN1_TIME_it = {
|
||||
.sname = "ASN1_TIME",
|
||||
};
|
||||
|
||||
ASN1_TIME *
|
||||
ASN1_TIME_new(void)
|
||||
{
|
||||
return (ASN1_TIME *)ASN1_item_new(&ASN1_TIME_it);
|
||||
}
|
||||
|
||||
void
|
||||
ASN1_TIME_free(ASN1_TIME *a)
|
||||
{
|
||||
ASN1_item_free((ASN1_VALUE *)a, &ASN1_TIME_it);
|
||||
}
|
||||
|
||||
/* Public API in OpenSSL. Kept internal for now. */
|
||||
static int
|
||||
ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
if (s != NULL)
|
||||
return ASN1_time_parse(s->data, s->length, tm, 0) != -1;
|
||||
|
||||
time(&now);
|
||||
memset(tm, 0, sizeof(*tm));
|
||||
|
||||
return gmtime_r(&now, tm) != NULL;
|
||||
}
|
||||
|
||||
int
|
||||
ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, const ASN1_TIME *to)
|
||||
{
|
||||
struct tm tm_from, tm_to;
|
||||
|
||||
if (!ASN1_TIME_to_tm(from, &tm_from))
|
||||
return 0;
|
||||
if (!ASN1_TIME_to_tm(to, &tm_to))
|
||||
return 0;
|
||||
|
||||
return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to);
|
||||
}
|
||||
|
||||
ASN1_TIME *
|
||||
d2i_ASN1_TIME(ASN1_TIME **a, const unsigned char **in, long len)
|
||||
@@ -93,15 +132,3 @@ i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **out)
|
||||
{
|
||||
return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASN1_TIME_it);
|
||||
}
|
||||
|
||||
ASN1_TIME *
|
||||
ASN1_TIME_new(void)
|
||||
{
|
||||
return (ASN1_TIME *)ASN1_item_new(&ASN1_TIME_it);
|
||||
}
|
||||
|
||||
void
|
||||
ASN1_TIME_free(ASN1_TIME *a)
|
||||
{
|
||||
ASN1_item_free((ASN1_VALUE *)a, &ASN1_TIME_it);
|
||||
}
|
||||
|
Reference in New Issue
Block a user