2
# $Id: mkkeypair 3076 2014-02-27 20:08:52Z michael $
4
# mkkeypair - short shell script to generate a OpenSSL RSA key suitable
5
# for use with cryptlinks.
7
# (C) 2003 Joshua Kwan and the IRCD-Hybrid team
8
# See COPYING for the terms of copying.
10
if test -f rsa.key; then
11
echo Moving old key out of the way to rsa.key.old
12
mv rsa.key rsa.key.old
15
if test -f rsa.pub; then
16
echo Moving old public key out of the way to rsa.pub.old
17
mv rsa.pub rsa.pub.old
20
echo Generating random bytes
22
if test -c /dev/urandom; then
24
elif test -c /dev/random; then
30
if test "$RANDGEN" = input; then
31
echo "Your system doesn't have a suitable random data generator,"
32
echo "so type 150 characters of gibberish here to simulate it."
33
read -n 150 randomdata
35
echo "$randomdata" > randdata
36
sort < randdata >> randdata.1
37
cat randdata.1 >> randdata
40
dd if=$RANDGEN of=randdata count=1 bs=2048
43
echo Creating the private key.
44
openssl genrsa -rand randdata -out rsa.key 2048 || exit 1
46
echo Creating the public key from the private key.
47
openssl rsa -in rsa.key -out rsa.pub -pubout || exit 1
51
echo Private key now exists as rsa.key
52
echo Public key now exists as rsa.pub