mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
* keyid.c (keyid_from_sk, keyid_from_pk, fingerprint_from_pk,
fingerprint_from_sk): Enforce the v3-is-only-RSA rule. Anything that isn't RSA gets a zero keyid and fingerprint.
This commit is contained in:
parent
4830eb7cae
commit
08967eb985
@ -1,5 +1,9 @@
|
|||||||
2003-12-09 David Shaw <dshaw@jabberwocky.com>
|
2003-12-09 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* keyid.c (keyid_from_sk, keyid_from_pk, fingerprint_from_pk,
|
||||||
|
fingerprint_from_sk): Enforce the v3-is-only-RSA rule. Anything
|
||||||
|
that isn't RSA gets a zero keyid and fingerprint.
|
||||||
|
|
||||||
* keyid.c (do_fingerprint_md): Properly handle hashing of keys
|
* keyid.c (do_fingerprint_md): Properly handle hashing of keys
|
||||||
that we don't know the structure of by using the opaque MPI.
|
that we don't know the structure of by using the opaque MPI.
|
||||||
(do_fingerprint_md_sk): We cannot calculate the fingerprint from a
|
(do_fingerprint_md_sk): We cannot calculate the fingerprint from a
|
||||||
|
41
g10/keyid.c
41
g10/keyid.c
@ -33,7 +33,6 @@
|
|||||||
#include "keydb.h"
|
#include "keydb.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
pubkey_letter( int algo )
|
pubkey_letter( int algo )
|
||||||
{
|
{
|
||||||
@ -149,9 +148,13 @@ keyid_from_sk( PKT_secret_key *sk, u32 *keyid )
|
|||||||
if( !keyid )
|
if( !keyid )
|
||||||
keyid = dummy_keyid;
|
keyid = dummy_keyid;
|
||||||
|
|
||||||
if( sk->version < 4 && is_RSA(sk->pubkey_algo) ) {
|
if( sk->version < 4 )
|
||||||
|
{
|
||||||
|
if( is_RSA(sk->pubkey_algo) )
|
||||||
lowbits = pubkey_get_npkey(sk->pubkey_algo) ?
|
lowbits = pubkey_get_npkey(sk->pubkey_algo) ?
|
||||||
mpi_get_keyid( sk->skey[0], keyid ) : 0; /* take n */
|
mpi_get_keyid( sk->skey[0], keyid ) : 0; /* take n */
|
||||||
|
else
|
||||||
|
keyid[0]=keyid[1]=lowbits=0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const byte *dp;
|
const byte *dp;
|
||||||
@ -191,12 +194,18 @@ keyid_from_pk( PKT_public_key *pk, u32 *keyid )
|
|||||||
keyid[1] = pk->keyid[1];
|
keyid[1] = pk->keyid[1];
|
||||||
lowbits = keyid[1];
|
lowbits = keyid[1];
|
||||||
}
|
}
|
||||||
else if( pk->version < 4 && is_RSA(pk->pubkey_algo) ) {
|
else if( pk->version < 4 )
|
||||||
|
{
|
||||||
|
if( is_RSA(pk->pubkey_algo) )
|
||||||
|
{
|
||||||
lowbits = pubkey_get_npkey(pk->pubkey_algo) ?
|
lowbits = pubkey_get_npkey(pk->pubkey_algo) ?
|
||||||
mpi_get_keyid( pk->pkey[0], keyid ) : 0 ; /* from n */
|
mpi_get_keyid( pk->pkey[0], keyid ) : 0 ; /* from n */
|
||||||
pk->keyid[0] = keyid[0];
|
pk->keyid[0] = keyid[0];
|
||||||
pk->keyid[1] = keyid[1];
|
pk->keyid[1] = keyid[1];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
pk->keyid[0]=pk->keyid[1]=keyid[0]=keyid[1]=lowbits=0;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
const byte *dp;
|
const byte *dp;
|
||||||
MD_HANDLE md;
|
MD_HANDLE md;
|
||||||
@ -452,7 +461,10 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len )
|
|||||||
size_t len;
|
size_t len;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
if( pk->version < 4 && is_RSA(pk->pubkey_algo) ) {
|
if( pk->version < 4 )
|
||||||
|
{
|
||||||
|
if( is_RSA(pk->pubkey_algo) )
|
||||||
|
{
|
||||||
/* RSA in version 3 packets is special */
|
/* RSA in version 3 packets is special */
|
||||||
MD_HANDLE md;
|
MD_HANDLE md;
|
||||||
|
|
||||||
@ -472,6 +484,14 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len )
|
|||||||
memcpy(array, md_read(md, DIGEST_ALGO_MD5), 16 );
|
memcpy(array, md_read(md, DIGEST_ALGO_MD5), 16 );
|
||||||
md_close(md);
|
md_close(md);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!array)
|
||||||
|
array=m_alloc(16);
|
||||||
|
len=16;
|
||||||
|
memset(array,0,16);
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
MD_HANDLE md;
|
MD_HANDLE md;
|
||||||
md = do_fingerprint_md(pk);
|
md = do_fingerprint_md(pk);
|
||||||
@ -498,7 +518,10 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len )
|
|||||||
size_t len;
|
size_t len;
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
if( sk->version < 4 && is_RSA(sk->pubkey_algo) ) {
|
if( sk->version < 4 )
|
||||||
|
{
|
||||||
|
if( is_RSA(sk->pubkey_algo) )
|
||||||
|
{
|
||||||
/* RSA in version 3 packets is special */
|
/* RSA in version 3 packets is special */
|
||||||
MD_HANDLE md;
|
MD_HANDLE md;
|
||||||
|
|
||||||
@ -518,6 +541,14 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len )
|
|||||||
memcpy(array, md_read(md, DIGEST_ALGO_MD5), 16 );
|
memcpy(array, md_read(md, DIGEST_ALGO_MD5), 16 );
|
||||||
md_close(md);
|
md_close(md);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!array)
|
||||||
|
array=m_alloc(16);
|
||||||
|
len=16;
|
||||||
|
memset(array,0,16);
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
MD_HANDLE md;
|
MD_HANDLE md;
|
||||||
md = do_fingerprint_md_sk(sk);
|
md = do_fingerprint_md_sk(sk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user