xref: /freebsd/contrib/ntp/util/ntp-keygen.texi (revision 7847e04111f2c2b06b36f6d19a46d78814d7836d)
12b15cb3dSCy Schubert\input texinfo    @c -*-texinfo-*-
22b15cb3dSCy Schubert@c %**start of header
32b15cb3dSCy Schubert@setfilename ntp-keygen.info
42b15cb3dSCy Schubert@settitle Ntp-keygen User's Manual
52b15cb3dSCy Schubert@include ../sntp/include/version.texi
62b15cb3dSCy Schubert@paragraphindent 2
72b15cb3dSCy Schubert@c %**end of header
82b15cb3dSCy Schubert
92b15cb3dSCy Schubert@ifinfo
102b15cb3dSCy SchubertThis file documents the use of the NTP Project's @code{ntp-keygen}
112b15cb3dSCy Schubertprogram, which generates various keys for @code{ntpd},
122b15cb3dSCy Schubert@end ifinfo
132b15cb3dSCy Schubert
142b15cb3dSCy Schubert@direntry
152b15cb3dSCy Schubert* ntp-keygen: (ntp-keygen).                   NTP Key Generation
162b15cb3dSCy Schubert@end direntry
172b15cb3dSCy Schubert
182b15cb3dSCy Schubert@titlepage
192b15cb3dSCy Schubert@title NTP Key Generation User's Manual
202b15cb3dSCy Schubert@subtitle ntp-keygen, version @value{VERSION}, @value{UPDATED}
212b15cb3dSCy Schubert@c @author Max @email{foo@ntp.org}
222b15cb3dSCy Schubert@end titlepage
232b15cb3dSCy Schubert
242b15cb3dSCy Schubert@c @page
252b15cb3dSCy Schubert@c @vskip 0pt plus 1filll
262b15cb3dSCy Schubert
272b15cb3dSCy Schubert@shortcontents
282b15cb3dSCy Schubert
292b15cb3dSCy Schubert@menu
302b15cb3dSCy Schubert* Description::
312b15cb3dSCy Schubert* ntp-keygen Invocation::	Invoking ntp-keygen
322b15cb3dSCy Schubert* Running the Program::
332b15cb3dSCy Schubert* Random Seed File::
342b15cb3dSCy Schubert* Cryptographic Data Files::
352b15cb3dSCy Schubert@end menu
362b15cb3dSCy Schubert
372b15cb3dSCy Schubert@node Top, Description, (dir), (dir)
382b15cb3dSCy Schubert@top NTP Key Generation Program User Manual
392b15cb3dSCy Schubert
402b15cb3dSCy SchubertThis document describes the use of the NTP Project's @code{ntp-keygen}
412b15cb3dSCy Schubertprogram, that generates cryptographic data files used by the NTPv4
422b15cb3dSCy Schubertauthentication and identity schemes.
432b15cb3dSCy SchubertIt can generate message digest keys used in symmetric key cryptography and,
442b15cb3dSCy Schubertif the OpenSSL software
452b15cb3dSCy Schubertlibrary has been installed, it can generate host keys, sign keys,
462b15cb3dSCy Schubertcertificates, and identity keys and parameters used by the Autokey
472b15cb3dSCy Schubertpublic key cryptography.
482b15cb3dSCy SchubertThe message digest keys file is generated in a
492b15cb3dSCy Schubertformat compatible with NTPv3.
502b15cb3dSCy SchubertAll other files are in PEM-encoded
512b15cb3dSCy Schubertprintable ASCII format so they can be embedded as MIME attachments in
522b15cb3dSCy Schubertmail to other sites.
532b15cb3dSCy Schubert
542b15cb3dSCy SchubertThis document applies to version @value{VERSION} of @code{ntp-keygen}.
552b15cb3dSCy Schubert
562b15cb3dSCy Schubert@node Description, Running the Program, Top, Top
572b15cb3dSCy Schubert@comment  node-name,  next,  previous,  up
582b15cb3dSCy Schubert@section Description
592b15cb3dSCy Schubert
602b15cb3dSCy SchubertThis program generates cryptographic data files used by the NTPv4
612b15cb3dSCy Schubertauthentication and identity schemes. It can generate message digest
622b15cb3dSCy Schubertkeys used in symmetric key cryptography and, if the OpenSSL software
632b15cb3dSCy Schubertlibrary has been installed, it can generate host keys, sign keys,
642b15cb3dSCy Schubertcertificates, and identity keys and parameters used by the Autokey
652b15cb3dSCy Schubertpublic key cryptography. The message digest keys file is generated in a
662b15cb3dSCy Schubertformat compatible with NTPv3. All other files are in PEM-encoded
672b15cb3dSCy Schubertprintable ASCII format so they can be embedded as MIME attachments in
682b15cb3dSCy Schubertmail to other sites.
692b15cb3dSCy Schubert
702b15cb3dSCy SchubertWhen used to generate message digest keys, the program produces a file
712b15cb3dSCy Schubertcontaining ten pseudo-random printable ASCII strings suitable for the
722b15cb3dSCy SchubertMD5 message digest algorithm included in the distribution.
732b15cb3dSCy SchubertIf the
742b15cb3dSCy SchubertOpenSSL library is installed, it produces an additional ten hex-encoded
752b15cb3dSCy Schubertrandom bit strings suitable for the SHA1 and other message digest
762b15cb3dSCy Schubertalgorithms.
772b15cb3dSCy SchubertThe message digest keys file must be distributed and stored
782b15cb3dSCy Schubertusing secure means beyond the scope of NTP itself.
792b15cb3dSCy SchubertBesides the keys
802b15cb3dSCy Schubertused for ordinary NTP associations, additional keys can be defined as
812b15cb3dSCy Schubertpasswords for the ntpq and ntpdc utility programs.
822b15cb3dSCy Schubert
832b15cb3dSCy SchubertThe remaining generated files are compatible with other OpenSSL
842b15cb3dSCy Schubertapplications and other Public Key Infrastructure (PKI) resources.
852b15cb3dSCy SchubertCertificates generated by this program are compatible with extant
862b15cb3dSCy Schubertindustry practice, although some users might find the interpretation of
872b15cb3dSCy SchubertX509v3 extension fields somewhat liberal.
882b15cb3dSCy SchubertHowever, the identity keys
892b15cb3dSCy Schubertare probably not compatible with anything other than Autokey.
902b15cb3dSCy Schubert
912b15cb3dSCy SchubertSome files used by this program are encrypted using a private password.
922b15cb3dSCy SchubertThe @code{-p} option specifies the password for local encrypted files and the
932b15cb3dSCy Schubert@code{-q} option the password for encrypted files sent to remote sites.
942b15cb3dSCy SchubertIf no password is specified, the host name returned by the Unix
952b15cb3dSCy Schubert@code{gethostname()} function, normally the DNS name of the host, is used.
962b15cb3dSCy Schubert
972b15cb3dSCy SchubertThe @kbd{pw} option of the @code{crypto} configuration command
982b15cb3dSCy Schubertspecifies the read password for previously encrypted local files.
992b15cb3dSCy SchubertThis must match the local password used by this program.
1002b15cb3dSCy SchubertIf not specified, the host name is used.
1012b15cb3dSCy SchubertThus, if files are generated by this program without password,
1022b15cb3dSCy Schubertthey can be read back by ntpd without password, but only on the same
1032b15cb3dSCy Schuberthost.
1042b15cb3dSCy Schubert
1052b15cb3dSCy SchubertNormally, encrypted files for each host are generated by that host and
1062b15cb3dSCy Schubertused only by that host, although exceptions exist as noted later on
1072b15cb3dSCy Schubertthis page.
1082b15cb3dSCy SchubertThe symmetric keys file, normally called @code{ntp.keys}, is
1092b15cb3dSCy Schubertusually installed in @code{/etc}.
1102b15cb3dSCy SchubertOther files and links are usually installed
1112b15cb3dSCy Schubertin @code{/usr/local/etc}, which is normally in a shared filesystem in
1122b15cb3dSCy SchubertNFS-mounted networks and cannot be changed by shared clients.
1132b15cb3dSCy SchubertThe location of the keys directory can be changed by the keysdir
1142b15cb3dSCy Schubertconfiguration command in such cases.
1152b15cb3dSCy SchubertNormally, this is in @code{/etc}.
1162b15cb3dSCy Schubert
1172b15cb3dSCy SchubertThis program directs commentary and error messages to the standard
1182b15cb3dSCy Schuberterror stream @code{stderr} and remote files to the standard output stream
1192b15cb3dSCy Schubert@code{stdout} where they can be piped to other applications or redirected to
1202b15cb3dSCy Schubertfiles.
1212b15cb3dSCy SchubertThe names used for generated files and links all begin with the
1222b15cb3dSCy Schubertstring @code{ntpkey} and include the file type,
1232b15cb3dSCy Schubertgenerating host and filestamp,
1242b15cb3dSCy Schubertas described in the @ref{Cryptographic Data Files} section below.
1252b15cb3dSCy Schubert
1262b15cb3dSCy Schubert@node Running the Program, Random Seed File, Description, Top
1272b15cb3dSCy Schubert@comment  node-name,  next,  previous,  up
1282b15cb3dSCy Schubert@section Running the Program
1292b15cb3dSCy Schubert
1302b15cb3dSCy SchubertTo test and gain experience with Autokey concepts, log in as root and
1312b15cb3dSCy Schubertchange to the keys directory, usually @code{/usr/local/etc}.
1322b15cb3dSCy SchubertWhen run for the
1332b15cb3dSCy Schubertfirst time, or if all files with names beginning @code{ntpkey}] have been
1342b15cb3dSCy Schubertremoved, use the @code{ntp-keygen} command without arguments to generate a
1352b15cb3dSCy Schubertdefault RSA host key and matching RSA-MD5 certificate with expiration
1362b15cb3dSCy Schubertdate one year hence.
1372b15cb3dSCy SchubertIf run again without options, the program uses the
1382b15cb3dSCy Schubertexisting keys and parameters and generates only a new certificate with
1392b15cb3dSCy Schubertnew expiration date one year hence.
1402b15cb3dSCy Schubert
1412b15cb3dSCy SchubertRun the command on as many hosts as necessary.
1422b15cb3dSCy SchubertDesignate one of them as the trusted host (TH) using @code{ntp-keygen}
1432b15cb3dSCy Schubertwith the @code{-T} option and configure
1442b15cb3dSCy Schubertit to synchronize from reliable Internet servers.
1452b15cb3dSCy SchubertThen configure the other hosts to synchronize to the TH directly or indirectly.
1462b15cb3dSCy SchubertA certificate trail is created when Autokey asks the immediately
1472b15cb3dSCy Schubertascendant host towards the TH to sign its certificate, which is then
1482b15cb3dSCy Schubertprovided to the immediately descendant host on request.
1492b15cb3dSCy SchubertAll group hosts should have acyclic certificate trails ending on the TH.
1502b15cb3dSCy Schubert
1512b15cb3dSCy SchubertThe host key is used to encrypt the cookie when required and so must be
1522b15cb3dSCy SchubertRSA type.
1532b15cb3dSCy SchubertBy default, the host key is also the sign key used to encrypt signatures.
1542b15cb3dSCy SchubertA different sign key can be assigned using the @code{-S} option
1552b15cb3dSCy Schubertand this can be either RSA or DSA type.
1562b15cb3dSCy SchubertBy default, the signature
1572b15cb3dSCy Schubertmessage digest type is MD5, but any combination of sign key type and
1582b15cb3dSCy Schubertmessage digest type supported by the OpenSSL library can be specified
1592b15cb3dSCy Schubertusing the @code{-c} option.
1602b15cb3dSCy Schubert
1612b15cb3dSCy SchubertThe rules say cryptographic media should be generated with proventic
1622b15cb3dSCy Schubertfilestamps, which means the host should already be synchronized before
1632b15cb3dSCy Schubertthis program is run.
1642b15cb3dSCy SchubertThis of course creates a chicken-and-egg problem
1652b15cb3dSCy Schubertwhen the host is started for the first time.
1662b15cb3dSCy SchubertAccordingly, the host time
1672b15cb3dSCy Schubertshould be set by some other means, such as eyeball-and-wristwatch, at
1682b15cb3dSCy Schubertleast so that the certificate lifetime is within the current year.
1692b15cb3dSCy SchubertAfter that and when the host is synchronized to a proventic source, the
1702b15cb3dSCy Schubertcertificate should be re-generated.
1712b15cb3dSCy Schubert
1722b15cb3dSCy SchubertAdditional information on trusted groups and identity schemes is on the
1732b15cb3dSCy SchubertAutokey Public-Key Authentication page.
1742b15cb3dSCy Schubert
1752b15cb3dSCy Schubert@include invoke-ntp-keygen.texi
1762b15cb3dSCy Schubert
1772b15cb3dSCy Schubert@node Random Seed File, Cryptographic Data Files, Running the Program, Top
1782b15cb3dSCy Schubert@comment  node-name,  next,  previous,  up
1792b15cb3dSCy Schubert@section Random Seed File
1802b15cb3dSCy Schubert
1812b15cb3dSCy SchubertAll cryptographically sound key generation schemes must have means to
1822b15cb3dSCy Schubertrandomize the entropy seed used to initialize the internal
1832b15cb3dSCy Schubertpseudo-random number generator used by the OpenSSL library routines.
1842b15cb3dSCy SchubertIf a site supports ssh, it is very likely that means to do this are
1852b15cb3dSCy Schubertalready available.
1862b15cb3dSCy SchubertThe entropy seed used by the OpenSSL library is contained in a file,
1872b15cb3dSCy Schubertusually called @code{.rnd}, which must be available when
1882b15cb3dSCy Schubertstarting the @code{ntp-keygen} program or @code{ntpd} daemon.
1892b15cb3dSCy Schubert
1902b15cb3dSCy SchubertThe OpenSSL library looks for the file using the path specified by the
1912b15cb3dSCy Schubert@code{RANDFILE} environment variable in the user home directory, whether root
1922b15cb3dSCy Schubertor some other user.
1932b15cb3dSCy SchubertIf the @code{RANDFILE} environment variable is not
1942b15cb3dSCy Schubertpresent, the library looks for the @code{.rnd} file in the user home
1952b15cb3dSCy Schubertdirectory.
1962b15cb3dSCy SchubertSince both the @code{ntp-keygen} program and @code{ntpd} daemon must run
1972b15cb3dSCy Schubertas root, the logical place to put this file is in @code{/.rnd} or
1982b15cb3dSCy Schubert@code{/root/.rnd}.
1992b15cb3dSCy SchubertIf the file is not available or cannot be written, the program exits
2002b15cb3dSCy Schubertwith a message to the system log.
2012b15cb3dSCy Schubert
2022b15cb3dSCy Schubert@node Cryptographic Data Files,  , Random Seed File, Top
2032b15cb3dSCy Schubert@comment  node-name,  next,  previous,  up
2042b15cb3dSCy Schubert@section Cryptographic Data Files
2052b15cb3dSCy Schubert
2062b15cb3dSCy SchubertFile and link names are in the @code{form ntpkey_key_name.fstamp},
2072b15cb3dSCy Schubertwhere @code{key} is the key or parameter type,
2082b15cb3dSCy Schubert@code{name} is the host or group name and
2092b15cb3dSCy Schubert@code{fstamp} is the filestamp (NTP seconds) when the file was created).
2102b15cb3dSCy SchubertBy convention, key names in generated file names include both upper and
2112b15cb3dSCy Schubertlower case characters, while key names in generated link names include
2122b15cb3dSCy Schubertonly lower case characters. The filestamp is not used in generated link
2132b15cb3dSCy Schubertnames.
2142b15cb3dSCy Schubert
2152b15cb3dSCy SchubertThe key name is a string defining the cryptographic key type.
2162b15cb3dSCy SchubertKey types include public/private keys host and sign, certificate cert
2172b15cb3dSCy Schubertand several challenge/response key types.
2182b15cb3dSCy SchubertBy convention, client files used for
2192b15cb3dSCy Schubertchallenges have a par subtype, as in the IFF challenge IFFpar, while
2202b15cb3dSCy Schubertserver files for responses have a key subtype, as in the GQ response
2212b15cb3dSCy SchubertGQkey.
2222b15cb3dSCy Schubert
2232b15cb3dSCy SchubertAll files begin with two nonencrypted lines. The first line contains
2242b15cb3dSCy Schubertthe file name in the format @code{ntpkey_key_host.fstamp}.
2252b15cb3dSCy SchubertThe second line contains the datestamp in conventional Unix date format.
2262b15cb3dSCy SchubertLines beginning with @code{#} are ignored.
2272b15cb3dSCy Schubert
2282b15cb3dSCy SchubertThe remainder of the file contains cryptographic data encoded first
2292b15cb3dSCy Schubertusing ASN.1 rules, then encrypted using the DES-CBC algorithm with
2302b15cb3dSCy Schubertgiven password and finally written in PEM-encoded printable ASCII text
2312b15cb3dSCy Schubertpreceded and followed by MIME content identifier lines.
2322b15cb3dSCy Schubert
2332b15cb3dSCy SchubertThe format of the symmetric keys file, ordinarily named @code{ntp.keys},
2342b15cb3dSCy Schubertis somewhat different than the other files in the interest of backward
2352b15cb3dSCy Schubertcompatibility.
2362b15cb3dSCy SchubertOrdinarily, the file is generated by this program, but
2372b15cb3dSCy Schubertit can be constructed and edited using an ordinary text editor.
2382b15cb3dSCy Schubert
2392b15cb3dSCy Schubert@example
2402b15cb3dSCy Schubert# ntpkey_MD5key_hms.local.3564038757
2412b15cb3dSCy Schubert# Sun Dec  9 02:45:57 2012
2422b15cb3dSCy Schubert
2432b15cb3dSCy Schubert 1 MD5 "]!ghT%O;3)WJ,/Nc:>I  # MD5 key
2442b15cb3dSCy Schubert 2 MD5 lu+H^tF46BKR-6~p{V_5  # MD5 key
2452b15cb3dSCy Schubert 3 MD5 :lnoVsE%Y}z*avh%EtNC  # MD5 key
2462b15cb3dSCy Schubert 4 MD5 |fdZrf0sF~@PHZ;w-i^V  # MD5 key
2472b15cb3dSCy Schubert 5 MD5 IyAG>O"}y"LmCRS!*bHC  # MD5 key
2482b15cb3dSCy Schubert 6 MD5 ">e\A@>hT/661ri52,,H  # MD5 key
2492b15cb3dSCy Schubert 7 MD5 c9x=M'CfLxax9v)PV-si  # MD5 key
2502b15cb3dSCy Schubert 8 MD5 E|=jvFVov?Bn|Ev=&aK\  # MD5 key
2512b15cb3dSCy Schubert 9 MD5 T!c4UT&`(m$+m+B6,`Q0  # MD5 key
2522b15cb3dSCy Schubert10 MD5 JVF/1=)=IFbHbJQz..Cd  # MD5 key
2532b15cb3dSCy Schubert11 SHA1 6dea311109529e436c2b4fccae9bc753c16d1b48  # SHA1 key
2542b15cb3dSCy Schubert12 SHA1 7076f373d86c4848c59ff8046e49cb7d614ec394  # SHA1 key
2552b15cb3dSCy Schubert13 SHA1 5f48b1b60591eb01b7cf1d33b7774f08d20262d3  # SHA1 key
2562b15cb3dSCy Schubert14 SHA1 eed5ab9d9497319ec60cf3781d52607e76720178  # SHA1 key
2572b15cb3dSCy Schubert15 SHA1 f283562611a04c964da8126296f5f8e58c3f85de  # SHA1 key
2582b15cb3dSCy Schubert16 SHA1 1930da171297dd63549af50b29449de17dcf341f  # SHA1 key
2592b15cb3dSCy Schubert17 SHA1 fee892110358cd4382322b889869e750db8e8a8f  # SHA1 key
2602b15cb3dSCy Schubert18 SHA1 b5520c9fadd7ad3fd8bfa061c8821b65d029bb37  # SHA1 key
2612b15cb3dSCy Schubert19 SHA1 8c74fb440ec80f453ec6aaa62b9baed0ab723b92  # SHA1 key
2622b15cb3dSCy Schubert20 SHA1 6bc05f734306a189326000970c19b3910f403795  # SHA1 key
2632b15cb3dSCy Schubert@end example
2642b15cb3dSCy Schubert
2652b15cb3dSCy Schubert                  Figure 1. Typical Symmetric Key File
2662b15cb3dSCy Schubert
2672b15cb3dSCy SchubertFigure 1 shows a typical symmetric keys file used by the reference
2682b15cb3dSCy Schubertimplementation.
2692b15cb3dSCy SchubertEach line of the file contains three fields, first an
270*4e1ef62aSXin LIinteger between 1 and 65535, inclusive, representing the key identifier
2712b15cb3dSCy Schubertused in the server and peer configuration commands.
2722b15cb3dSCy SchubertNext is the key type for the message digest algorithm,
2732b15cb3dSCy Schubertwhich in the absence of the
2742b15cb3dSCy SchubertOpenSSL library must be MD5 to designate the MD5 message digest
2752b15cb3dSCy Schubertalgorithm.
2762b15cb3dSCy SchubertIf the OpenSSL library is installed, the key type can be any
2772b15cb3dSCy Schubertmessage digest algorithm supported by that library.
2782b15cb3dSCy SchubertHowever, if
2792b15cb3dSCy Schubertcompatibility with FIPS 140-2 is required, the key type must be either
2802b15cb3dSCy SchubertSHA or SHA1.
2812b15cb3dSCy SchubertThe key type can be changed using an ASCII text editor.
2822b15cb3dSCy Schubert
2832b15cb3dSCy SchubertAn MD5 key consists of a printable ASCII string less than or equal to
2842b15cb3dSCy Schubert16 characters and terminated by whitespace or a # character.
2852b15cb3dSCy SchubertAn OpenSSL
2862b15cb3dSCy Schubertkey consists of a hex-encoded ASCII string of 40 characters, which is
2872b15cb3dSCy Schuberttruncated as necessary.
2882b15cb3dSCy Schubert
2892b15cb3dSCy SchubertNote that the keys used by the @code{ntpq} and @code{ntpdc} programs are
2902b15cb3dSCy Schubertchecked against passwords requested by the programs and entered by hand,
2912b15cb3dSCy Schubertso it
2922b15cb3dSCy Schubertis generally appropriate to specify these keys in human readable ASCII
2932b15cb3dSCy Schubertformat.
2942b15cb3dSCy Schubert
2952b15cb3dSCy SchubertThe @code{ntp-keygen} program generates a MD5 symmetric keys file
2962b15cb3dSCy Schubert@code{ntpkey_MD5key_hostname.filestamp}.
2972b15cb3dSCy SchubertSince the file contains private
2982b15cb3dSCy Schubertshared keys, it should be visible only to root and distributed by
2992b15cb3dSCy Schubertsecure means to other subnet hosts.
3002b15cb3dSCy SchubertThe NTP daemon loads the file @code{ntp.keys}, so @code{ntp-keygen}
3012b15cb3dSCy Schubertinstalls a soft link from this name to the generated file.
3022b15cb3dSCy SchubertSubsequently, similar soft links must be installed by
3032b15cb3dSCy Schubertmanual or automated means on the other subnet hosts.
3042b15cb3dSCy SchubertWhile this file is
3052b15cb3dSCy Schubertnot used with the Autokey Version 2 protocol, it is needed to
3062b15cb3dSCy Schubertauthenticate some remote configuration commands used by the @code{ntpq} and
3072b15cb3dSCy Schubert@code{ntpdc} utilities.
308