[Winpt-commits] r313 - trunk/Gnupg
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun May 13 11:43:51 CEST 2007
Author: twoaday
Date: 2007-05-13 11:43:51 +0200 (Sun, 13 May 2007)
New Revision: 313
Modified:
trunk/Gnupg/parse-packet.c
Log:
Modified: trunk/Gnupg/parse-packet.c
===================================================================
--- trunk/Gnupg/parse-packet.c 2007-05-13 09:43:33 UTC (rev 312)
+++ trunk/Gnupg/parse-packet.c 2007-05-13 09:43:51 UTC (rev 313)
@@ -21,9 +21,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-
#include <stdio.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -105,6 +103,14 @@
return a;
}
+int
+set_packet_list_mode( int mode )
+{
+ int old = list_mode;
+ list_mode = mode;
+ mpi_print_mode = 0;
+ return old;
+}
static void
unknown_pubkey_warning( int algo )
@@ -117,48 +123,7 @@
}
}
-static const char *
-strtimestamp( unsigned long stamp )
-{
- static char buffer[11+5];
- struct tm *tp;
- time_t atime = stamp;
-
- if (atime < 0) {
- strcpy (buffer, "????" "-??" "-??");
- }
- else {
- tp = gmtime( &atime );
- sprintf(buffer,"%04d-%02d-%02d",
- 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday );
- }
- return buffer;
-}
-static const char *
-strtimevalue( unsigned long value )
-{
- static char buffer[30];
- unsigned int years, days, hours, minutes;
-
- value /= 60;
- minutes = value % 60;
- value /= 60;
- hours = value % 24;
- value /= 24;
- days = value % 365;
- value /= 365;
- years = value;
-
- sprintf(buffer,"%uy%ud%uh%um", years, days, hours, minutes );
- if( years )
- return buffer;
- if( days )
- return strchr( buffer, 'y' ) + 1;
- return strchr( buffer, 'd' ) + 1;
-}
-
-
static gpg_mpi_t
mpi_read( gpg_iobuf_t inp, size_t *ret_n, int flags )
{
@@ -735,7 +700,7 @@
/* with a some probability this is caused by a problem in the
* the uncompressing layer - in some error cases it just loops
* and spits out 0xff bytes. */
- /*printf ("%s: garbled packet detected\n", gpg_iobuf_where(inp));*/
+ printf ("%s: garbled packet detected\n", gpg_iobuf_where(inp) );
rc = G10ERR_INVALID_PACKET;
goto leave;
}
@@ -1078,177 +1043,6 @@
return rc;
}
-static void
-dump_sig_subpkt( int hashed, int type, int critical,
- const byte *buffer, size_t buflen, size_t length )
-{
- const char *p=NULL;
- int i;
-
- /* The CERT has warning out with explains how to use GNUPG to
- * detect the ARRs - we print our old message here when it is a faked
- * ARR and add an additional notice */
- if ( type == SIGSUBPKT_ARR && !hashed ) {
- printf("\tsubpkt %d len %u (additional recipient request)\n"
- "WARNING: PGP versions > 5.0 and < 6.5.8 will automagically "
- "encrypt to this key and thereby reveal the plaintext to "
- "the owner of this ARR key. Detailed info follows:\n",
- type, (unsigned)length );
- }
-
-
- printf("\t%s%ssubpkt %d len %u (", /*)*/
- critical ? "critical ":"",
- hashed ? "hashed ":"", type, (unsigned)length );
- buffer++;
- length--;
- if( length > buflen ) {
- printf("too short: buffer is only %u)\n", (unsigned)buflen );
- return;
- }
- switch( type ) {
- case SIGSUBPKT_SIG_CREATED:
- if( length >= 4 )
- printf("sig created %s", strtimestamp( buffer_to_u32(buffer) ) );
- break;
- case SIGSUBPKT_SIG_EXPIRE:
- if( length >= 4 )
- printf("sig expires after %s",
- strtimevalue( buffer_to_u32(buffer) ) );
- break;
- case SIGSUBPKT_EXPORTABLE:
- if( length )
- printf("%sexportable", *buffer? "":"not ");
- break;
- case SIGSUBPKT_TRUST:
- if(length!=2)
- p="[invalid trust signature]";
- else
- printf("trust signature of level %d, amount %d",buffer[0],buffer[1]);
- break;
- case SIGSUBPKT_REGEXP:
- if(!length)
- p="[invalid regexp]";
- else
- printf("regular expression: \"%s\"",buffer);
- break;
- case SIGSUBPKT_REVOCABLE:
- if( length )
- printf("%srevocable", *buffer? "":"not ");
- break;
- case SIGSUBPKT_KEY_EXPIRE:
- if( length >= 4 )
- printf("key expires after %s",
- strtimevalue( buffer_to_u32(buffer) ) );
- break;
- case SIGSUBPKT_PREF_SYM:
- fputs("pref-sym-algos:", stdout );
- for( i=0; i < length; i++ )
- printf(" %d", buffer[i] );
- break;
- case SIGSUBPKT_REV_KEY:
- fputs("revocation key: ", stdout );
- if( length < 22 )
- p = "[too short]";
- else {
- printf("c=%02x a=%d f=", buffer[0], buffer[1] );
- for( i=2; i < length; i++ )
- printf("%02X", buffer[i] );
- }
- break;
- case SIGSUBPKT_ISSUER:
- if( length >= 8 )
- printf("issuer key ID %08lX%08lX",
- (ulong)buffer_to_u32(buffer),
- (ulong)buffer_to_u32(buffer+4) );
- break;
- case SIGSUBPKT_NOTATION:
- {
- fputs("notation: ", stdout );
- if( length < 8 )
- p = "[too short]";
- else if( !(*buffer & 0x80) )
- p = "[not human readable]";
- else {
- const byte *s = buffer;
- size_t n1, n2;
-
- n1 = (s[4] << 8) | s[5];
- n2 = (s[6] << 8) | s[7];
- s += 8;
- if( 8+n1+n2 != length )
- p = "[error]";
- else {
- print_string( stdout, s, n1, ')' );
- putc( '=', stdout );
- print_string( stdout, s+n1, n2, ')' );
- }
- }
- }
- break;
- case SIGSUBPKT_PREF_HASH:
- fputs("pref-hash-algos:", stdout );
- for( i=0; i < length; i++ )
- printf(" %d", buffer[i] );
- break;
- case SIGSUBPKT_PREF_COMPR:
- fputs("pref-zip-algos:", stdout );
- for( i=0; i < length; i++ )
- printf(" %d", buffer[i] );
- break;
- case SIGSUBPKT_KS_FLAGS:
- fputs("key server preferences:",stdout);
- for(i=0;i<length;i++)
- printf(" %02X", buffer[i]);
- break;
- case SIGSUBPKT_PREF_KS:
- p = "preferred key server";
- break;
- case SIGSUBPKT_PRIMARY_UID:
- p = "primary user ID";
- break;
- case SIGSUBPKT_POLICY:
- fputs("policy: ", stdout );
- print_string( stdout, buffer, length, ')' );
- break;
- case SIGSUBPKT_KEY_FLAGS:
- fputs ( "key flags:", stdout );
- for( i=0; i < length; i++ )
- printf(" %02X", buffer[i] );
- break;
- case SIGSUBPKT_SIGNERS_UID:
- p = "signer's user ID";
- break;
- case SIGSUBPKT_REVOC_REASON:
- if( length ) {
- printf("revocation reason 0x%02x (", *buffer );
- print_string( stdout, buffer+1, length-1, ')' );
- p = ")";
- }
- break;
- case SIGSUBPKT_ARR:
- fputs("Big Brother's key (ignored): ", stdout );
- if( length < 22 )
- p = "[too short]";
- else {
- printf("c=%02x a=%d f=", buffer[0], buffer[1] );
- for( i=2; i < length; i++ )
- printf("%02X", buffer[i] );
- }
- break;
- case SIGSUBPKT_FEATURES:
- fputs ( "features:", stdout );
- for( i=0; i < length; i++ )
- printf(" %02x", buffer[i] );
- break;
- case SIGSUBPKT_PRIV_VERIFY_CACHE:
- p = "obsolete verification cache";
- break;
- default: p = "?"; break;
- }
-
- printf("%s)\n", p? p: "");
-}
/****************
* Returns: >= 0 offset into buffer
@@ -1414,9 +1208,6 @@
}
}
}
- else if( reqtype < 0 ) /* list packets */
- dump_sig_subpkt( reqtype == SIGSUBPKT_LIST_HASHED,
- type, *critical, buffer, buflen, n );
else if( type == reqtype ) { /* found */
buffer++;
n--;
@@ -2683,7 +2474,7 @@
u32
-gpg_keyid_from_sk( PKT_secret_key * sk, byte *fprint )
+gpg_keyid_from_sk (PKT_secret_key * sk, byte *fprint)
{
PKT_public_key pk;
int npkey = pubkey_get_npkey( sk->pubkey_algo );
More information about the Winpt-commits
mailing list