aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-12 10:44:55 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-12 10:44:55 +0000
commit23ec698784a8c6bd14d001e738205f2931478677 (patch)
tree20752f8a949b832e54873264a18b0394ffcc24bf
parent48b01fd15b6d8a0d59e77775108e06945b09a712 (diff)
downloadsequelpro-23ec698784a8c6bd14d001e738205f2931478677.tar.gz
sequelpro-23ec698784a8c6bd14d001e738205f2931478677.tar.bz2
sequelpro-23ec698784a8c6bd14d001e738205f2931478677.zip
• fixed reading encrypted SPF files on the 64bit SP version (for now)
- make usage of UInt32 instead of NSUInteger for checking whether decryption was successful and for retrieving the correct data size TODO: it should be possible to change it to NSUInteger by applying the correct pointer arithmetics
-rw-r--r--Source/SPDataAdditions.m9
1 files 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];