aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2004-08-19 10:12:54 +0000
committerWerner Koch <[email protected]>2004-08-19 10:12:54 +0000
commitbf256b9696db43125c2fb2f24210a3561893bdb4 (patch)
tree34a15f502f71586c83fd93ba4b812c119daafa85
parent2004-08-18 Marcus Brinkmann <[email protected]> (diff)
downloadgnupg-bf256b9696db43125c2fb2f24210a3561893bdb4.tar.gz
gnupg-bf256b9696db43125c2fb2f24210a3561893bdb4.zip
(encode_session_key): Changed the zero random byte
substituting code to actually do clever things. Thanks to Matthias Urlichs for noting the implementation problem.
Diffstat (limited to '')
-rw-r--r--g10/ChangeLog6
-rw-r--r--g10/seskey.c7
2 files changed, 11 insertions, 2 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 8ee93128c..5653bf650 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,9 @@
+2004-08-19 Werner Koch <[email protected]>
+
+ * 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 <[email protected]>
* passphrase.c (agent_get_passphrase): Fix detection of gpg-agent
diff --git a/g10/seskey.c b/g10/seskey.c
index 664508be0..cc58154ad 100644
--- a/g10/seskey.c
+++ b/g10/seskey.c
@@ -117,11 +117,14 @@ encode_session_key( DEK *dek, unsigned nbits )
k++;
if( !k )
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);
- for(j=0; j < i && k ; j++ )
+ for(j=0; j < i && k ;) {
if( !p[j] )
p[j] = pp[--k];
+ if (p[j])
+ j++;
+ }
m_free(pp);
}
memcpy( frame+n, p, i );