On 11/7/2012 3:39 PM, Charles Mills wrote:
> A struct tm is only granular down to whole seconds, right?

Yes, and it is not the easiest data type for data math either, even
when restricted to GMT/UT1/UTC.

Plus many OS/compiler supplied struct tm related functions work badly
outside the range 1970 to 2037 (U2K38 bug and signedness issues).

What would be really nice would be a function that converted the time
to/from a signed bignum (OpenSSL type BN) of nanoseconds since
1970-01-01 00:00:00.000000000 GMT/UT1/UTC, counting GMT/UT1/UTC virtual
seconds not IAT SI seconds (so an input timestamp of 2012-06-30
23:59:60 would be counted as 2012-06-30 23:59:59 or 2012-07-01 00:00:00
and the straigt subtraction between 2012-06-30 23:59:00 and 2012-07-01
00:00:00 would be 1 hour (3600 seconds), not 3601 seconds).

Those wanting a conversion to POSIX time_t could then simply divide by
1000000000 and then convert to a C long or long long.

Note that OpenSSL already contains portable functions to convert
Gregorian YYYY-MM-DD to/from a count of days using pure math.

>
...

-----Original Message-----
From: owner-openssl-us...@openssl.org
[mailto:owner-openssl-us...@openssl.org] On Behalf Of Dr. Stephen Henson
Sent: Wednesday, November 07, 2012 9:33 AM
To: openssl-users@openssl.org
Subject: Re: Find the difference in (milli|micro)seconds between two
ASN1_TIME values

On Wed, Nov 07, 2012, Graham Leggett wrote:

Hi all,

I would like to know how long a CRL has until it expires in seconds (or
milli or microseconds, don't care, I can convert), and am struggling to find
a formally supported way to do this.

What I would like to do is return the difference between a given ASN1_TIME
and the current time, or two ASN1_TIME values (don't care which, I can
generate an ASN1_TIME from the current time).

Does openssl offer a function to do this, or will I be forced to write my
own?


There isn't currently a function to do this but there is a commented out
(and largely untested) function in crypto/asn1/a_time.c to convert an
ASN1_TIME structure to a struct tm and a function to diff two tm structures
called OPENSSL_gmtime_diff.



Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  http://www.wisemo.com
Transformervej 29, 2730 Herlev, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to