1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

See ChangeLog: Fri Mar 24 11:25:45 CET 2000 Werner Koch

This commit is contained in:
Werner Koch 2000-03-24 10:19:50 +00:00
parent 14a2e006bc
commit da129a5124
9 changed files with 205 additions and 17 deletions

View file

@ -1,3 +1,11 @@
Fri Mar 24 11:25:45 CET 2000 Werner Koch <wk@openit.de>
* gpg.c (print_mds): Add arg keys as a kludge to print hmacs
(main): New option --print-hmac.
* trustdb.c (verify_own_keys): Do not print warning about unprotected
key when in quiet mode.
Mon Mar 13 19:22:46 CET 2000 Werner Koch <wk@openit.de>
* build-paket.c (do_user_id): Save offset where name has been stored.

View file

@ -1,5 +1,7 @@
# Some notes used by the maintainers
print-hmac
# test function to print a HMAC
store
# simply packs the input data into a rfc1991 packet format

View file

@ -89,6 +89,7 @@ enum cmd_and_opt_values { aNull = 0,
aGenRevoke,
aPrimegen,
aPrintMD,
aPrintHMAC,
aPrintMDs,
aCheckTrustDB,
aUpdateTrustDB,
@ -226,6 +227,7 @@ static ARGPARSE_OPTS opts[] = {
{ aEnArmor, "enarmor", 256, N_("En-Armor a file or stdin") },
{ aEnArmor, "enarmour", 256, "@" },
{ aPrintMD, "print-md" , 256, N_("|algo [files]|print message digests")},
{ aPrintHMAC, "print-hmac" , 256, "@"},
{ aPrimegen, "gen-prime" , 256, "@" },
{ aGenRandom, "gen-random" , 256, "@" },
@ -354,7 +356,7 @@ static char *build_list( const char *text, const char * (*mapf)(int),
static void set_cmd( enum cmd_and_opt_values *ret_cmd,
enum cmd_and_opt_values new_cmd );
static void print_hex( byte *p, size_t n );
static void print_mds( const char *fname, int algo );
static void print_mds( const char *fname, int algo, const char *key );
static void add_notation_data( const char *string );
static int check_policy_url( const char *s );
@ -739,6 +741,7 @@ main( int argc, char **argv )
case aPrimegen: set_cmd( &cmd, aPrimegen); break;
case aGenRandom: set_cmd( &cmd, aGenRandom); break;
case aPrintMD: set_cmd( &cmd, aPrintMD); break;
case aPrintHMAC: set_cmd( &cmd, aPrintHMAC); break;
case aPrintMDs: set_cmd( &cmd, aPrintMDs); break;
case aListTrustDB: set_cmd( &cmd, aListTrustDB); break;
case aCheckTrustDB: set_cmd( &cmd, aCheckTrustDB); break;
@ -1074,6 +1077,7 @@ main( int argc, char **argv )
switch( cmd ) {
case aPrimegen:
case aPrintMD:
case aPrintHMAC:
case aPrintMDs:
case aGenRandom:
case aDeArmor:
@ -1387,10 +1391,34 @@ main( int argc, char **argv )
else {
argc--; argv++;
if( !argc )
print_mds(NULL, algo);
print_mds(NULL, algo, NULL);
else {
for(; argc; argc--, argv++ )
print_mds(*argv, algo);
print_mds(*argv, algo, NULL);
}
}
}
break;
case aPrintHMAC:
if( argc < 2 )
wrong_args("--print-hmac hash-algo key [files]");
{
int all_algos = (**argv=='*' && !(*argv)[1]);
int algo = all_algos? 0 : gcry_md_map_name(*argv);
if( !algo && !all_algos )
log_error(_("invalid hash algorithm `%s'\n"), *argv );
else {
const char *key;
argc--; argv++;
key = *argv;
argc--; argv++;
if( !argc )
print_mds(NULL, algo, key );
else {
for(; argc; argc--, argv++ )
print_mds(*argv, algo, key );
}
}
}
@ -1398,10 +1426,10 @@ main( int argc, char **argv )
case aPrintMDs: /* old option */
if( !argc )
print_mds(NULL,0);
print_mds(NULL,0,NULL);
else {
for(; argc; argc--, argv++ )
print_mds(*argv,0);
print_mds(*argv,0,NULL);
}
break;
@ -1554,7 +1582,7 @@ print_hex( byte *p, size_t n )
}
static void
print_mds( const char *fname, int algo )
print_mds( const char *fname, int algo, const char *key )
{
FILE *fp;
char buf[1024];
@ -1578,15 +1606,18 @@ print_mds( const char *fname, int algo )
return;
}
md = gcry_md_open( 0, 0 );
md = gcry_md_open( 0, key? GCRY_MD_FLAG_HMAC : 0 );
if( algo )
gcry_md_enable( md, algo );
else {
/* Fixme: this does not work with hmac */
gcry_md_enable( md, GCRY_MD_MD5 );
gcry_md_enable( md, GCRY_MD_SHA1 );
gcry_md_enable( md, GCRY_MD_RMD160 );
have_tiger = !gcry_md_enable( md, GCRY_MD_TIGER );
}
if( key )
gcry_md_setkey( md, key, strlen(key) );
while( (n=fread( buf, 1, DIM(buf), fp )) )
gcry_md_write( md, buf, n );

View file

@ -90,7 +90,7 @@ The standard KBX Blob looks like this:
maybe we put a sigture here later.
b16 MD5 checksum (useful for KS syncronsiation)
b16 MD5 checksum (useful for KS syncronisation)
*
*/
@ -540,3 +540,61 @@ kbx_release_blob ( KBXBLOB blob )
gcry_free( blob );
}
static ulong
get32( const byte *buffer )
{
ulong a;
a = *buffer << 24;
a |= buffer[1] << 16;
a |= buffer[2] << 8;
a |= buffer[3];
return a;
}
static ulong
get16( const byte *buffer )
{
ulong a;
a = *buffer << 8;
a |= buffer[0];
return a;
}
int
kbx_dump_blob ( FILE *fp, const byte* buffer, size_t length )
{
#if 0
ulong n;
ulong keyblock_off, keyblock_len;
if( length < 40 ) {
fprintf( fp, "blob too short\n");
return -1;
}
n = get32( buffer );
if( n > length ) {
fprintf( fp, "blob larger than length - output truncated\n");
}
else
length = n; /* ignore the rest */
fprintf( fp, "Length: %lu\n", n );
fprintf( fp, "Type: %d\n", buffer[4] ),
fprintf( fp, "Version: %d\n", buffer[5] ),
if( buffer[4] != 2 ) {
fprintf( fp, "can't dump this blob type\n" );
return 0;
}
n = get16( buffer + 6 );
fprintf( fp, "Blob-Flags: %04lX\n", n );
keyblock_off = get32( buffer + 8 );
keyblock_len = get32( buffer + 12 );
fprintf( fp, "Keyblock-Offset: %lu\n", keyblock_off );
fprintf( fp, "Keyblock-Length: %lu\n", keyblock_len );
#endif
}

View file

@ -20,7 +20,7 @@
/****************
* We will change the whole system to use only KBX. This file here
* will implements the methods needed to operate on plain KBXfiles.
* will implement the methods needed to operate on plain KBXfiles.
* Most stuff from getkey and ringedit will be replaced by stuff here.
* To make things even mor easier we will only allow one updateable kbxfile
* and optionally some read-only files.