mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-17 07:33:57 +00:00
fix(crypto): add protections for decryption
This commit is contained in:
@@ -1186,8 +1186,8 @@ Defaults to `NO` when unset.
|
||||
(with read-only access). Note that if set to `NO`, autocompletion will
|
||||
not work for entries in this source and thus, freebusy lookups.
|
||||
|
||||
!displayName (optional)
|
||||
!If set as an address book, the human identification name of the LDAP
|
||||
|displayName (optional)
|
||||
|If set as an address book, the human identification name of the LDAP
|
||||
repository
|
||||
|
||||
|listRequiresDot (optional)
|
||||
|
||||
@@ -511,7 +511,6 @@ static const NSString *kAES256GCMError = @"kAES256GCMError";
|
||||
|
||||
// Clean up
|
||||
free(plaintext);
|
||||
|
||||
return value;
|
||||
|
||||
#else
|
||||
@@ -653,7 +652,7 @@ static const NSString *kAES256GCMError = @"kAES256GCMError";
|
||||
|
||||
int status = 0;
|
||||
EVP_DecryptUpdate(ctx, plaintext, &p_len, [data bytes], [data length]);
|
||||
outputData = [NSData dataWithBytes: plaintext length: p_len];
|
||||
outputData = [NSData dataWithBytes: (char *)plaintext length: p_len];
|
||||
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, GMC_TAG_LEN, (void *)[tagData bytes]);
|
||||
rv = EVP_DecryptFinal_ex(ctx, plaintext + p_len, &f_len);
|
||||
p_len += f_len;
|
||||
@@ -672,7 +671,14 @@ static const NSString *kAES256GCMError = @"kAES256GCMError";
|
||||
// Clean up
|
||||
free(plaintext);
|
||||
|
||||
if(value)
|
||||
return value;
|
||||
else
|
||||
{
|
||||
*ex = [NSException exceptionWithName: kAES128ECError reason:@"Could decrypt but value is null" userInfo: nil];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
*ex = [NSException exceptionWithName:kAES256GCMError reason:@"Missing OpenSSL framework" userInfo: nil];
|
||||
|
||||
@@ -1079,6 +1079,8 @@ static const NSString *kEncryptedUserNamePrefix = @"uenc";
|
||||
if(exception)
|
||||
[self errorWithFormat:@"Can't decrypt the password for auxiliary account %@: %@",
|
||||
[account objectForKey: @"name"], [exception reason]];
|
||||
else if(!password)
|
||||
[self errorWithFormat:@"No exception but decyrpted password is empty for account %@",[account objectForKey: @"name"]];
|
||||
else
|
||||
[account setObject: password forKey: @"password"];
|
||||
}
|
||||
|
||||
@@ -1624,6 +1624,8 @@ static NSArray *reminderValues = nil;
|
||||
[oldAccount objectForKey: @"name"], [exception reason]];
|
||||
decryptedPassword = @"";
|
||||
}
|
||||
else if(!decryptedPassword)
|
||||
[self errorWithFormat:@"No exception but decrypted password is empty for account %@",[oldAccount objectForKey: @"name"]];
|
||||
else
|
||||
password = decryptedPassword;
|
||||
NS_HANDLER
|
||||
|
||||
Reference in New Issue
Block a user