--- a/Sources/NetworkAndStorage/CryptoUtils.m
+++ b/Sources/NetworkAndStorage/CryptoUtils.m
@@ -472,22 +472,31 @@ static CryptoUtils* _cryptoManager = nil
}
// Storage version 4 is a lot simpler. We simply generate the initial crypto and hmac keys from the
// sync key. Which is possibly derived from the passphrase. We then download the crypto/keys from
// the server and keep those around.
case 4:
{
- // If this key is a 26 character new style sync key then decode it
+ // We accept two types of passwords for v4. Hyphenated or plain.
NSData* passphraseData = nil;
-
+
if ([passphrase length] == 26) {
passphraseData = [passphrase userfriendlyBase32Decoding];
+ } else if ([passphrase isMatchedByRegex: @"^(?i)[A-Z2-9]{1}-[A-Z2-9]{5}-[A-Z2-9]{5}-[A-Z2-9]{5}-[A-Z2-9]{5}-[A-Z2-9]{5}$"]) {
+ passphrase = [passphrase stringByReplacingOccurrencesOfString: @"-" withString: @""];
+ passphraseData = [passphrase userfriendlyBase32Decoding];
+ } else {
+ [self release];
+ NSException *e = [NSException exceptionWithName:PASSPHRASE_EXCEPTION_STRING
+ reason:NSLocalizedString(@"Incorrect Secret Phrase", @"incorrect secret phrase") userInfo:nil];
+ @throw e;
+ return nil;
}
// Load the keys
NSDictionary* keys = [[self downloadKeysWithUsername: accountName passphraseData: passphraseData] retain];
if (keys == nil) {
[self release];
NSException *e = [NSException exceptionWithName:PASSPHRASE_EXCEPTION_STRING