IPSEC_RSASIGKEY(8) Executable programs IPSEC_RSASIGKEY(8)
ipsec_rsasigkey - generate RSA signature key
ipsec rsasigkey [--verbose] [--random filename] [--configdir nssdbdir] [--password nsspassword] [--hostname hostname] [nbits]
ipsec rsasigkey [--verbose] [--configdir nssdbdir] [--password nsspassword] [--hostname hostname]
Rsasigkey generates an RSA public/private key pair, suitable for digital signatures, of (exactly) nbits bits (that is, two primes each of
exactly nbits/2 bits, and related numbers) and emits it on standard output as ASCII (mostly hex) data. nbits must be a multiple of 16.
The public exponent is forced to the value 3, which has important speed advantages for signature checking. Beware that the resulting keys
have known weaknesses as encryption keys and should not be used for that purpose.
The --verbose option makesrsasigkey give a running commentary on standard error. By default, it works in silence until it is ready to
The --random option specifies a source for random bits used to seed the crypto library's RNG. The default is /dev/random (see random(4)).
FreeS/WAN and Openswan without NSS support used this option to specify the random source used to directly create keys. Libreswan only uses
it to seed the crypto libraries RNG. Under Linux with hardware random support, special devices might show up as /dev/*rng* devices.
However, these should never be access directly using this option, as hardware failures could lead to extremely non-random values (streams
of zeroes have been observed in the wild)
The --configdir option specifies the nss configuration directory to use. This is the directory where the NSS certificate, key and security
modules databases reside. The default value is /etc/ipsec.d.
The --password option specifies the nss cryptographic module authentication password if the NSS module has been configured to require it. A
password is required by hardware tokens and also by the internal softotken module when configured to run in FIPS mode.
The --hostname option specifies what host name to use in the first line of the output (see below); the default is what gethostname(2)
The output format looks like this (with long numbers trimmed down for clarity):
# RSA 2048 bits xy.example.com Sat Apr 15 13:53:22 2000
# for signatures only, UNSAFE FOR ENCRYPTION
# everything after this point is secret
The first (comment) line, indicating the nature and date of the key, and giving a host name, is used by ipsec_showhostkey(8) when
generating some forms of key output.
The commented-out pubkey= line contains the public key, the public exponent and the modulus combined in approximately RFC 2537 format (the
one deviation is that the combined value is given with a 0s prefix, rather than in unadorned base-64), suitable for use in the ipsec.conf
The Modulus, PublicExponent and PrivateExponent lines give the basic signing and verification data.
The Prime1 and Prime2 lines give the primes themselves (aka p and q), largest first. The Exponent1 and Exponent2 lines give the private
exponent mod p-1 and q-1 respectively. The Coefficient line gives the Chinese Remainder Theorem coefficient, which is the inverse of q, mod
p. These additional numbers (which must all be kept as secret as the private exponent) are precomputed aids to rapid signature generation.
When NSS is used, these values are not available outside the NSS security database (softtoken or hardware token) and are instead filled in
with the CKA_ID.
No attempt is made to break long lines.
The US patent on the RSA algorithm expired 20 Sept 2000.
ipsec rsasigkey --verbose 4096 >mykey.txt
generates a 4096-bit signature key and puts it in the file mykey.txt, with running commentary on standard error. The file contents can
be inserted verbatim into a suitable entry in the ipsec.secrets file (see ipsec_secrets(5)), and the public key can then be extracted
and edited into the ipsec.conf (see ipsec_showhostkey(8)).
random(4), rngd(8), ipsec_showhostkey(8), Applied Cryptography, 2nd. ed., by Bruce Schneier, Wiley 1996, RFCs 2537, 2313, GNU MP, the GNU
multiple precision arithmetic library, edition 2.0.2, by Torbj Granlund
Originally written for the Linux FreeS/WAN project <http://www.freeswan.org> by Henry Spencer. Updated for the Libreswan Project by Paul
The --round and --noopt options were obsoleted as these were only used with the old non-library crypto code
The --random device is only used for seeding the crypto library, not for direct random to generate keys
There is an internal limit on nbits, currently 20000.
rsasigkey's run time is difficult to predict, since /dev/random output can be arbitrarily delayed if the system's entropy pool is low on
randomness, and the time taken by the search for primes is also somewhat unpredictable. Specifically, embedded systems and most virtual
machines are low on entropy. In such a situation, consider generating the RSA key on another machine, and copying ipsec.secrets and the
ipsec.d/*db files to the embedded platform. Note that NSS embeds the full path in the DB files, so the path on proxy machine must be
identical to the path on the destination machine.
placeholder to suppress warning
libreswan 09/06/2013 IPSEC_RSASIGKEY(8)