summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTimo Schulz <twoaday@gnutls.org>2002-12-01 10:07:10 +0000
committerTimo Schulz <twoaday@gnutls.org>2002-12-01 10:07:10 +0000
commitc023e839ef1afd83696ea72101c713c2c27a5469 (patch)
tree715703dcaf70401810d72f8f32602c9d4e53678d /tests
parent02c345f1e326161ea133e7e22249af03e1c2f2d9 (diff)
downloadgnutls-c023e839ef1afd83696ea72101c713c2c27a5469.tar.gz
Some enhancements for the OpenPGP test program.
Diffstat (limited to 'tests')
-rw-r--r--tests/openpgp_test.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/openpgp_test.c b/tests/openpgp_test.c
index b61a6a7348..7e6c646f31 100644
--- a/tests/openpgp_test.c
+++ b/tests/openpgp_test.c
@@ -25,6 +25,17 @@ get_pkalgo( int algo )
return NULL;
}
+static const char *
+get_pktime( long timestamp )
+{
+ static char buf[128];
+ struct tm * tb;
+
+ tb = localtime( &timestamp );
+ sprintf( buf, "%04d-%02d-%02d", tb->tm_year+1900, tb->tm_mon+1, tb->tm_mday );
+ return buf;
+}
+
int
get_pubkey( gnutls_datum *pk, const gnutls_datum *kr, unsigned long kid )
{
@@ -74,7 +85,7 @@ main( int argc, char ** argv )
printf( "pk-algorithm %s %d bits\n", get_pkalgo( rc ), nbits );
rc = gnutls_openpgp_extract_key_creation_time( &dat );
- printf( "creation time %lu\n", rc );
+ printf( "creation time %s\n", get_pktime( rc ) );
rc = gnutls_openpgp_extract_key_expiration_time( &dat );
printf( "expiration time %lu\n", rc );
@@ -82,8 +93,8 @@ main( int argc, char ** argv )
printf( "key fingerprint: " );
rc = gnutls_openpgp_fingerprint( &dat, fpr, &fprlen );
assert( rc == 0 );
- for( i = 0; i < fprlen; i++ )
- printf( "%02X ", fpr[i] );
+ for( i = 0; i < fprlen/2; i++ )
+ printf( "%02X%02X ", fpr[2*i], fpr[2*i+1] );
printf( "\n" );
printf( "key id: " );
@@ -126,8 +137,8 @@ main( int argc, char ** argv )
printf( "key fingerprint: " );
gnutls_openpgp_fingerprint( &pk, fpr, &fprlen );
- for( i = 0; i < fprlen; i++ )
- printf( "%02X ", fpr[i] );
+ for( i = 0; i < fprlen/2; i++ )
+ printf( "%02X%02X ", fpr[2*i], fpr[2*i+1] );
printf( "\n" );
gnutls_free_datum( &pk );