From 23ec698784a8c6bd14d001e738205f2931478677 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 12 Jan 2010 10:44:55 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20reading=20encrypted=20SPF=20files?= =?UTF-8?q?=20on=20the=2064bit=20SP=20version=20(for=20now)=20-=20make=20u?= =?UTF-8?q?sage=20of=20UInt32=20instead=20of=20NSUInteger=20for=20checking?= =?UTF-8?q?=20whether=20decryption=20was=20successful=20and=20for=20retrie?= =?UTF-8?q?ving=20the=20correct=20data=20size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: it should be possible to change it to NSUInteger by applying the correct pointer arithmetics --- Source/SPDataAdditions.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/SPDataAdditions.m b/Source/SPDataAdditions.m index 3f45a5fa..d50ee631 100644 --- a/Source/SPDataAdditions.m +++ b/Source/SPDataAdditions.m @@ -148,6 +148,7 @@ static char base64encodingTable[64] = { - (NSData*)dataDecryptedWithPassword:(NSString*)password { + // Create the key from the password hash unsigned char passwordDigest[20]; SHA1((const unsigned char *)[password UTF8String], strlen([password UTF8String]), passwordDigest); @@ -169,15 +170,15 @@ static char base64encodingTable[64] = { AES_cbc_encrypt([self bytes] + 16, decryptedBytes, encryptedLength, &aesKey, iv, AES_DECRYPT); // If decryption was successful, these blocks will be zeroed - if ( *((NSUInteger*)decryptedBytes + ((encryptedLength / 4) - 4)) || - *((NSUInteger*)decryptedBytes + ((encryptedLength / 4) - 3)) || - *((NSUInteger*)decryptedBytes + ((encryptedLength / 4) - 2)) ) + if ( *((UInt32*)decryptedBytes + ((encryptedLength / 4) - 4)) || + *((UInt32*)decryptedBytes + ((encryptedLength / 4) - 3)) || + *((UInt32*)decryptedBytes + ((encryptedLength / 4) - 2)) ) { return nil; } // Get the size of the data from the last 32-bit chunk - NSInteger bigIntDataLength = *((NSUInteger*)decryptedBytes + ((encryptedLength / 4) - 1)); + NSInteger bigIntDataLength = *((UInt32*)decryptedBytes + ((encryptedLength / 4) - 1)); NSInteger dataLength = NSSwapBigIntToHost(bigIntDataLength); return [NSData dataWithBytesNoCopy:decryptedBytes length:dataLength]; -- cgit v1.2.3