[vlc-devel] commit: Fix a few bugs in update pgp code. (Antoine Cellerier )

git version control git at videolan.org
Sun Sep 21 02:29:49 CEST 2008


vlc | branch: 0.9-bugfix | Antoine Cellerier <dionoea at videolan.org> | Sun Sep 21 02:18:21 2008 +0200| [f71123b58ca4072a090b0a22019c81270bbcde4d] | committer: Antoine Cellerier 

Fix a few bugs in update pgp code.

1/ pgp v4 signature checks of status files with more than 506 bytes would fail
2/ pgp v4 signature checks would fail (code dupication sucks).

This code is quite a mess. We shouldn't need to implement all this lowlevel stuff. I'll remove most of it and use pgpme instead.

For the time being, this means that upcomming releases should use v3 signatures for the downloaded files and shouldn't use status files of more than 506 bytes (or maybe shouldn't use v4 signatures for status files either)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f71123b58ca4072a090b0a22019c81270bbcde4d
---

 src/misc/update.c |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/misc/update.c b/src/misc/update.c
index 96a3948..51794e6 100644
--- a/src/misc/update.c
+++ b/src/misc/update.c
@@ -845,6 +845,16 @@ static uint8_t *hash_sha1_from_file( const char *psz_file,
         gcry_md_write( hd, p_sig->specific.v4.hashed_data_len, 2 );
         size_t i_len = scalar_number( p_sig->specific.v4.hashed_data_len, 2 );
         gcry_md_write( hd, p_sig->specific.v4.hashed_data, i_len );
+
+        gcry_md_putc( hd, 0x04 );
+        gcry_md_putc( hd, 0xFF );
+
+        i_len += 6; /* hashed data + 6 bytes header */
+
+        gcry_md_putc( hd, (i_len >> 24) & 0xff );
+        gcry_md_putc( hd, (i_len >> 16) & 0xff );
+        gcry_md_putc( hd, (i_len >> 8) & 0xff );
+        gcry_md_putc( hd, (i_len) & 0xff );
     }
     else
     {   /* RFC 4880 only tells about versions 3 and 4 */
@@ -978,9 +988,9 @@ static uint8_t *key_sign_hash( public_key_t *p_pkey )
 
     size_t i_len = strlen((char*)p_pkey->psz_username);
 
-    gcry_md_putc( hd, (i_len << 24) & 0xff );
-    gcry_md_putc( hd, (i_len << 16) & 0xff );
-    gcry_md_putc( hd, (i_len << 8) & 0xff );
+    gcry_md_putc( hd, (i_len >> 24) & 0xff );
+    gcry_md_putc( hd, (i_len >> 16) & 0xff );
+    gcry_md_putc( hd, (i_len >> 8) & 0xff );
     gcry_md_putc( hd, (i_len) & 0xff );
 
     gcry_md_write( hd, p_pkey->psz_username, i_len );
@@ -1000,14 +1010,14 @@ static uint8_t *key_sign_hash( public_key_t *p_pkey )
 
     i_hashed_data_len += 6; /* hashed data + 6 bytes header */
 
-    gcry_md_putc( hd, (i_hashed_data_len << 24) & 0xff);
-    gcry_md_putc( hd, (i_hashed_data_len << 16) &0xff );
-    gcry_md_putc( hd, (i_hashed_data_len << 8) & 0xff );
+    gcry_md_putc( hd, (i_hashed_data_len >> 24) & 0xff );
+    gcry_md_putc( hd, (i_hashed_data_len >> 16) & 0xff );
+    gcry_md_putc( hd, (i_hashed_data_len >> 8) & 0xff );
     gcry_md_putc( hd, (i_hashed_data_len) & 0xff );
 
     gcry_md_final( hd );
 
-    uint8_t *p_tmp = gcry_md_read( hd, GCRY_MD_SHA1);
+    uint8_t *p_tmp = gcry_md_read( hd, GCRY_MD_SHA1 );
 
     if( !p_tmp ||
         p_tmp[0] != p_pkey->sig.hash_verification[0] ||
@@ -1308,9 +1318,9 @@ static bool GetUpdateFile( update_t *p_update )
 
         i_len += 6; /* hashed data + 6 bytes header */
 
-        gcry_md_putc( hd, (i_len << 24) & 0xff);
-        gcry_md_putc( hd, (i_len << 16) &0xff );
-        gcry_md_putc( hd, (i_len << 8) & 0xff );
+        gcry_md_putc( hd, (i_len >> 24) & 0xff );
+        gcry_md_putc( hd, (i_len >> 16) & 0xff );
+        gcry_md_putc( hd, (i_len >> 8) & 0xff );
         gcry_md_putc( hd, (i_len) & 0xff );
     }
     else




More information about the vlc-devel mailing list