From 93b7fb4a1742b1284d329b5768fa25044bfea055 Mon Sep 17 00:00:00 2001 From: Moritz Schulte Date: Mon, 9 Aug 2004 11:58:26 +0000 Subject: [PATCH] 2004-08-09 Moritz Schulte * gpgsm-gencert.sh: New file. --- tools/ChangeLog | 4 ++ tools/gpgsm-gencert.sh | 115 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100755 tools/gpgsm-gencert.sh diff --git a/tools/ChangeLog b/tools/ChangeLog index e4862bc38..841fb0c98 100644 --- a/tools/ChangeLog +++ b/tools/ChangeLog @@ -1,3 +1,7 @@ +2004-08-09 Moritz Schulte + + * gpgsm-gencert.sh: New file. + 2004-06-16 Werner Koch * rfc822parse.c (rfc822parse_get_field): Add arg VALUEOFF. diff --git a/tools/gpgsm-gencert.sh b/tools/gpgsm-gencert.sh new file mode 100755 index 000000000..3241efd94 --- /dev/null +++ b/tools/gpgsm-gencert.sh @@ -0,0 +1,115 @@ +#!/bin/sh + +# gpgsm-gencert.c - Generate X.509 certificates through GPGSM. +# Copyright (C) 2004 g10 Code GmbH +# +# This file is part of GnuPG. +# +# GnuPG is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GnuPG is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +set -e + +ASSUAN_FP_IN=4 +ASSUAN_FP_OUT=5 + +ASSUAN_COMMANDS="\ +INPUT FD=$ASSUAN_FP_IN\n\ +OUTPUT FD=$ASSUAN_FP_OUT --armor\n\ +GENKEY\n\ +BYE" + +ANSWER="" + +query_user() +{ + message=$1; shift + + echo "$message" + echo -n "> " + read answer + + ANSWER=$answer; +} + +query_user_menu() +{ + message=$1; shift + i=0 + + echo "$message" + for choice in "$@"; do + i=$(expr $i + 1) + echo " [$i] $choice" + done + + while true; do + j=1 + echo -n "Your selection: " + read idx + + while [ $j -lt $i -o $j -eq $i ]; do + if [ "$idx" = $j ]; then + break + fi + j=$(expr $j + 1) + done + if [ $j -lt $i -o $j -eq $i ]; then + break + fi + done + + i=0 + for choice in "$@"; do + i=$(expr $i + 1) + if [ $i -eq $idx ]; then + ANSWER=$1 + break; + fi + shift + done + + echo "You selected: $ANSWER" +} + +query_user_menu "Key type" "RSA" +KEY_TYPE=$ANSWER + +query_user_menu "Key length" "1024" "2048" +KEY_LENGTH=$ANSWER + +query_user_menu "Key usage" "sign, encrypt" +KEY_USAGE=$ANSWER + +query_user "Name" +NAME=$ANSWER + +query_user "E-Mail address" +EMAIL_ADDRESS=$ANSWER + +file_parameter=$(mktemp "/tmp/gpgsm.XXXXXX") + +cat > "$file_parameter" <&1 + +rm "$file_parameter" +exit 0