pem-dev
[Top] [All Lists]

Re: Re[2]: Certificate Handling Standards ( was:PEM Status)

1996-01-04 00:54:00
Green alien space slime made Theodore Ts'o <tytso(_at_)mit(_dot_)edu> write:
 
Also, note that the Date/Time type in ASN.1 is pretty hopeless; it's extremely
inefficiently coded, and a time-zone indicator is not required (!).  DER does
*not* specify the content field of the UTCT time; it merely the encoding for
this (specialized) string type.  For example, all three of these content
fields are legal representations in DER for 4:45:40 p.m. Pacific Daylight Time
on May 6, 1991:

       "910506164540" (this assumes PDT)
       "910506164540-0700" (explicitly specifiyng the PDT zone)
       "910506234540Z" (specified in GMT)

For PKIX, the wg should very strongly consider whether or not times should
simply be sent as an integral number of seconds since some date. There's a
precedence in doing that in how internet time is encoded, and it makes life
*much* easier both from an implementation point of view. It also makes your
protocols a few bytes slimmer, and it avoids a real potential ambiguity in
DER.
 
If you're going to use "seconds-since-X", might I suggest using the Julian Era
(4713 BCE)?  I've found this useful because:
 
(1) It is a standard and well-defined astronomical reference point that you can
    get existing routines for conversion to/from.
 
(2) It was invented precisely for the purpose of calendar calculations.
 
(3) Negative values are *really* rare :-).
 
Actually 4713 BCE is the most recent past year in which three time cycles
started at once.  These are:
 
1) The Roman indiction, a period of 15 years, used during the Roman era to
   schedule taxation and government requisitions.  It is still used in some
   obscure calendrical and religious timings.  FYI, for 1993, the Roman
   Indiction Number is 1.
 
2) The Metonic Cycle of 19 years.  This is the periodicity of the Moon phases
   recuring on the same day(s) of the solar year, and, roughly, repeating
   eclipses.
 
3) The solar cycle of the Julian calendar, the period over which dates recur on
   the same days of the week in the Julian calendar.  This has a period of 28
   years (NB: The Julian calendar should be confused with the Julian Era, which
   is a completely diffrent thing).
 
The advantage of the Julian Era is that it's pretty much universal - no matter
how weird your calendar system is, there is a standard reference somewhere
which tells you how to get there from here.
 
That's the short overview, a longer boring bit follows (hit 'n' when drowsiness
strikes).
 
From Lang's Astrophysical Formulae, 1980 (Berlin: Springer Verlag), p 506,
 
"...the Julian day number is defined as the number of ephemeris days [86400
 seconds each] that have elapsed, at the preceding 12 h E.T., since 12h E. T.
 on January 1, 4713 B.C.  The fundamental epoch 1900 January 0days 12hours E. T
 has the Julian day number 2,415,020.0, whereas for 0d12h E.T on January 1950.0
 the Julian day number is 2,433,282".
 
A footnote on the next page clarifies "1900 January 0 corresponds to 1899
December 31".  On page 508, it becomes clear that E.T. is about 30 seconds off
from U.T. (the exact correction varies-- ET is the flat space theoretical time,
while U.T. is the actual astronomical time, roughly.  For practical purposes,
just use U.T., since that's what computers use).
 
One thing which you have to worry about when dealing with calendar dates is the
use of multiple calendars.  To give you an example of what you're in for,
included below are (sometimes approximate) dates of calendar conversion for
many countries. Surprisingly, there seems to be considerable doubt over when
some areas changed.  Information below is taken from
 
  Explanatory Supplement to the Astronomical Ephemeris and the American
  Ephemeris and Nautical Almanac
 
  Her Majesty's Stationary Office, London, 1961
 
This gives several other references, mainly obscure German works.
 
Where it is known exactly, the changeover is given in the form
 
      last Julian date - first Gregorian date
 
otherwise approximate dates (usually just years) are given.
 
Many European countries had very different borders at the time of the
changeover to those they have now (e.g. Poland, Hungary).  There have been
changes in political authority too.  The German states particularly formed just
a linguistic area comprising (roughly) modern Austria, Germany, Czechoslovakia
and Switzerland; and different political entities (and sometimes even the
ecclesiastical and civil authorities in one area) adopted the Gregorian
calendar at different dates. See the above reference for more details.
 
This table doesn't include the multitude of different calendar systems used in
various parts of the world (for example the Hebrew and Muslim calendars).  I've
got another table somewhere which gives the conversion rules, but can't find it
at the moment.
 
Alaska                             Gregorian calendar adopted when the USA
                                   bought Alaska from Russia (18 October 1867)
 
Albania                            December 1912
 
American Colonies                  See Great Britain
 
Austria                            Different regions on different dates
                                        6 Oct 1583 - 16 Oct 1583 [JD2299527]
                                       15 Dec 1583 - 25 Dec 1583 [JD2299597]
 
Belgium                            Different authorities say
                                       15 Dec 1582 - 25 Dec 1582 [JD2299232]
                                       22 Dec 1582 -  1 Jan 1583 [JD2299239]
 
Bulgaria                           Different authorities say
                                       Sometime in 1912 [JD2419403]
                                       19 Mar 1916 -  1 Apr 1916 [JD2420955]
 
China                              Different authorities say
                                       19 Dec 1911 -  1 Jan 1912 [JD2419403]
                                       19 Dec 1928 -  1 Jan 1929 [JD2425613]
 
Czechoslovakia (i.e. Bohemia and Moravia)
                                   7 Jan 1584 - 17 Jan 1584 [JD2299620]
 
Denmark (including Norway)         19 Feb 1700 - 1 Mar 1700 [JD2342032]
 
Egypt                              1875 [JD2405890]
 
Estonia                            January 1918 [JD2421595]
 
Finland                            Then part of Sweden (q.v.)
 
France                             10 Dec 1582 - 20 Dec 1582 [JD2299227]
 
German States                      Different states on different dates:
                                       14 Feb 1583 - 24 Feb 1583 [JD2299293]
                                        5 Oct 1583 - 15 Oct 1583 [JD2299526]
                                        6 Oct 1583 - 16 Oct 1583 [JD2299527]
                                        3 Nov 1583 - 13 Nov 1583 [JD2299555]
                                        4 Nov 1583 - 14 Nov 1583 [JD2299556]
                                        5 Nov 1583 - 15 Nov 1583 [JD2299557]
                                       12 Nov 1583 - 22 Nov 1583 [JD2299564]
                                       17 Nov 1583 - 27 Nov 1583 [JD2299569]
                                        7 Jan 1584 - 17 Jan 1584 [JD2299620]
                                       13 Jan 1584 - 23 Jan 1584 [JD2299626]
                                        2 Jul 1584 - 12 Jul 1584 [JD2299797]
                                       17 Jun 1585 - 27 Jun 1585 [JD2300147]
                                       23 Aug 1610 -  2 Sep 1610   (a) 
[JD2309345]
                                       14 Dec 1615 - 24 Dec 1615 [JD2311284]
                                       16 Mar 1631 - 26 Mar 1631 [JD2316855]
                                       19 Feb 1700 -  1 Mar 1700   (b) 
[JD2342032]
                                   Note:
                                   (a) Prussia
                                   (b) Protestant Germany
 
Great Britain and Dominions         3 Sep 1752 - 14 Sep 1752 [JD2361222]
 
Greece                             10 Mar 1924 - 23 Mar 1924 [JD2423868]
 
Hungary                            22 Oct 1587 -  1 Nov 1587 [JD2301004]
 
Italy                               5 Oct 1582 - 15 Oct 1582 [JD2299161]
 
Japan                              19 Dec 1918 -  1 Jan 1919 [JD2421960]
 
Latvia                             During German occupation 1915 to 1918 
[1/1/1915->JD2420499]
 
Lithuania                          1915 [JD2420499]
 
Luxemburg                          15 Dec 1582 - 25 Dec 1582 [JD2299232]
 
Netherlands                        Catholic:    various 1582 or 1583 
[10/15/1582->JD2299161]
                                   Protestant:  various 1700 or 1701 
[1/1/1700->JD2341973]
 
Norway                             Then under Danish rule. See Denmark
 
Poland                              5 Oct 1582 - 15 Oct 1582 [JD2299161]
 
Portugal                            5 Oct 1582 - 15 Oct 1582 [JD2299161]
 
Romania                             1 Apr 1919 - 14 Apr 1919 [JD2422063]
 
Spain                               5 Oct 1582 - 15 Oct 1882 [JD2408734]
 
Sweden (including Finland)         18 Feb 1753 - 1 Mar 1753 [JD2361390]
                                   (actually it's more complex than this,
                                    Sweden changed over a forty-year period by
                                    dropping leap days until they were back in
                                    sync.  Even worse, some leap days weren't
                                    dropped when the Swedish king was off
                                    fighting the Russians, so they added and
                                    dropped days in random years to make up for
                                    it).
 
Switzerland                        Varied with the Cantons. Generally one of
                                       12 Jan 1584 - 22 Jan 1584 [JD2299625]
                                        1 Jan 1701 - 12 Jan 1701 [JD2342349]
 
Turkey                             19 Dec 1926 -  1 Jan 1927 [JD2424882]
 
Yugoslavia (as it then was)        1919 [JD2421960]
 
UK                                 See Great Britain
 
USA (then American colonies)       See Great Britain
 
USSR (as it then was)               1 Feb 1918 - 14 Feb 1918 [JD2421639]
 
Still reading?  OK, I think that pretty well sums up the case for Julian dates:
it's universal (you can go from a Julian date to any date in any calendar
format in any time zone), it's well-defined, and it's a lot less messy than the
existing ASN.1 date format.  BTW when I've had to use this date format in the
past I coded it as a 5-byte OCTET STRING (you can add a fractional part as well
if you need fractional seconds).  The only disadantage is that using it will
require some sort of software update in 37,000 years when the date rolls over.
So it may be overkill, but it's more efficient and easier to work with than 
the existing ASN.1 date format, and at worst the conversion to the Unix epoch 
consists of subtracting/adding an integer to the Julian date.

Peter.

<Prev in Thread] Current Thread [Next in Thread>