<html>
- <head>
- <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
- <meta name="generator" content="HTML Tidy, see www.w3.org">
- <title>ntp-keygen - generate public and private keys</title>
- <link href="scripts/style.css" type="text/css" rel="stylesheet">
+<head>
+<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+<meta name="generator" content="HTML Tidy, see www.w3.org">
+<title>ntp-keygen - generate public and private keys</title>
+<link href="scripts/style.css" type="text/css" rel="stylesheet">
</head>
- <body>
- <h3><tt>ntp-keygen</tt> - generate public and private keys</h3>
- <img src="pic/alice23.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
- <p>Alice holds the key.</p>
- <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61"></csobj><csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="269">July 5, 2008</csobj></p>
- <br clear="left">
- <h4>Related Links</h4>
- <script type="text/javascript" language="javascript" src="scripts/manual.txt"></script>
- <h4>Table of Contents</h4>
- <ul>
- <li class="inline"><a href="#synop">Synopsis</a>
- <li class="inline"><a href="#descrip">Description</a></li>
- <li class="inline"><a href="#run">Running the program</a></li>
- <li class="inline"><a href="#trust">Trusted Hosts and Secure Groups</a></li>
- <li class="inline"><a href="#ident">Identity Schemes</a></li>
- <li class="inline"><a href="#cmd">Command Line Options</a>
- <li class="inline"><a href="#rand">Random Seed File</a></li>
- <li class="inline"><a href="#fmt">Cryptographic Data Files</a></li>
- <li class="inline"><a href="#bug">Bugs</a></li>
- </ul>
- <hr>
- <h4 id="synop">Synopsis</h4>
- <p id="intro"><tt>ntp-keygen [ -cdeMPT ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [ -H } [ -i <i>issuername</i> ] [ -p <i>passwd2</i> ] [ -q <i>passwd1</i> ] [ -S [ RSA | DSA ] ] [ -s <i>subjectame</i> ] [ -V <i>nkeys</i> ]</tt></p>
- <h4 id="descrip">Description</h4>
- <p>This program generates cryptographic data files used by the NTPv4 authentication and identity schemes. It generates MD5 keys used in symmetric key cryptography and, if the OpenSSL software library has been installed, it generates host keys, certificates and identity keys used in the Autokey public key cryptography. The symmetric keys file is generated in a format compatable with NTPv3 and also used with NTPv4. All other files are in PEM-encoded printable ASCII format so they can be embedded as MIME attachments in mail to other sites and certificate authorities.</p>
- <p>When used to generate symmetric keys, the program produces a file containing 16 random keys. If this is the only need, run <tt>ntp-keygen</tt> with the <tt>-M</tt> option and disregard the remainder of this page. The file can be edited later with purpose-chosen passwords. Each line of the file contains three fields, first an integer between 1 and 65534, inclusive, representing the key identifier used in the <tt>server</tt> and <tt>peer</tt> configuration command. Next is the single character <tt>M</tt> to designate the key as MD5. Finally is the key itself from 1 to 31 characters chosen from the printable ASCII set with the exclusion of space and #. As is custom, # and the remaining chacters on the line are ignored. </p>
- <p>Generated files are compatible with other OpenSSL applications and other Public Key Infrastructure (PKI) resources. Certificates generated by this program should be compatible with extant industry practice, although some users might find the interpretation of X509v3 extension fields somewhat liberal. However, the identity keys are probably not compatible with anything other than Autokey.</p>
- <p>Most files used by this program are encrypted using a private password. The <tt>-p</tt> option specifies the password for local files and the <tt>-q</tt> option the password for files to be sent to remote sites. If no local password is specified, the string returned by the Unix <tt>gethostname()</tt> function is used. If no remote password is specified, the local password is used.</p>
- <p>The <tt>ntpd</tt> command <tt>crypto pw</tt> specifies the read password for previously encrypted files. This must match the local password used by this program. If not specified, the host name is used. Thus, if files are generated by this program without password, they can be read back by <tt>ntpd</tt> without password, but only on the same host.</p>
- <p>All files and links are installed by default in the keys directory <tt>/usr/local/etc</tt>, which is normally in a shared filesystem in NFS-mounted networks. The location of the keys directory can be changed by the <tt>keysdir</tt> configuration command. Normally, encrypted files for each host are generated by that host and used only by that host, although exceptions exist as noted later on this page.</p>
- <p>This program directs commentary and error messages to the standard error stream <tt>stderr</tt> and remote files to the standard output stream <tt>stdout</tt> where they can be piped to other aplications or redirected to a file. The names used for generated files and links all begin with the string <tt>ntpkey</tt> and include the file type, generating host and filestamp, as described in the <a href="#fmt">Cryptographic Data Files</a> section below</p>
- <h4 id="run">Running the Program</h4>
- <p>To test and gain experience with Autokey concepts, log in as root and change
- to the keys directory, usually <tt>/usr/local/etc. </tt>When run for the first
- time, or if all files with names beginning <tt>ntpkey</tt> have been removed,
- use the <tt>ntp-keygen </tt>command without arguments to generate a default
- RSA host key and matching RSA-MD5 certificate with expiration date
- one year hence. If run again, the program uses the existing keys
- and parameters and generates a new certificate with new expiration
- date one year hence; however, the certificate is not generated
- if the <tt>-e</tt> or <tt>-q</tt> options
- are present..</p>
- <p>Run the command on as many hosts as necessary. Designate one of them as the trusted host (TH) using <tt>ntp-keygen</tt> with the <tt>-T</tt> option and configure it to synchronize from reliable Internet servers. Then configure the other hosts to synchronize to the TH directly or indirectly. A certificate trail is created when Autokey asks the immediately ascendant host towards the root to sign its certificate, which is then provided to the immediately descendant host on request. All group hosts should have acyclic certificate trails ending on the TH.</p>
- <p>The host key is used to encrypt the cookie when required and so must be
- RSA type. By default, the host key is also the sign key used to encrypt
- signatures. A different sign key can be assigned using the <tt>-S</tt> option
- and this can be either RSA or DSA type. By default, the signature
- message digest type is MD5, but any combination of sign key type
- and sign digest type supported by the OpenSSL library can be specified
- using the <tt>-c</tt> option.
- At the moment, legacy considerations require the NTP packet header
- digest type to be MD5.</p>
- <h4 id="trust">Trusted Hosts and Secure Groups</h4>
- <p>As described on the <a href="authopt.html">Authentication Options</a> page, an NTP secure group consists of one or more low-stratum THs as the root from which all other group hosts derive synchronization directly or indirectly. For authentication purposes all hosts in a group must have the same group name specified by the <tt>-i</tt> option and matching the <tt>crypto ident</tt> command option. The group name is used in the subject and issuer fields of trusted certificates and when constructing the file names for identity keys. All hosts must have different host names specified by the <tt>-s</tt> option and matching the <tt>crypto host</tt> command option. Host names are used in the subject and issuer fields of nontrusted certificates and when constructing the file names for host and sign keys and certificats. Host and group names are used only for authentication purposes and have nothing to do with DNS names.</p>
- <h4 id="ident">Identity Schemes</h4>
- <p>As described on the <a href="authopt.html">Authentication Options</a> page, there are five identity schemes, three of which - IFF, GQ and MV - require identity keys specific to each scheme. There are two files for each scheme, an encrypted keys file and a nonencrypted parameters file. In general, servers use the keys file and clients use the parameters file. In general, servers expecting to support a client population ned the keys file while others need only the parameters file. Both files are generated by the TA on behalf of all servers and clients in the group.</p>
- <p>The parameters files are public; they can be stored in a public place and sent in the clear. The keys files are encrypted with the local password. To retrieve the keys file, a host sends a mail request to the TA including its local password. The TA encrypts the keys file with this password and returns it as an attachment. The attachment is then copied intact to the keys directory with name given in the first line of the file, but all in lower case and with the filestamp deleted..</p>
- <p>For example, the TA can generate IFF keys and trusted certificate
- using the command</p>
- <p><tt>ntp-keygen -p <i>local_passwd</i> -T -I</tt></p>
- <p>Once these media have been generated, the TA can then generate the public
- parameters using the command</p>
- <tt>ntp-keygen -p local_passwd -e ><i>parameters_file</i></tt></p>
- <p>where the <tt>-e</tt> option redirects the unencrypted parameters to
- the standard output stream for a mail application or stored locally
- for later distribution. In a similar fashion the <tt>-q</tt> option redirects
- the encrypted server keys to the standard output stream.</p>
- <p><tt><i></tt></p>
- <h4 id="cmd">Command Line Options</h4>
- <dl>
- <dt><tt>-c [ RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ]</tt>
- <dd>Select certificate and message digest/signature encryption scheme. Note that RSA schemes must be used with a RSA sign key and DSA schemes must be used with a DSA sign key. The default without this option is <tt>RSA-MD5</tt>.
- <dt><tt>-d</tt>
- <dd>Enable debugging. This option displays the cryptographic data produced for eye-friendly billboards.<dt><tt>-e</tt>
- <dd>Extract the IFF or GQ public parameters from the <tt>IFFkey</tt> or <tt>GQkey</tt> keys
- file previously specified. Send the unencrypted data to the
- standard output stream <tt>stdout</tt>.
- While the IFF parameters do not reveal the
- private group key, the
- GQ parameters should be used with caution, as
- they include the group key. Use the <tt>-q</tt> option with password
- instead.
- Note: a new certificate is not generated when this option is present.
-
- This allows multiple commands with this option but without disturbing
- existing media.
- <dt><tt>-G</tt>
- <dd>Generate GQ key file <tt>GQkey </tt>and link <tt>gqkey </tt>for the Guillou-Quisquater (GQ) identity scheme.
- <dt><tt>-H</tt>
- <dd>Generate a new public/private host keys <tt>RSAkey</tt>, and link <tt>host</tt>.
- <dt><tt>-I</tt>
- <dd>Generate a new encrypted IFF key file <tt>IFFkey </tt>and link <tt>iffkey </tt>for the Schnorr (IFF) identity scheme.<dt><tt>-i <i>group</i></tt>
- <dd>Set the group name to <tt><i>group</i></tt> for generated identity files. This is useful only if the TA is not a group member and is generally considered not a good practice.<dt><tt>-M</tt>
- <dd>Generate a new MD5 key file.<dt><tt>-P</tt>
- <dd>Generate a new private certificate used by the PC identity scheme. By default, the program generates public certificates. Note: the PC identity scheme is not recommended for new installations.<dt><tt>-p <i>passwd</i></tt>
- <dd>Set the password for reading and writing encrypted files to <tt><i>passwd</i></tt>.
- By default, the password is the host name.<dt><tt>-q <i>passwd</i></tt>
- <dd>Extract the encrypted IFF or GQ server keys from the <tt>IFFkey</tt>
- or <tt>GQkey</tt> key file previously generated. The data are
- sent to the standard output stream <tt>stdout</tt>. Set the password for
- writing the data, which is also the password to read the data
- file in another host. By default, the password is the host name.
- Note: a new certificate is not generated when this option is present.
- This allows multiple commands with this option but without disturbing
- existing media.
- <dt><tt>-S [ RSA | DSA ]</tt>
- <dd>Generate a new sign key of the designated type. By default, the sign key is the host key.<dt><tt>-s <i>name</i></tt>
- <dd>Set the host name to <tt><i>name</i></tt>. This is used in the host and sign key file names, as well as the subject and issuer names in the certificate. It must match the host name specified in the <tt>CRYPTO</tt> configuration command. <dt><tt>-T</tt>
- <dd>Generate a trusted certificate. By default, the program generates nontrusted certificates.<dt><tt>-V <i>nkeys</i></tt>
- <dd>Generate server parameters <tt>MV</tt> and <tt><i>nkeys</i></tt> client keys for the Mu-Varadharajan (MV) identity scheme. Note: support for this option should be considered a work in progress.</dl>
- <h4 id="rand">Random Seed File</h4>
- <p>All cryptographically sound key generation schemes must have means to randomize the entropy seed used to initialize the internal pseudo-random number generator used by the OpenSSL library routines. If a site supports <tt>ssh</tt>, it is very likely that means to do this are already available. The entropy seed used by the OpenSSL library is contained in a file, usually called <tt>.rnd</tt>, which must be available when starting the <tt>ntp-keygen</tt> program or <tt>ntpd</tt> daemon.</p>
- <p>The OpenSSL library looks for the file using the path specified by the <tt>RANDFILE</tt> environment variable in the user home directory, whether root or some other user. If the <tt>RANDFILE</tt> environment variable is not present, the library looks for the <tt>.rnd</tt> file in the user home directory. Since both the <tt>ntp-keygen</tt> program and <tt>ntpd</tt> daemon must run as root, the logical place to put this file is in <tt>/.rnd</tt> or <tt>/root/.rnd</tt>. If the file is not available or cannot be written, the program exits with a message to the system log.</p>
- <h4 id="priv">Cryptographic Data Files</h4>
- <p>File and link names are in the form <tt>ntpkey_<i>key</i>_<i>name</i>.<i>fstamp</i></tt>, where <tt><i>key</i></tt> is the key or parameter type, <tt><i>name</i></tt> is the host or group name and <tt><i>fstamp</i></tt> is the filestamp (NTP seconds) when the file was created). By convention, key fields in generated file names include both upper and lower case alphanumeric characters, while key fields in generated link names include only lower case characters. The filestamp is not used in generated link names.</p>
- <p>The key type is a string defining the cryptographic function. Key types include public/private keys <tt>host </tt>and <tt>sign</tt>, certificate <tt>cert</tt> and several challenge/response key types. By convention, files used for challenges have a <tt>par</tt> subtype, as in the IFF challenge <tt>IFFpar</tt>, while files for responses have a <tt>key</tt> subtype, as in the GQ response <tt>GQkey</tt>.</p>
- <p>All files begin with two nonencrypted lines. The first line contains the file name in the format <tt>ntpkey_<i>key</i>_<i>host</i>.<i>fstamp</i></tt>. The second line contains the datestamp in conventional Unix <tt>date</tt> format. Lines beginning with <tt>#</tt> are ignored.</p>
- <p>The remainder of the file contains cryptographic data encoded first using ASN.1 rules, then encrypted using the DES-CBC algorithm and given password and finally written in PEM-encoded printable ASCII text preceded and followed by MIME content identifier lines.</p>
- <p id="symkey">The format of the symmetric keys file is somewhat different than the other files in the interest of backward compatibility. Since DES-CBC is deprecated in NTPv4, the only key format of interest is MD5 alphanumeric strings. Following the header the keys are entered one per line in the format</p>
- <p><i><tt>keyno type key</tt></i></p>
- <p>where <i><tt>keyno</tt></i> is a positive integer in the range 1-65,535, <i><tt>type</tt></i> is the string <tt>MD5</tt> defining the key format and <i><tt>key</tt></i> is the key itself, which is a printable ASCII string 16 characters or less in length. Each character is chosen from the 93 printable characters in the range 0x21 through 0x7f excluding space and the '#' character.</p>
- <p>Note that the keys used by the <tt>ntpq</tt> and <tt>ntpdc</tt> programs are checked against passwords requested by the programs and entered by hand, so it is generally appropriate to specify these keys in human readable ASCII format.</p>
- <p>The <tt>ntp-keygen</tt> program generates a MD5 symmetric keys file <tt>ntpkey_MD5key_<i>hostname.filestamp</i></tt>. Since the file contains private shared keys, it should be visible only to root and distributed by secure means to other subnet hosts. The NTP daemon loads the file <tt>ntp.keys</tt>, so <tt>ntp-keygen</tt> installs a soft link from this name to the generated file. Subsequently, similar soft links must be installed by manual or automated means on the other subnet hosts. While this file is not used with the Autokey Version 2 protocol, it is needed to authenticate some remote configuration commands used by the <a href="ntpdc.html"><tt>ntpq</tt></a> and <a href="ntpq.html"><tt>ntpdc</tt></a> utilities.</p>
- <h4 id="bug">Bugs</h4>
- <p>It can take quite a while to generate some cryptographic values, from one to several minutes with modern architectures such as UltraSPARC and up to tens of minutes to an hour with older architectures such as SPARC IPC.</p>
- <hr>
- <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
- </body>
+<body>
+<h3><tt>ntp-keygen</tt> - generate public and private keys</h3>
+
+<p><img src="pic/alice23.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a></p>
+
+<p>Alice holds the key.</p>
+
+<p>Last update:
+ <!-- #BeginDate format:En2m -->26-Apr-2009 15:46<!-- #EndDate -->
+</p>
+<br clear="left">
+
+<h4>Related Links</h4>
+<script type="text/javascript" language="javascript" src="scripts/manual.txt"></script>
+
+<h4>Table of Contents</h4>
+
+<ul>
+
+<li class="inline"><a href="#synop">Synopsis</a></li>
+<li class="inline"><a href="#descrip">Description</a></li>
+<li class="inline"><a href="#run">Running the program</a></li>
+<li class="inline"><a href="#trust">Trusted Hosts and Secure Groups</a></li>
+<li class="inline"><a href="#ident">Identity Schemes</a></li>
+<li class="inline"><a href="#cmd">Command Line Options</a></li>
+<li class="inline"><a href="#rand">Random Seed File</a></li>
+<li class="inline"><a href="#fmt">Cryptographic Data Files</a></li>
+<li class="inline"><a href="#bug">Bugs</a></li>
+</ul>
+
+<hr>
+
+<h4 id="synop">Synopsis</h4>
+
+<p id="intro"><tt>ntp-keygen [ -deGHIMPT ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA
+ | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [
+ -i <i>group</i> ]
+ [ -m <i>modulus</i> ] [ -p <i>passwd2</i> ] [ -q <i>passwd1</i> ] [ -S
+ [ RSA | DSA ] ] [ -s <i>host</i> ] [ -V <i>nkeys</i> ]</tt></p>
+
+<h4 id="descrip">Description</h4>
+
+<p>This program generates cryptographic data files used by the NTPv4 authentication
+ and identity schemes. It generates MD5 keys used in symmetric key cryptography
+ and, if the OpenSSL software library has been installed, it generates host keys,
+ certificates and identity keys used in the Autokey public key cryptography.
+ The symmetric keys file is generated in a format comparable with NTPv3 and also
+ used with NTPv4. All other files are in PEM-encoded printable ASCII format so
+ they can be embedded as MIME attachments in mail to other sites and certificate
+ authorities.</p>
+
+<p>When used to generate symmetric keys, the program produces a file containing
+ 16 random keys. If this is the only need, run <tt>ntp-keygen</tt> with the <tt>-M</tt> option
+ and disregard the remainder of this page. The file can be edited later with
+ purpose-chosen passwords. Each line of the file contains three fields, first
+ an integer between 1 and 65534, inclusive, representing the key identifier used
+ in the <tt>server</tt> and <tt>peer</tt> configuration command. Next is the
+ single character <tt>M</tt> to designate the key as MD5. Finally is the key
+ itself from 1 to 31 characters chosen from the printable ASCII set with the
+ exclusion of space and #. As is custom, # and the remaining characters on the
+ line are ignored.</p>
+
+<p>Generated files are compatible with other OpenSSL applications and other Public Key Infrastructure (PKI) resources. Certificates generated by this program should be compatible with extant industry practice, although some users might find the interpretation of X509v3 extension fields somewhat liberal. However, the identity keys are probably not compatible with anything other than Autokey.</p>
+
+<p>Most files used by this program are encrypted using a private password. The <tt>-p</tt> option specifies the password for local files and the <tt>-q</tt> option the password for files to be sent to remote sites. If no local password is specified, the host name returned by the Unix <tt>gethostname()</tt> function is used. If no remote password is specified, the local password is used.</p>
+
+<p>The <tt>pw</tt> option of the <tt>crypto</tt> configuration command specifies the read password for previously encrypted files. This must match the local password used by this program. If not specified, the host name is used. Thus, if files are generated by this program without password, they can be read back by <tt>ntpd</tt> without password, but only on the same host.</p>
+
+<p>All files and links are installed by default in the keys directory <tt>/usr/local/etc</tt>, which is normally in a shared filesystem in NFS-mounted networks and cannot be changed by clients. The location of the keys directory can be changed by the <tt>keysdir</tt> configuration command in such cases. Normally, encrypted files for each host are generated by that host and used only by that host, although exceptions exist as noted later on this page.</p>
+
+<p>This program directs commentary and error messages to the standard error stream <tt>stderr</tt> and
+ remote files to the standard output stream <tt>stdout</tt> where they can be
+ piped to other applications or redirected to a file. The names used for generated
+ files and links all begin with the string <tt>ntpkey</tt> and include the file
+ type, generating host and filestamp, as described in the <a href="#fmt">Cryptographic
+ Data Files</a> section below</p>
+
+<h4 id="run">Running the Program</h4>
+
+<p>To test and gain experience with Autokey concepts, log in as root and change to the keys directory, usually <tt>/usr/local/etc</tt>. When run for the first time, or if all files with names beginning <tt>ntpkey</tt> have been removed, use the <tt>ntp-keygen </tt>command without arguments to generate a default RSA host key and matching RSA-MD5 certificate with expiration date one year hence. If run again, the program uses the existing keys and parameters and generates a new certificate with new expiration date one year hence; however, the certificate is not generated if the <tt>-e</tt> or <tt>-q</tt> options are present.</p>
+
+<p>Run the command on as many hosts as necessary. Designate one of them as the
+ trusted host (TH) using <tt>ntp-keygen</tt> with the <tt>-T</tt> option and
+ configure it to synchronize from reliable Internet servers. Then configure the
+ other hosts to synchronize to the TH directly or indirectly. A certificate trail
+ is created when Autokey asks the immediately ascendant host towards the root
+ to sign its certificate, which is then provided to the immediately descendant
+ host on request. All group hosts should have acyclic certificate trails ending
+ on the TH.</p>
+
+<p>The host key is used to encrypt the cookie when required and so must be RSA type. By default, the host key is also the sign key used to encrypt signatures. A different sign key can be assigned using the <tt>-S</tt> option and this can be either RSA or DSA type. By default, the signature message digest type is MD5, but any combination of sign key type and sign digest type supported by the OpenSSL library can be specified using the <tt>-c</tt> option. At the moment, legacy considerations require the NTP packet header digest type to be MD5.</p>
+
+<h4 id="trust">Trusted Hosts and Secure Groups</h4>
+
+<p>As described on the <a href="authopt.html">Authentication Options</a> page,
+ an NTP secure group consists of one or more low-stratum The as the root
+ from which all other group hosts derive synchronization directly or indirectly.
+ For authentication purposes all hosts in a group must have the same group name
+ specified by the <tt>-i</tt> option and matching the <tt>ident</tt> option of
+ the <tt>crypto</tt> configuration command. The group name is used in the subject
+ and issuer fields of trusted certificates and when constructing the file names
+ for identity keys. All hosts must have different host names specified by the <tt>-s</tt> option
+ and matching the <tt>host</tt> option of the <tt>crypto</tt> configuration command.
+ Host names are used in the subject and issuer fields of nontrusted certificates
+ and when constructing the file names for host and sign keys and certificates.
+ Host and group names are used only for authentication purposes and have nothing
+ to do with NS names.</p>
+
+<h4 id="ident">Identity Schemes</h4>
+
+<p>As described on the <a href="authopt.html">Authentication Options</a> page, there are five identity schemes, three of which - IFF, GQ and MV - require identity keys specific to each scheme. There are two types of files for each scheme, an encrypted keys file and a nonencrypted parameters file, which usually contains a subset of the keys file. In general, NTP secondary servers operating as certificate signing authorities (CSA) use the keys file and clients use the parameters file. Both files are generated by the TA operating as a certificate authority (CA) on behalf of all servers and clients in the group.</p>
+
+<p>The parameters files are public; they can be stored in a public place and sent in the clear. The keys files are encrypted with the local password. To retrieve the keys file, a host sends a mail request to the TA including its local password. The TA encrypts the keys file with this password and returns it as an attachment. The attachment is then copied intact to the keys directory with name given in the first line of the file, but all in lower case and with the filestamp deleted..</p>
+
+<p>For example, the TA can generate IFF keys and trusted certificate using the command</p>
+
+<p><tt>ntp-keygen -p <i>local_passwd</i> -T -I</tt></p>
+
+<p>Once these media have been generated, the TA can then generate the public parameters using the command</p>
+
+<p><tt>ntp-keygen -p local_passwd -e ><i>parameters_file</i></tt></p>
+
+<p>where the <tt>-e</tt> option redirects the unencrypted parameters to the standard output stream for a mail application or stored locally for later distribution. In a similar fashion the <tt>-q</tt> option redirects the encrypted server keys to the standard output stream.</p>
+
+<h4 id="cmd">Command Line Options</h4>
+
+<dl>
+
+<dt><tt>-c [ RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ]</tt></dt>
+<dd>Select certificate and message digest/signature encryption scheme. Note that RSA schemes must be used with a RSA sign key and DSA schemes must be used with a DSA sign key. The default without this option is <tt>RSA-MD5</tt>.</dd>
+
+<dt><tt>-d</tt></dt>
+<dd>Enable debugging. This option displays the cryptographic data produced for eye-friendly billboards.</dd>
+
+<dt><tt>-e</tt></dt>
+<dd>Extract the IFF or GQ public parameters from the <tt>IFFkey</tt> or <tt>GQkey</tt> keys file previously specified. Send the unencrypted data to the standard output stream <tt>stdout</tt>. While the IFF parameters do not reveal the private group key, the GQ parameters should be used with caution, as they include the group key. Use the <tt>-q</tt> option with password instead. Note: a new certificate is not generated when this option is present. This allows multiple commands with this option but without disturbing existing media.</dd>
+
+<dt><tt>-G</tt></dt>
+<dd>Generate GQ key file <tt>GQkey and</tt> link <tt>gqkey </tt>for the Guillou-Quisquater
+ (GQ) identity scheme.</dd>
+
+<dt><tt>-H</tt></dt>
+<dd>Generate a new public/private host keys <tt>RSAkey</tt>, and link <tt>host</tt>.</dd>
+
+<dt><tt>-i <i>group</i></tt></dt>
+<dd>Set the group name to <tt><i>group</i></tt>. This is used in the identity file names. It must match the group name specified in the <tt>ident</tt> option of the <tt>crypto</tt> configuration command.</dd>
+
+<dt><tt>-I</tt></dt>
+<dd>Generate a new encrypted IFF key file <tt>IFFkey </tt>and link <tt>iffkey </tt>for the Schnorr (IFF) identity scheme.</dd>
+
+<dt><tt>-m <i>modulus</i></tt></dt>
+<dd>Set the modulus for generating files to <i>modulus</i> bits. The modulus defaults to 512, but can be set from this value to 2048.</dd>
+
+<dt><tt>-M</tt></dt>
+<dd>Generate a new MD5 key file.</dd>
+
+<dt><tt>-P</tt></dt>
+<dd>Generate a new private certificate used by the PC identity scheme. By default, the program generates public certificates. Note: the PC identity scheme is not recommended for new installations.</dd>
+
+<dt><tt>-p <i>passwd</i></tt></dt>
+<dd>Set the password for reading and writing encrypted files to <tt><i>passwd</i></tt>. By default, the password is the host name.</dd>
+
+<dt><tt>-q <i>passwd</i></tt></dt>
+<dd>Extract the encrypted IFF or GQ server keys from the <tt>IFFkey</tt> or <tt>GQkey</tt> key file previously generated. The data are sent to the standard output stream <tt>stdout</tt>. Set the password for writing the data, which is also the password to read the data file in another host. By default, the password is the host name. Note: a new certificate is not generated when this option is present. This allows multiple commands with this option but without disturbing existing media.</dd>
+
+<dt><tt>-S [ RSA | DSA ]</tt></dt>
+<dd>Generate a new sign key of the designated type. By default, the sign key is the host key.</dd>
+
+<dt><tt>-s <i>host</i></tt></dt>
+<dd>Set the host name to <tt><i>host</i></tt>. This is used in the host and sign key file names. It must match the host name specified in the <tt>host</tt> option of the <tt>crypto</tt> configuration command.</dd>
+
+<dt><tt>-T</tt></dt>
+<dd>Generate a trusted certificate. By default, the program generates nontrusted certificates.</dd>
+
+<dt><tt>-V <i>nkeys</i></tt></dt>
+<dd>Generate server parameters <tt>MV</tt> and <tt><i>nkeys</i></tt> client keys for the Mu-Varadharajan (MV) identity scheme. Note: support for this option should be considered a work in progress.</dd>
+
+</dl>
+
+<h4 id="rand">Random Seed File</h4>
+
+<p>All cryptographically sound key generation schemes must have means to randomize the entropy seed used to initialize the internal pseudo-random number generator used by the OpenSSL library routines. If a site supports <tt>ssh</tt>, it is very likely that means to do this are already available. The entropy seed used by the OpenSSL library is contained in a file, usually called <tt>.rnd</tt>, which must be available when starting the <tt>ntp-keygen</tt> program or <tt>ntpd</tt> daemon.</p>
+
+<p>The OpenSSL library looks for the file using the path specified by the <tt>RANDFILE</tt> environment variable in the user home directory, whether root or some other user. If the <tt>RANDFILE</tt> environment variable is not present, the library looks for the <tt>.rnd</tt> file in the user home directory. Since both the <tt>ntp-keygen</tt> program and <tt>ntpd</tt> daemon must run as root, the logical place to put this file is in <tt>/.rnd</tt> or <tt>/root/.rnd</tt>. If the file is not available or cannot be written, the program exits with a message to the system log.</p>
+
+<h4 id="priv">Cryptographic Data Files</h4>
+
+<p>File and link names are in the form <tt>ntpkey_<i>key</i>_<i>name</i>.<i>fstamp</i></tt>, where <tt><i>key</i></tt> is the key or parameter type, <tt><i>name</i></tt> is the host or group name and <tt><i>fstamp</i></tt> is the filestamp (NTP seconds) when the file was created). By convention, key fields in generated file names include both upper and lower case alphanumeric characters, while key fields in generated link names include only lower case characters. The filestamp is not used in generated link names.</p>
+
+<p>The key type is a string defining the cryptographic function. Key types include public/private keys <tt>host </tt>and <tt>sign</tt>, certificate <tt>cert</tt> and several challenge/response key types. By convention, files used for challenges have a <tt>par</tt> subtype, as in the IFF challenge <tt>IFFpar</tt>, while files for responses have a <tt>key</tt> subtype, as in the GQ response <tt>GQkey</tt>.</p>
+
+<p>All files begin with two nonencrypted lines. The first line contains the file
+ name in the format <tt>ntpkey_<i>key</i>_<i>host</i>.<i>fstamp</i></tt>. The
+ second line contains the datestamp in conventional Unix <tt>date</tt> format.
+ Lines beginning with <tt>#</tt> are ignored.</p>
+
+<p>The remainder of the file contains cryptographic data encoded first using ASN.1 rules, then encrypted using the DES-CBC algorithm and given password and finally written in PEM-encoded printable ASCII text preceded and followed by MIME content identifier lines.</p>
+
+<p id="symkey">The format of the symmetric keys file is somewhat different than the other files in the interest of backward compatibility. Since DES-CBC is deprecated in NTPv4, the only key format of interest is MD5 alphanumeric strings. Following the header the keys are entered one per line in the format</p>
+
+<p><i><tt>keyno type key</tt></i></p>
+
+<p>where <i><tt>keyno</tt></i> is a positive integer in the range 1-65,535, <i><tt>type</tt></i> is the string <tt>MD5</tt> defining the key format and <i><tt>key</tt></i> is the key itself, which is a printable ASCII string 16 characters or less in length. Each character is chosen from the 93 printable characters in the range 0x21 through 0x7f excluding space and the '#' character.</p>
+
+<p>Note that the keys used by the <tt>ntpq</tt> and <tt>ntpdc</tt> programs are checked against passwords requested by the programs and entered by hand, so it is generally appropriate to specify these keys in human readable ASCII format.</p>
+
+<p>The <tt>ntp-keygen</tt> program generates a MD5 symmetric keys file <tt>ntpkey_MD5key_<i>hostname.filestamp</i></tt>. Since the file contains private shared keys, it should be visible only to root and distributed by secure means to other subnet hosts. The NTP daemon loads the file <tt>ntp.keys</tt>, so <tt>ntp-keygen</tt> installs a soft link from this name to the generated file. Subsequently, similar soft links must be installed by manual or automated means on the other subnet hosts. While this file is not used with the Autokey Version 2 protocol, it is needed to authenticate some remote configuration commands used by the <a href="ntpdc.html"><tt>ntpq</tt></a> and <a href="ntpq.html"><tt>ntpdc</tt></a> utilities.</p>
+
+<h4 id="bug">Bugs</h4>
+
+<p>It can take quite a while to generate some cryptographic values, from one to several minutes with modern architectures such as UltraSPARC and up to tens of minutes to an hour with older architectures such as SPARC IPC.</p>
+
+<hr>
+
+<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+
+</body>
</html>
\ No newline at end of file
EVP_SignUpdate(&ctx, (u_char *)vp, 12);
EVP_SignUpdate(&ctx, vp->ptr, sizeof(struct autokey));
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) {
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
peer->flags |= FLAG_ASSOC;
}
}
/*
* Check for valid value header opcode, association ID and
- & extension field length. The request and response opcodes must
- & match and the response ID must match the association ID. The
+ * extension field length. The request and response opcodes must
+ * match and the response ID must match the association ID. The
* autokey values response is the exception, as it can be sent
* unsolicited.
*/
EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
EVP_SignUpdate(&ctx, vp->ptr, len);
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
return (XEVNT_OK);
}
EVP_SignUpdate(&ctx, (u_char *)&pubkey, 12);
EVP_SignUpdate(&ctx, pubkey.ptr, ntohl(pubkey.vallen));
if (EVP_SignFinal(&ctx, pubkey.sig, &len, sign_pkey))
- pubkey.siglen = htonl(len);
+ pubkey.siglen = htonl(sign_siglen);
}
/*
EVP_SignUpdate(&ctx, cp->cert.ptr,
ntohl(cp->cert.vallen));
if (EVP_SignFinal(&ctx, cp->cert.sig, &len, sign_pkey))
- cp->cert.siglen = htonl(len);
+ cp->cert.siglen = htonl(sign_siglen);
}
/*
EVP_SignUpdate(&ctx, (u_char *)&tai_leap, 12);
EVP_SignUpdate(&ctx, tai_leap.ptr, len);
if (EVP_SignFinal(&ctx, tai_leap.sig, &len, sign_pkey))
- tai_leap.siglen = htonl(len);
+ tai_leap.siglen = htonl(sign_siglen);
if (leap_sec > 0)
crypto_flags |= CRYPTO_FLAG_TAI;
snprintf(statstr, NTP_MAXSTRLEN, "signature update ts %u",
EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
EVP_SignUpdate(&ctx, vp->ptr, len);
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
return (XEVNT_OK);
}
EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
EVP_SignUpdate(&ctx, vp->ptr, len);
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
return (XEVNT_OK);
}
EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
EVP_SignUpdate(&ctx, vp->ptr, len);
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
return (XEVNT_OK);
}
EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
EVP_SignUpdate(&ctx, vp->ptr, len);
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
return (XEVNT_OK);
}
EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
EVP_SignUpdate(&ctx, vp->ptr, len);
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
return (XEVNT_OK);
}
EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
EVP_SignUpdate(&ctx, vp->ptr, len);
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
return (XEVNT_OK);
}
EVP_SignUpdate(&ctx, (u_char *)vp, 12);
EVP_SignUpdate(&ctx, vp->ptr, len);
if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
- vp->siglen = htonl(len);
+ vp->siglen = htonl(sign_siglen);
}
#ifdef DEBUG
if (debug > 1)
* Load optional sign key from file "ntpkey_sign_<hostname>". If
* available, it becomes the sign key.
*/
- if (sign_file != NULL) {
- snprintf(filename, MAXFILENAME, "ntpkey_sign_%s",
- sign_file);
- pinfo = crypto_key(filename, passwd, NULL);
- if (pinfo != NULL)
- sign_pkey = pinfo->pkey;
- }
- sign_siglen = EVP_PKEY_size(sign_pkey);
+ snprintf(filename, MAXFILENAME, "ntpkey_sign_%s", sys_hostname);
+ pinfo = crypto_key(filename, passwd, NULL); if (pinfo != NULL)
+ sign_pkey = pinfo->pkey;
/*
* Load required certificate from file "ntpkey_cert_<hostname>".
}
cert_host = cinfo;
sign_digest = cinfo->digest;
+ sign_siglen = EVP_PKEY_size(sign_pkey);
if (cinfo->flags & CERT_PRIV)
crypto_flags |= CRYPTO_FLAG_PRIV;
*/
crypto_flags |= CRYPTO_FLAG_ENAB | (cinfo->nid << 16);
snprintf(statstr, NTP_MAXSTRLEN,
- "setup 0x%x host %s %s\n", crypto_flags, sys_hostname,
+ "setup 0x%x host %s %s", crypto_flags, sys_hostname,
OBJ_nid2ln(cinfo->nid));
record_crypto_stats(NULL, statstr);
#ifdef DEBUG
* MD5 (128-bit) keys used to compute message digests in symmetric
* key cryptography
*
- * ntpkey_RSAkey_<hostname>.<filestamp>
+ * ntpkey_RSAhost_<hostname>.<filestamp>
* ntpkey_host_<hostname>
* RSA private/public host key pair used for public key signatures
- * and data encryption
*
- * ntpkey_DSAkey_<hostname>.<filestamp>
+ * ntpkey_RSAsign_<hostname>.<filestamp>
* ntpkey_sign_<hostname>
- * DSA private/public sign key pair used for public key signatures,
- * but not data encryption
+ * RSA private/public sign key pair used for public key signatures
+ *
+ * ntpkey_DSAsign_<hostname>.<filestamp>
+ * ntpkey_sign_<hostname>
+ * DSA Private/public sign key pair used for public key signatures
*
* Available digest/signature schemes
*
#define MAXHOSTNAME 256 /* max host name length */
#ifdef OPENSSL
#define PLEN 512 /* default prime modulus size (bits) */
+#define ILEN 256 /* default identity modulus size (bits) */
#define MVMAX 100 /* max MV parameters */
/*
int debug = 0; /* debug, not de bug */
#ifdef OPENSSL
u_int modulus = PLEN; /* prime modulus size (bits) */
+u_int modulus2 = ILEN; /* identity modulus size (bits) */
#endif
int nkeys; /* MV keys */
time_t epoch; /* Unix epoch (seconds) since 1970 */
* Write the RSA parameters and keys as a RSA private key
* encoded in PEM.
*/
- str = fheader("RSAkey", id, hostname);
+ if (strcmp(id, "sign") == 0)
+ str = fheader("RSAsign", id, hostname);
+ else
+ str = fheader("RSAhost", id, hostname);
pkey = EVP_PKEY_new();
EVP_PKEY_assign_RSA(pkey, rsa);
PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL,
DSA *dsa; /* DSA parameters */
u_char seed[20]; /* seed for parameters */
FILE *str;
+ int bits;
/*
* Generate DSA parameters.
*/
+ bits = modulus;
+ if (bits > 1024)
+ bits = 1024;
fprintf(stderr,
- "Generating DSA parameters (%d bits)...\n", modulus);
+ "Generating DSA parameters (%d bits)...\n", bits);
RAND_bytes(seed, sizeof(seed));
- dsa = DSA_generate_parameters(modulus, seed, sizeof(seed), NULL,
+ dsa = DSA_generate_parameters(bits, seed, sizeof(seed), NULL,
NULL, cb, "DSA");
fprintf(stderr, "\n");
if (dsa == NULL) {
* Write the DSA parameters and keys as a DSA private key
* encoded in PEM.
*/
- str = fheader("DSAkey", id, hostname);
+ str = fheader("DSAsign", id, hostname);
pkey = EVP_PKEY_new();
EVP_PKEY_assign_DSA(pkey, dsa);
PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL,
* Generate DSA parameters for use as IFF parameters.
*/
fprintf(stderr, "Generating IFF keys (%d bits)...\n",
- modulus);
+ modulus2);
RAND_bytes(seed, sizeof(seed));
- dsa = DSA_generate_parameters(modulus, seed, sizeof(seed), NULL,
+ dsa = DSA_generate_parameters(modulus2, seed, sizeof(seed), NULL,
NULL, cb, "IFF");
fprintf(stderr, "\n");
if (dsa == NULL) {
*/
fprintf(stderr,
"Generating GQ parameters (%d bits)...\n",
- modulus);
- rsa = RSA_generate_key(modulus, 3, cb, "GQ");
+ modulus2);
+ rsa = RSA_generate_key(modulus2, 3, cb, "GQ");
fprintf(stderr, "\n");
if (rsa == NULL) {
fprintf(stderr, "RSA generate keys fails\n%s\n",
n = nkeys;
fprintf(stderr,
"Generating MV parameters for %d keys (%d bits)...\n", n,
- modulus / n);
+ modulus2 / n);
ctx = BN_CTX_new(); u = BN_new(); v = BN_new(); w = BN_new();
b = BN_new(); b1 = BN_new();
dsa = DSA_new();
for (j = 1; j <= n; j++) {
s1[j] = BN_new();
while (1) {
- BN_generate_prime(s1[j], modulus / n, 0, NULL,
+ BN_generate_prime(s1[j], modulus2 / n, 0, NULL,
NULL, NULL, NULL);
for (i = 1; i < j; i++) {
if (BN_cmp(s1[i], s1[j]) == 0)
temp++;
j = temp % n + 1;
while (1) {
- BN_generate_prime(u, modulus / n, 0, 0, NULL,
+ BN_generate_prime(u, modulus2 / n, 0, 0, NULL,
NULL, NULL);
for (i = 1; i <= n; i++) {
if (BN_cmp(u, s1[i]) == 0)