~ubuntu-branches/ubuntu/raring/gnupg2/raring-proposed

« back to all changes in this revision

Viewing changes to agent/genkey.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-11-06 11:25:58 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20121106112558-kxptsug6ivixhx8m
Tags: 2.0.19-1ubuntu1
* Resynchronize on Debian, remaining changes:
  - Add udev rules to give gpg access to some smartcard readers;
    Debian #543217.
    . debian/gnupg2.dev: udev rules to set ACLs on SCM smartcard readers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
  unsigned char *buf;
38
38
  size_t len;
39
39
  unsigned char grip[20];
40
 
  
 
40
 
41
41
  if ( !gcry_pk_get_keygrip (private, grip) )
42
42
    {
43
43
      log_error ("can't calculate keygrip\n");
105
105
  if (!infp)
106
106
    {
107
107
      err = gpg_error_from_syserror ();
108
 
      log_error (_("error creating temporary file: %s\n"), strerror (errno));
 
108
      log_error (_("error creating temporary file: %s\n"), gpg_strerror (err));
109
109
      return 1; /* Error - assume password should not be used.  */
110
110
    }
111
111
 
113
113
    {
114
114
      err = gpg_error_from_syserror ();
115
115
      log_error (_("error writing to temporary file: %s\n"),
116
 
                 strerror (errno));
 
116
                 gpg_strerror (err));
117
117
      fclose (infp);
118
118
      return 1; /* Error - assume password should not be used.  */
119
119
    }
143
143
}
144
144
 
145
145
 
146
 
static int 
 
146
static int
147
147
take_this_one_anyway2 (ctrl_t ctrl, const char *desc, const char *anyway_btn)
148
148
{
149
149
  gpg_error_t err;
161
161
}
162
162
 
163
163
 
164
 
static int 
 
164
static int
165
165
take_this_one_anyway (ctrl_t ctrl, const char *desc)
166
166
{
167
167
  return take_this_one_anyway2 (ctrl, desc, _("Take this one anyway"));
182
182
  if (!pw)
183
183
    pw = "";
184
184
 
185
 
  if (utf8_charcount (pw) < minlen ) 
 
185
  if (utf8_charcount (pw) < minlen )
186
186
    {
187
187
      char *desc;
188
 
      
 
188
 
189
189
      if (silent)
190
190
        return gpg_error (GPG_ERR_INV_PASSPHRASE);
191
191
 
192
 
      desc = xtryasprintf 
 
192
      desc = xtryasprintf
193
193
        ( ngettext ("Warning: You have entered an insecure passphrase.%%0A"
194
 
                    "A passphrase should be at least %u character long.", 
 
194
                    "A passphrase should be at least %u character long.",
195
195
                    "Warning: You have entered an insecure passphrase.%%0A"
196
 
                    "A passphrase should be at least %u characters long.", 
 
196
                    "A passphrase should be at least %u characters long.",
197
197
                    minlen), minlen );
198
198
      if (!desc)
199
199
        return gpg_error_from_syserror ();
203
203
        return err;
204
204
    }
205
205
 
206
 
  if (nonalpha_count (pw) < minnonalpha ) 
 
206
  if (nonalpha_count (pw) < minnonalpha )
207
207
    {
208
208
      char *desc;
209
209
 
210
210
      if (silent)
211
211
        return gpg_error (GPG_ERR_INV_PASSPHRASE);
212
212
 
213
 
      desc = xtryasprintf 
 
213
      desc = xtryasprintf
214
214
        ( ngettext ("Warning: You have entered an insecure passphrase.%%0A"
215
215
                    "A passphrase should contain at least %u digit or%%0A"
216
 
                    "special character.", 
 
216
                    "special character.",
217
217
                    "Warning: You have entered an insecure passphrase.%%0A"
218
218
                    "A passphrase should contain at least %u digits or%%0A"
219
219
                    "special characters.",
256
256
                            "this is in general a bad idea!%0A"
257
257
                            "Please confirm that you do not want to "
258
258
                            "have any protection on your key."));
259
 
      
 
259
 
260
260
      if (silent)
261
261
        return gpg_error (GPG_ERR_INV_PASSPHRASE);
262
262
 
288
288
   KEYPARAM */
289
289
int
290
290
agent_genkey (ctrl_t ctrl, const char *keyparam, size_t keyparamlen,
291
 
              membuf_t *outbuf) 
 
291
              membuf_t *outbuf)
292
292
{
293
293
  gcry_sexp_t s_keyparam, s_key, s_private, s_public;
294
294
  struct pin_entry_info_s *pi, *pi2;
347
347
        xfree (pi);
348
348
        return rc;
349
349
      }
350
 
        
 
350
 
351
351
    if (!*pi->pin)
352
352
      {
353
353
        xfree (pi);
383
383
      return gpg_error (GPG_ERR_INV_DATA);
384
384
    }
385
385
  gcry_sexp_release (s_key); s_key = NULL;
386
 
  
 
386
 
387
387
  /* store the secret key */
388
388
  if (DBG_CRYPTO)
389
389
    log_debug ("storing private key\n");
422
422
 
423
423
/* Apply a new passpahrse to the key S_SKEY and store it. */
424
424
int
425
 
agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey) 
 
425
agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey)
426
426
{
427
427
  struct pin_entry_info_s *pi, *pi2;
428
428
  int rc;