xref: /freebsd/crypto/krb5/doc/appdev/y2038.rst (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy SchubertYear 2038 considerations for uses of krb5_timestamp
2*7f2fe78bSCy Schubert===================================================
3*7f2fe78bSCy Schubert
4*7f2fe78bSCy SchubertPOSIX time values, which measure the number of seconds since January 1
5*7f2fe78bSCy Schubert1970, will exceed the maximum value representable in a signed 32-bit
6*7f2fe78bSCy Schubertinteger in January 2038.  This documentation describes considerations
7*7f2fe78bSCy Schubertfor consumers of the MIT krb5 libraries.
8*7f2fe78bSCy Schubert
9*7f2fe78bSCy SchubertApplications or libraries which use libkrb5 and consume the timestamps
10*7f2fe78bSCy Schubertincluded in credentials or other structures make use of the
11*7f2fe78bSCy Schubert:c:type:`krb5_timestamp` type.  For historical reasons, krb5_timestamp
12*7f2fe78bSCy Schubertis a signed 32-bit integer, even on platforms where a larger type is
13*7f2fe78bSCy Schubertnatively used to represent time values.  To behave properly for time
14*7f2fe78bSCy Schubertvalues after January 2038, calling code should cast krb5_timestamp
15*7f2fe78bSCy Schubertvalues to uint32_t, and then to time_t::
16*7f2fe78bSCy Schubert
17*7f2fe78bSCy Schubert    (time_t)(uint32_t)timestamp
18*7f2fe78bSCy Schubert
19*7f2fe78bSCy SchubertUsed in this way, krb5_timestamp values can represent time values up
20*7f2fe78bSCy Schubertuntil February 2106, provided that the platform uses a 64-bit or
21*7f2fe78bSCy Schubertlarger time_t type.  This usage will also remain safe if a later
22*7f2fe78bSCy Schubertversion of MIT krb5 changes krb5_timestamp to an unsigned 32-bit
23*7f2fe78bSCy Schubertinteger.
24*7f2fe78bSCy Schubert
25*7f2fe78bSCy SchubertThe GSSAPI only uses representations of time intervals, not absolute
26*7f2fe78bSCy Schuberttimes.  Callers of the GSSAPI should require no changes to behave
27*7f2fe78bSCy Schubertcorrectly after January 2038, provided that they use MIT krb5 release
28*7f2fe78bSCy Schubert1.16 or later.
29