mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
2002-06-05 Timo Schulz <ts@winpt.org>
* mainproc.c (symkey_decrypt_sesskey): New. (proc_symkey_enc): Support for encrypted session keys.
This commit is contained in:
parent
098a5229d1
commit
3b6a0c36a2
@ -1,3 +1,8 @@
|
|||||||
|
2002-06-05 Timo Schulz <ts@winpt.org>
|
||||||
|
|
||||||
|
* mainproc.c (symkey_decrypt_sesskey): New.
|
||||||
|
(proc_symkey_enc): Support for encrypted session keys.
|
||||||
|
|
||||||
2002-06-04 David Shaw <dshaw@jabberwocky.com>
|
2002-06-04 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* sign.c (hash_for, sign_file): When encrypting and signing at the
|
* sign.c (hash_for, sign_file): When encrypting and signing at the
|
||||||
|
@ -237,6 +237,31 @@ add_signature( CTX c, PACKET *pkt )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
symkey_decrypt_sesskey( DEK *dek, byte *sesskey, size_t slen )
|
||||||
|
{
|
||||||
|
CIPHER_HANDLE hd;
|
||||||
|
|
||||||
|
if ( slen > 33 ) {
|
||||||
|
log_error( "weird size for an encrypted session key" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hd = cipher_open( dek->algo, CIPHER_MODE_CFB, 1 );
|
||||||
|
cipher_setkey( hd, dek->key, dek->keylen );
|
||||||
|
cipher_setiv( hd, NULL, 0 );
|
||||||
|
cipher_decrypt( hd, sesskey, sesskey, slen );
|
||||||
|
cipher_close( hd );
|
||||||
|
/* check first byte (the cipher algo) */
|
||||||
|
if ( sesskey[0] > 10 ) {
|
||||||
|
log_error( "invalid symkey algorithm detected\n" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* now we replace the dek components with the real session key
|
||||||
|
to decrypt the contents of the sequencing packet. */
|
||||||
|
dek->keylen = cipher_get_keylen( sesskey[0] );
|
||||||
|
dek->algo = sesskey[0];
|
||||||
|
memcpy( dek->key, sesskey + 1, dek->keylen );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
proc_symkey_enc( CTX c, PACKET *pkt )
|
proc_symkey_enc( CTX c, PACKET *pkt )
|
||||||
@ -264,6 +289,8 @@ proc_symkey_enc( CTX c, PACKET *pkt )
|
|||||||
c->dek = passphrase_to_dek( NULL, 0, algo, &enc->s2k, 0, NULL );
|
c->dek = passphrase_to_dek( NULL, 0, algo, &enc->s2k, 0, NULL );
|
||||||
if (c->dek)
|
if (c->dek)
|
||||||
c->dek->algo_info_printed = 1;
|
c->dek->algo_info_printed = 1;
|
||||||
|
if ( c->dek && enc->seskeylen )
|
||||||
|
symkey_decrypt_sesskey( c->dek, enc->seskey, enc->seskeylen );
|
||||||
}
|
}
|
||||||
leave:
|
leave:
|
||||||
free_packet(pkt);
|
free_packet(pkt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user