Skip to content

Commit 8fd150b

Browse files
committed
gpg: Remove all support for v3 keys and always create v4-signatures.
* g10/build-packet.c (do_key): Remove support for building v3 keys. * g10/parse-packet.c (read_protected_v3_mpi): Remove. (parse_key): Remove support for v3-keys. Add dedicated warnings for v3-key packets. * g10/keyid.c (hash_public_key): Remove v3-key support. (keyid_from_pk): Ditto. (fingerprint_from_pk): Ditto. * g10/options.h (opt): Remove fields force_v3_sigs and force_v4_certs. * g10/gpg.c (cmd_and_opt_values): Remove oForceV3Sigs, oNoForceV3Sigs, oForceV4Certs, oNoForceV4Certs. (opts): Turn --force-v3-sigs, --no-force-v3-sigs, --force-v4-certs, --no-force-v4-certs int dummy options. (main): Remove setting of the force_v3_sigs force_v4_certs flags. * g10/revoke.c (gen_revoke, create_revocation): Always create v4 certs. * g10/sign.c (hash_uid): Remove support for v3-signatures (hash_sigversion_to_magic): Ditto. (only_old_style): Remove this v3-key function. (write_signature_packets): Remove support for creating v3-signatures. (sign_file): Ditto. (sign_symencrypt_file): Ditto. (clearsign_file): Ditto. Remove code to emit no Hash armor line if only v3-keys are used. (make_keysig_packet): Remove arg SIGVERSION and force using v4-signatures. Change all callers to not pass a value for this arg. Remove all v3-key related code. (update_keysig_packet): Remove v3-signature support. * g10/keyedit.c (sign_uids): Always create v4-signatures. * g10/textfilter.c (copy_clearsig_text): Remove arg pgp2mode and change caller. -- v3 keys are deprecated for about 15 years and due the severe weaknesses of MD5 it does not make any sense to keep code around to use these old and broken keys. Users who need to decrypt old messages should use gpg 1.4 and best re-encrypt them to modern standards. verification of old (i.e. PGP2) created signatures is thus also not anymore possible but such signatures have no values anyway - MD5 is just too broken. We have also kept support for v3 signatures until now. With the removal of support for v3 keys it is questionable whether it makes any sense to keep support for v3-signatures. What we do now is to keep support for verification of v3-signatures but we force the use of v4-signatures. The latter makes the --pgp6 and --pgp7 switch a bit obsolete because those PGP versions require v3-signatures for messages. These versions of PGP are also really old and not anymore maintained so they have not received any bug fixes and should not be used anyway. Signed-off-by: Werner Koch <[email protected]>
1 parent 60d22d5 commit 8fd150b

15 files changed

+224
-478
lines changed

doc/OpenPGP

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
===================
1010
GnuPG (>=1.0.3) is in compliance with RFC2440 despite these exceptions:
1111

12+
* With GnuPG >= 2.1.0 all support for version 3 keys has been
13+
removed. Thus there is no more compatibility with PGP-2. Users
14+
who need to be able to decrypt old PGP 2 messages should use
15+
GnuPG 1.4.x along with the option --allow-weak-digest-algos.
16+
17+
* With GnuPG >= 2.1.0 all signatures (on messages and keys) are
18+
created using version 4 signatures. Support for verifying
19+
version 3 signature is still available.
20+
1221
* (9.2) states that IDEA SHOULD be implemented. This is not done
1322
due to patent problems.
1423
UPDATE: Since version 1.4.13 (or GnuPG 2.x with Libgcrypt 1.6)

doc/gpg.texi

+16-2
Original file line numberDiff line numberDiff line change
@@ -2129,6 +2129,7 @@ platforms that have different line ending conventions (UNIX-like to Mac,
21292129
Mac to Windows, etc). @option{--no-textmode} disables this option, and
21302130
is the default.
21312131

2132+
@ifclear gpgtwoone
21322133
@item --force-v3-sigs
21332134
@itemx --no-force-v3-sigs
21342135
@opindex force-v3-sigs
@@ -2147,6 +2148,15 @@ Defaults to no.
21472148
Always use v4 key signatures even on v3 keys. This option also
21482149
changes the default hash algorithm for v3 RSA keys from MD5 to SHA-1.
21492150
@option{--no-force-v4-certs} disables this option.
2151+
@end ifclear
2152+
2153+
@ifset gpgtwoone
2154+
@item --force-v3-sigs
2155+
@itemx --no-force-v3-sigs
2156+
@item --force-v4-certs
2157+
@itemx --no-force-v4-certs
2158+
These options are obsolete and have no effect since GnuPG 2.1.
2159+
@end ifset
21502160

21512161
@item --force-mdc
21522162
@opindex force-mdc
@@ -2301,8 +2311,12 @@ compression algorithms none and ZIP. This also disables
23012311
--throw-keyids, and making signatures with signing subkeys as PGP 6
23022312
does not understand signatures made by signing subkeys.
23032313

2304-
This option implies @option{--disable-mdc --escape-from-lines
2305-
--force-v3-sigs}.
2314+
@ifclear gpgtwoone
2315+
This option implies @option{--disable-mdc --escape-from-lines --force-v3-sigs}.
2316+
@end ifclear
2317+
@ifset gpgtwoone
2318+
This option implies @option{--disable-mdc --escape-from-lines}.
2319+
@end ifset
23062320

23072321
@item --pgp7
23082322
@opindex pgp7

g10/build-packet.c

+29-62
Original file line numberDiff line numberDiff line change
@@ -291,24 +291,13 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk)
291291
int i, nskey, npkey;
292292
iobuf_t a = iobuf_temp(); /* Build in a self-enlarging buffer. */
293293

294-
/* Write the version number - if none is specified, use 3 */
294+
/* Write the version number - if none is specified, use 4 */
295295
if ( !pk->version )
296-
iobuf_put ( a, 3 );
296+
iobuf_put ( a, 4 );
297297
else
298298
iobuf_put ( a, pk->version );
299299
write_32 (a, pk->timestamp );
300300

301-
/* v3 needs the expiration time. */
302-
if ( pk->version < 4 )
303-
{
304-
u16 ndays;
305-
if ( pk->expiredate )
306-
ndays = (u16)((pk->expiredate - pk->timestamp) / 86400L);
307-
else
308-
ndays = 0;
309-
write_16(a, ndays);
310-
}
311-
312301
iobuf_put (a, pk->pubkey_algo );
313302

314303
/* Get number of secret and public parameters. They are held in one
@@ -347,45 +336,37 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk)
347336
/* Build the header for protected (encrypted) secret parameters. */
348337
if (ski->is_protected)
349338
{
350-
if ( is_RSA (pk->pubkey_algo) && pk->version < 4 && !ski->s2k.mode )
339+
/* OpenPGP protection according to rfc2440. */
340+
iobuf_put (a, ski->sha1chk? 0xfe : 0xff);
341+
iobuf_put (a, ski->algo);
342+
if (ski->s2k.mode >= 1000)
351343
{
352-
/* The simple rfc1991 (v3) way. */
353-
iobuf_put (a, ski->algo );
354-
iobuf_write (a, ski->iv, ski->ivlen);
344+
/* These modes are not possible in OpenPGP, we use them
345+
to implement our extensions, 101 can be viewed as a
346+
private/experimental extension (this is not specified
347+
in rfc2440 but the same scheme is used for all other
348+
algorithm identifiers). */
349+
iobuf_put (a, 101);
350+
iobuf_put (a, ski->s2k.hash_algo);
351+
iobuf_write (a, "GNU", 3 );
352+
iobuf_put (a, ski->s2k.mode - 1000);
355353
}
356354
else
357355
{
358-
/* OpenPGP protection according to rfc2440. */
359-
iobuf_put (a, ski->sha1chk? 0xfe : 0xff);
360-
iobuf_put (a, ski->algo);
361-
if (ski->s2k.mode >= 1000)
362-
{
363-
/* These modes are not possible in OpenPGP, we use
364-
them to implement our extensions, 101 can be
365-
viewed as a private/experimental extension (this
366-
is not specified in rfc2440 but the same scheme
367-
is used for all other algorithm identifiers). */
368-
iobuf_put (a, 101);
369-
iobuf_put (a, ski->s2k.hash_algo);
370-
iobuf_write (a, "GNU", 3 );
371-
iobuf_put (a, ski->s2k.mode - 1000);
372-
}
373-
else
374-
{
375-
iobuf_put (a, ski->s2k.mode);
376-
iobuf_put (a, ski->s2k.hash_algo);
377-
}
378-
379-
if (ski->s2k.mode == 1 || ski->s2k.mode == 3)
380-
iobuf_write (a, ski->s2k.salt, 8);
381-
382-
if (ski->s2k.mode == 3)
383-
iobuf_put (a, ski->s2k.count);
384-
385-
/* For our special modes 1001, 1002 we do not need an IV. */
386-
if (ski->s2k.mode != 1001 && ski->s2k.mode != 1002)
387-
iobuf_write (a, ski->iv, ski->ivlen);
356+
iobuf_put (a, ski->s2k.mode);
357+
iobuf_put (a, ski->s2k.hash_algo);
388358
}
359+
360+
if (ski->s2k.mode == 1 || ski->s2k.mode == 3)
361+
iobuf_write (a, ski->s2k.salt, 8);
362+
363+
if (ski->s2k.mode == 3)
364+
iobuf_put (a, ski->s2k.count);
365+
366+
/* For our special modes 1001, 1002 we do not need an IV. */
367+
if (ski->s2k.mode != 1001 && ski->s2k.mode != 1002)
368+
iobuf_write (a, ski->iv, ski->ivlen);
369+
389370
}
390371
else /* Not protected. */
391372
iobuf_put (a, 0 );
@@ -400,7 +381,7 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk)
400381
/* The serial number gets stored in the IV field. */
401382
iobuf_write (a, ski->iv, ski->ivlen);
402383
}
403-
else if (ski->is_protected && pk->version >= 4)
384+
else if (ski->is_protected)
404385
{
405386
/* The secret key is protected - write it out as it is. */
406387
byte *p;
@@ -410,20 +391,6 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk)
410391
p = gcry_mpi_get_opaque (pk->pkey[npkey], &ndatabits);
411392
iobuf_write (a, p, (ndatabits+7)/8 );
412393
}
413-
else if (ski->is_protected)
414-
{
415-
/* The secret key is protected the old v4 way. */
416-
for ( ; i < nskey; i++ )
417-
{
418-
byte *p;
419-
unsigned int ndatabits;
420-
421-
assert (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_OPAQUE));
422-
p = gcry_mpi_get_opaque (pk->pkey[i], &ndatabits);
423-
iobuf_write (a, p, (ndatabits+7)/8);
424-
}
425-
write_16 (a, ski->csum );
426-
}
427394
else
428395
{
429396
/* Non-protected key. */

g10/filter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ int cipher_filter( void *opaque, int control,
152152
int text_filter( void *opaque, int control,
153153
iobuf_t chain, byte *buf, size_t *ret_len);
154154
int copy_clearsig_text (iobuf_t out, iobuf_t inp, gcry_md_hd_t md,
155-
int escape_dash, int escape_from, int pgp2mode);
155+
int escape_dash, int escape_from);
156156

157157
/*-- progress.c --*/
158158
progress_filter_context_t *new_progress_context (void);

g10/gpg.c

+9-16
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,6 @@ enum cmd_and_opt_values
272272
oShowPhotos,
273273
oNoShowPhotos,
274274
oPhotoViewer,
275-
oForceV3Sigs,
276-
oNoForceV3Sigs,
277-
oForceV4Certs,
278-
oNoForceV4Certs,
279275
oForceMDC,
280276
oNoForceMDC,
281277
oDisableMDC,
@@ -525,10 +521,6 @@ static ARGPARSE_OPTS opts[] = {
525521
ARGPARSE_s_n (oQuiet, "quiet", "@"),
526522
ARGPARSE_s_n (oNoTTY, "no-tty", "@"),
527523

528-
ARGPARSE_s_n (oForceV3Sigs, "force-v3-sigs", "@"),
529-
ARGPARSE_s_n (oNoForceV3Sigs, "no-force-v3-sigs", "@"),
530-
ARGPARSE_s_n (oForceV4Certs, "force-v4-certs", "@"),
531-
ARGPARSE_s_n (oNoForceV4Certs, "no-force-v4-certs", "@"),
532524
ARGPARSE_s_n (oForceMDC, "force-mdc", "@"),
533525
ARGPARSE_s_n (oNoForceMDC, "no-force-mdc", "@"),
534526
ARGPARSE_s_n (oDisableMDC, "disable-mdc", "@"),
@@ -810,6 +802,10 @@ static ARGPARSE_OPTS opts[] = {
810802
ARGPARSE_s_n (oNoop, "no-sk-comments", "@"),
811803
ARGPARSE_s_n (oNoop, "compress-keys", "@"),
812804
ARGPARSE_s_n (oNoop, "compress-sigs", "@"),
805+
ARGPARSE_s_n (oNoop, "force-v3-sigs", "@"),
806+
ARGPARSE_s_n (oNoop, "no-force-v3-sigs", "@"),
807+
ARGPARSE_s_n (oNoop, "force-v4-certs", "@"),
808+
ARGPARSE_s_n (oNoop, "no-force-v4-certs", "@"),
813809

814810
ARGPARSE_end ()
815811
};
@@ -2535,7 +2531,6 @@ main (int argc, char **argv)
25352531
opt.allow_freeform_uid = 1;
25362532
opt.pgp2_workarounds = 0;
25372533
opt.escape_from = 1;
2538-
opt.force_v3_sigs = 0;
25392534
opt.not_dash_escaped = 0;
25402535
opt.def_cipher_algo = 0;
25412536
opt.def_digest_algo = 0;
@@ -2553,7 +2548,6 @@ main (int argc, char **argv)
25532548
opt.allow_freeform_uid = 1;
25542549
opt.pgp2_workarounds = 0;
25552550
opt.escape_from = 0;
2556-
opt.force_v3_sigs = 0;
25572551
opt.not_dash_escaped = 0;
25582552
opt.def_cipher_algo = 0;
25592553
opt.def_digest_algo = 0;
@@ -2637,10 +2631,7 @@ main (int argc, char **argv)
26372631
opt.verify_options&=~VERIFY_SHOW_PHOTOS;
26382632
break;
26392633
case oPhotoViewer: opt.photo_viewer = pargs.r.ret_str; break;
2640-
case oForceV3Sigs: opt.force_v3_sigs = 1; break;
2641-
case oNoForceV3Sigs: opt.force_v3_sigs = 0; break;
2642-
case oForceV4Certs: opt.force_v4_certs = 1; break;
2643-
case oNoForceV4Certs: opt.force_v4_certs = 0; break;
2634+
26442635
case oForceMDC: opt.force_mdc = 1; break;
26452636
case oNoForceMDC: opt.force_mdc = 0; break;
26462637
case oDisableMDC: opt.disable_mdc = 1; break;
@@ -3288,15 +3279,17 @@ main (int argc, char **argv)
32883279
/* Do these after the switch(), so they can override settings. */
32893280
if(PGP6)
32903281
{
3282+
/* That does not anymore work becuase we have no more support
3283+
for v3 signatures. */
32913284
opt.disable_mdc=1;
32923285
opt.escape_from=1;
3293-
opt.force_v3_sigs=1;
32943286
opt.ask_sig_expire=0;
32953287
}
32963288
else if(PGP7)
32973289
{
3290+
/* That does not anymore work because we have no more support
3291+
for v3 signatures. */
32983292
opt.escape_from=1;
3299-
opt.force_v3_sigs=1;
33003293
opt.ask_sig_expire=0;
33013294
}
33023295
else if(PGP8)

0 commit comments

Comments
 (0)