~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-updates

« back to all changes in this revision

Viewing changes to tools/gpgsm-gencert.sh

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#
8
8
# GnuPG is free software; you can redistribute it and/or modify
9
9
# it under the terms of the GNU General Public License as published by
10
 
# the Free Software Foundation; either version 2 of the License, or
 
10
# the Free Software Foundation; either version 3 of the License, or
11
11
# (at your option) any later version.
12
12
#
13
13
# GnuPG is distributed in the hope that it will be useful,
16
16
# GNU General Public License for more details.
17
17
#
18
18
# You should have received a copy of the GNU General Public License
19
 
# along with this program; if not, write to the Free Software
20
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
 
# 02111-1307, USA.
 
19
# along with this program; if not, see <http://www.gnu.org/licenses/>.
22
20
 
23
21
set -e
24
22
 
29
27
INPUT FD=$ASSUAN_FP_IN\n\
30
28
OUTPUT FD=$ASSUAN_FP_OUT --armor\n\
31
29
GENKEY\n\
32
 
BYE"
 
30
BYE\n"
33
31
 
34
32
ANSWER=""
35
33
 
84
82
    echo "You selected: $ANSWER" >&2
85
83
}
86
84
 
87
 
query_user_menu "Key type" "RSA" "existing key"
88
 
if [ "$ANSWER" = "existing key" ]; then
89
 
  # User requested to use an existing key; need to set some dummy defaults
90
 
  KEY_TYPE=RSA 
91
 
  KEY_LENGTH=1024
92
 
  query_user "Keygrip "
93
 
  KEY_GRIP=$ANSWER
94
 
else
95
 
  KEY_TYPE=$ANSWER
96
 
  query_user_menu "Key length" "1024" "2048"
97
 
  KEY_LENGTH=$ANSWER
98
 
  KEY_GRIP=
99
 
fi
100
 
 
 
85
 
 
86
 
 
87
KEY_TYPE=""
 
88
while [ -z "$KEY_TYPE" ]; do
 
89
  query_user_menu "Key type" "RSA" "Existing key" "Direct from card"
 
90
  case "$ANSWER" in
 
91
    RSA)
 
92
      KEY_TYPE=$ANSWER
 
93
      query_user_menu "Key length" "1024" "2048"
 
94
      KEY_LENGTH=$ANSWER
 
95
      KEY_GRIP=
 
96
      ;;
 
97
    Existing*)
 
98
      # User requested to use an existing key; need to set some dummy defaults
 
99
      query_user "Keygrip "
 
100
      if [ -n "$ANSWER" ]; then
 
101
        KEY_TYPE=RSA 
 
102
        KEY_LENGTH=1024
 
103
        KEY_GRIP=$ANSWER
 
104
      fi
 
105
      ;;
 
106
    Direct*)
 
107
      tmp=$(echo 'SCD SERIALNO' | gpg-connect-agent | \
 
108
            awk '$2 == "SERIALNO" {print $3}') 
 
109
      if [ -z "$tmp" ]; then
 
110
          echo "No card found" >&2
 
111
      else
 
112
        echo "Card with S/N $tmp found" >&2
 
113
        tmp=$(echo 'SCD LEARN --force' | gpg-connect-agent | \
 
114
              awk '$2 == "KEYPAIRINFO" {printf " %s", $4}')
 
115
        sshid=$(echo 'SCD GETATTR $AUTHKEYID' | gpg-connect-agent | \
 
116
                awk '$2 == "$AUTHKEYID" {print $3}') 
 
117
        [ -n "$sshid" ] && echo "gpg-agent uses $sshid as ssh key" >&2
 
118
        query_user_menu "Select key " $tmp "back"
 
119
        if [ "$ANSWER" != "back" ]; then
 
120
          KEY_TYPE="card:$ANSWER"
 
121
          KEY_LENGTH=
 
122
          KEY_GRIP=
 
123
        fi
 
124
      fi
 
125
      ;;
 
126
    *)
 
127
      exit 1
 
128
      ;;   
 
129
  esac
 
130
done
101
131
 
102
132
query_user_menu "Key usage" "sign, encrypt" "sign" "encrypt"
103
133
KEY_USAGE=$ANSWER
161
191
[ "$ANSWER" != "yes" ] && exit 1
162
192
    
163
193
 
164
 
echo -e "$ASSUAN_COMMANDS" | \
165
 
    gpgsm --no-log-file --debug-level none --debug-none \
 
194
printf "$ASSUAN_COMMANDS" | \
 
195
     gpgsm --no-log-file --debug-level none --debug-none \
166
196
           --server 4< "$file_parameter" 5>"$outfile" >/dev/null
167
197
 
168
198
cat "$outfile"