[OpenPGP:SDK svn] r345 - openpgpsdk/trunk/src

Subversion ben at algroup.co.uk
Mon Jan 30 16:33:42 GMT 2006


Author: ben
Date: 2006-01-30 16:33:42 +0000 (Mon, 30 Jan 2006)
New Revision: 345

Modified:
   openpgpsdk/trunk/src/packet-parse.c
Log:
Actually, the checksum is encrypted, too.


Modified: openpgpsdk/trunk/src/packet-parse.c
===================================================================
--- openpgpsdk/trunk/src/packet-parse.c	2006-01-30 16:25:04 UTC (rev 344)
+++ openpgpsdk/trunk/src/packet-parse.c	2006-01-30 16:33:42 UTC (rev 345)
@@ -1935,14 +1935,10 @@
 	decrypt.set_iv(&decrypt,C.secret_key.iv);
 	decrypt.set_key(&decrypt,key);
 
-	/* We need to prevent the decrypter from reading the trailing
-	   checksum */
-	region->length-=checksum_length;
 	ops_reader_push_decrypt(parse_info,&decrypt,region);
 
 	/* Since all known encryption for PGP doesn't compress, we can
-	   limit to the same length as the current region (for now),
-	   allowing for the trailing checksum.
+	   limit to the same length as the current region (for now).
 	*/
 
 	ops_init_subregion(&encregion,NULL);
@@ -1976,31 +1972,33 @@
 	assert(0);
 	}
 
-    if(saved_region)
+    if(ret)
 	{
+	// XXX: check the checksum
+
+	if(C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED_AND_HASHED)
+	    {
+	    if(!limited_read(C.secret_key.checkhash,20,region,parse_info))
+		return 0;
+	    }
+	else
+	    {
+	    if(!limited_read_scalar(&C.secret_key.checksum,2,region,
+				    parse_info))
+		return 0;
+	    }
+	}
+
+    if(C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED
+       || C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED_AND_HASHED)
+	{
 	ops_reader_pop_decrypt(parse_info);
 	assert(region->length_read == region->length);
-	region=saved_region;
-	/* put back checksum data */
-	region->length+=checksum_length;
 	}
 
     if(!ret)
 	return 0;
 
-    // XXX: check the checksum
-
-    if(C.secret_key.s2k_usage == OPS_S2KU_ENCRYPTED_AND_HASHED)
-	{
-	if(!limited_read(C.secret_key.checkhash,20,region,parse_info))
-	    return 0;
-	}
-    else
-	{
-	if(!limited_read_scalar(&C.secret_key.checksum,2,region,parse_info))
-	    return 0;
-	}
-
     CBP(parse_info,OPS_PTAG_CT_SECRET_KEY,&content);
 
     return 1;



More information about the OpenPGPsdk-svn mailing list