summaryrefslogtreecommitdiff
path: root/tools/mkkeypair
diff options
context:
space:
mode:
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2012-10-27 21:02:32 +0000
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2012-10-27 21:02:32 +0000
commit70f1558a2eca8295e30bb1e381d948056333634d (patch)
tree3051cb6afbc7d5ebae4381e54c70d9cbe54005a4 /tools/mkkeypair
parent4f1edcf052857117fd51e878c362f878961c4dc9 (diff)
- Second time's the charm? Moving svnroot/ircd-hybrid-8 to
svnroot/ircd-hybrid/trunk git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@1592 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'tools/mkkeypair')
-rwxr-xr-xtools/mkkeypair54
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/mkkeypair b/tools/mkkeypair
new file mode 100755
index 0000000..7393a10
--- /dev/null
+++ b/tools/mkkeypair
@@ -0,0 +1,54 @@
+#!/bin/sh
+# $Id$
+#
+# mkkeypair - short shell script to generate a OpenSSL RSA key suitable
+# for use with cryptlinks.
+#
+# (C) 2003 Joshua Kwan and the IRCD-Hybrid team
+# See LICENSE for the terms of copying.
+
+if test -f rsa.key; then
+ echo Moving old key out of the way to rsa.key.old
+ mv rsa.key rsa.key.old
+fi
+
+if test -f rsa.pub; then
+ echo Moving old public key out of the way to rsa.pub.old
+ mv rsa.pub rsa.pub.old
+fi
+
+echo Generating random bytes
+
+if test -c /dev/urandom; then
+ RANDGEN=/dev/urandom
+elif test -c /dev/random; then
+ RANDGEN=/dev/random
+else
+ RANDGEN=input
+fi
+
+if test "$RANDGEN" = input; then
+ echo "Your system doesn't have a suitable random data generator,"
+ echo "so type 150 characters of gibberish here to simulate it."
+ read -n 150 randomdata
+ echo
+ echo "$randomdata" > randdata
+ sort < randdata >> randdata.1
+ cat randdata.1 >> randdata
+ rm -f randdata.1
+else
+ dd if=$RANDGEN of=randdata count=1 bs=2048
+fi
+
+echo Creating the private key.
+openssl genrsa -rand randdata -out rsa.key 2048 || exit 1
+chmod 600 rsa.key
+echo Creating the public key from the private key.
+openssl rsa -in rsa.key -out rsa.pub -pubout || exit 1
+chmod 644 rsa.pub
+
+echo
+echo Private key now exists as rsa.key
+echo Public key now exists as rsa.pub
+
+rm -f randdata