1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-21 14:47:03 +01:00

(encode_session_key): Changed the zero random byte

substituting code to actually do clever things.  Thanks to
Matthias Urlichs for noting the implementation problem.
This commit is contained in:
Werner Koch 2004-08-19 10:12:54 +00:00
parent 75ac082a76
commit bf256b9696
2 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2004-08-19 Werner Koch <wk@g10code.de>
* seskey.c (encode_session_key): Changed the zero random byte
substituting code to actually do clever things. Thanks to
Matthias Urlichs for noting the implementation problem.
2004-08-18 Marcus Brinkmann <marcus@g10code.de> 2004-08-18 Marcus Brinkmann <marcus@g10code.de>
* passphrase.c (agent_get_passphrase): Fix detection of gpg-agent * passphrase.c (agent_get_passphrase): Fix detection of gpg-agent

View File

@ -117,11 +117,14 @@ encode_session_key( DEK *dek, unsigned nbits )
k++; k++;
if( !k ) if( !k )
break; /* okay: no zero bytes */ break; /* okay: no zero bytes */
k += k/128; /* better get some more */ k += k/128 + 3; /* better get some more */
pp = get_random_bits( k*8, 1, 1); pp = get_random_bits( k*8, 1, 1);
for(j=0; j < i && k ; j++ ) for(j=0; j < i && k ;) {
if( !p[j] ) if( !p[j] )
p[j] = pp[--k]; p[j] = pp[--k];
if (p[j])
j++;
}
m_free(pp); m_free(pp);
} }
memcpy( frame+n, p, i ); memcpy( frame+n, p, i );