1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

gpg: Change armor Version header to emit only the major version.

* g10/options.h (opt): Rename field no_version to emit_version.
* g10/gpg.c (main): Init opt.emit_vesion to 1.  Change --emit-version
to bump up opt.emit_version.
* g10/armor.c (armor_filter): Implement different --emit-version
values.
--

GnuPG-bug-id: 1572
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit e951782e93)

Resolved conflicts:
	NEWS
	g10/armor.c
	g10/gpg.c
This commit is contained in:
Werner Koch 2013-11-27 09:20:02 +01:00
parent 571bcd4662
commit fd5f452496
5 changed files with 49 additions and 22 deletions

View file

@ -147,7 +147,7 @@ release_armor_context (armor_filter_context_t *afx)
int
push_armor_filter (armor_filter_context_t *afx, iobuf_t iobuf)
{
int rc;
int rc;
afx->refcount++;
rc = iobuf_push_filter (iobuf, armor_filter, afx);
@ -981,7 +981,7 @@ armor_filter( void *opaque, int control,
/* We need some space for the faked packet. The minmum
* required size is the PARTIAL_CHUNK size plus a byte for the
* length itself */
if( size < PARTIAL_CHUNK+1 )
if( size < PARTIAL_CHUNK+1 )
BUG(); /* supplied buffer too short */
if( afx->faked )
@ -1000,7 +1000,7 @@ armor_filter( void *opaque, int control,
unsigned int hashes = afx->hashes;
const byte *sesmark;
size_t sesmarklen;
sesmark = get_session_marker( &sesmarklen );
if ( sesmarklen > 20 )
BUG();
@ -1022,7 +1022,7 @@ armor_filter( void *opaque, int control,
buf[n++] = 0xff; /* new format, type 63, 1 length byte */
n++; /* see below */
memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
buf[n++] = CTRLPKT_CLEARSIGN_START;
buf[n++] = CTRLPKT_CLEARSIGN_START;
buf[n++] = afx->not_dash_escaped? 0:1; /* sigclass */
if( hashes & 1 )
buf[n++] = DIGEST_ALGO_RMD160;
@ -1076,10 +1076,24 @@ armor_filter( void *opaque, int control,
iobuf_writestr(a, head_strings[afx->what] );
iobuf_writestr(a, "-----" );
iobuf_writestr(a,afx->eol);
if( !opt.no_version )
if (opt.emit_version)
{
iobuf_writestr(a, "Version: GnuPG v" VERSION " ("
PRINTABLE_OS_NAME ")" );
iobuf_writestr (a, "Version: GnuPG v");
for (s=VERSION; *s && *s != '.'; s++)
iobuf_writebyte (a, *s);
if (opt.emit_version > 1 && *s)
{
iobuf_writebyte (a, *s++);
for (; *s && *s != '.'; s++)
iobuf_writebyte (a, *s);
if (opt.emit_version > 2)
{
for (; *s && *s != '-' && !spacep (s); s++)
iobuf_writebyte (a, *s);
if (opt.emit_version > 3)
iobuf_writestr (a, " (" PRINTABLE_OS_NAME ")");
}
}
iobuf_writestr(a,afx->eol);
}
@ -1283,7 +1297,7 @@ make_radix64_string( const byte *data, size_t len )
/***********************************************
* For the pipemode command we can't use the armor filter for various
* reasons, so we use this new unarmor_pump stuff to remove the armor
* reasons, so we use this new unarmor_pump stuff to remove the armor
*/
enum unarmor_state_e {
@ -1291,7 +1305,7 @@ enum unarmor_state_e {
STA_bypass,
STA_wait_newline,
STA_wait_dash,
STA_first_dash,
STA_first_dash,
STA_compare_header,
STA_found_header_wait_newline,
STA_skip_header_lines,
@ -1330,12 +1344,12 @@ unarmor_pump_release (UnarmorPump x)
xfree (x);
}
/*
/*
* Get the next character from the ascii armor taken from the IOBUF
* created earlier by unarmor_pump_new().
* Return: c = Character
* 256 = ignore this value
* -1 = End of current armor
* -1 = End of current armor
* -2 = Premature EOF (not used)
* -3 = Invalid armor
*/
@ -1346,9 +1360,9 @@ unarmor_pump (UnarmorPump x, int c)
switch (x->state) {
case STA_init:
{
{
byte tmp[1];
tmp[0] = c;
tmp[0] = c;
if ( is_armored (tmp) )
x->state = c == '-'? STA_first_dash : STA_wait_newline;
else {
@ -1371,10 +1385,10 @@ unarmor_pump (UnarmorPump x, int c)
x->state = STA_compare_header;
case STA_compare_header:
if ( "-----BEGIN PGP SIGNATURE-----"[++x->pos] == c ) {
if ( x->pos == 28 )
if ( x->pos == 28 )
x->state = STA_found_header_wait_newline;
}
else
else
x->state = c == '\n'? STA_wait_dash : STA_wait_newline;
break;
case STA_found_header_wait_newline:
@ -1421,7 +1435,7 @@ unarmor_pump (UnarmorPump x, int c)
break;
}
}
switch(x->pos) {
case 0:
x->val = c << 2;
@ -1462,7 +1476,7 @@ unarmor_pump (UnarmorPump x, int c)
x->state = STA_ready; /* not sure whether this is correct */
break;
}
switch(x->pos) {
case 0:
x->val = c << 2;