Skip to content

Commit

Permalink
Merge pull request #39 from vijaysingh-axway/MOD-2533
Browse files Browse the repository at this point in the history
fix(ios): db migration issue fixed
  • Loading branch information
lokeshchdhry committed Sep 30, 2019
2 parents baf9b87 + b8356ae commit 7e71998
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ios/Classes/AppceleratorEncrypteddatabaseDBProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ -(BOOL)needCipherMigrate:(NSString*)name_
NSFileManager *fm = [NSFileManager defaultManager];
NSString *versionFile = [[dbPath stringByAppendingPathComponent:name_] stringByAppendingPathExtension:@"version"];
BOOL versionExists = [fm fileExistsAtPath:versionFile];
NSString *currentVersion = @"2.0.4";
NSString *currentVersion = @"2.0.7";
BOOL migrate = YES;

if (versionExists) {
Expand Down
28 changes: 23 additions & 5 deletions ios/Classes/PlausibleDatabase/EncPLSqliteDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,36 @@ - (BOOL) openAndMigrate: (NSError **) error {
return NO;
}
char *errMsg;
//disable hmac cipher for backwards compatibility
err = sqlite3_exec(_sqlite, [@"PRAGMA cipher_use_hmac = OFF;" UTF8String], NULL, NULL, &errMsg);

//prepare existing database for migration
err = sqlite3_exec(_sqlite, [@"PRAGMA cipher_page_size = 1024;" UTF8String], NULL, NULL, &errMsg);
if (err != SQLITE_OK) {
NSLog([@"[ERROR] " stringByAppendingString:[NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]]);
[self populateError: error
withErrorCode: EncPLDatabaseErrorCipherMigrateFailed
description: NSLocalizedString(@"Cipher migrate: failed to disable hmac cipher.", @"")
description: NSLocalizedString(@"Cipher migrate: failed to prepare database for migration.", @"")
queryString: nil];
return NO;
}
//prepare existing database for migration
err = sqlite3_exec(_sqlite, [@"PRAGMA kdf_iter = 4000;" UTF8String], NULL, NULL, &errMsg);
err = sqlite3_exec(_sqlite, [@"PRAGMA kdf_iter = 64000;" UTF8String], NULL, NULL, &errMsg);
if (err != SQLITE_OK) {
NSLog([@"[ERROR] " stringByAppendingString:[NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]]);
[self populateError: error
withErrorCode: EncPLDatabaseErrorCipherMigrateFailed
description: NSLocalizedString(@"Cipher migrate: failed to prepare database for migration.", @"")
queryString: nil];
return NO;
}
err = sqlite3_exec(_sqlite, [@"PRAGMA cipher_hmac_algorithm = HMAC_SHA1;" UTF8String], NULL, NULL, &errMsg);
if (err != SQLITE_OK) {
NSLog([@"[ERROR] " stringByAppendingString:[NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]]);
[self populateError: error
withErrorCode: EncPLDatabaseErrorCipherMigrateFailed
description: NSLocalizedString(@"Cipher migrate: failed to prepare database for migration.", @"")
queryString: nil];
return NO;
}
err = sqlite3_exec(_sqlite, [@"PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA1;" UTF8String], NULL, NULL, &errMsg);
if (err != SQLITE_OK) {
NSLog([@"[ERROR] " stringByAppendingString:[NSString stringWithCString:errMsg encoding:NSUTF8StringEncoding]]);
[self populateError: error
Expand Down
2 changes: 1 addition & 1 deletion ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.0.6
version: 2.0.7
apiversion: 2
architectures: armv7 arm64 i386 x86_64
description: Provides transparent, secure 256-bit AES encryption of SQLite database files.
Expand Down

0 comments on commit 7e71998

Please sign in to comment.