feat(core): Add URL encryption for GDPR compliancy. Check for null termination when decrypting. Disable url encryption for anonymous user.

This commit is contained in:
smizrahi
2024-02-12 13:47:41 +01:00
parent 5197b9bd0b
commit 42511d666f
2 changed files with 14 additions and 5 deletions
+12 -3
View File
@@ -500,8 +500,17 @@ static const NSString *kAES256GCMError = @"kAES256GCMError";
if (p_len > 0) {
// Convert to NSString
outputData = [NSData dataWithBytes: plaintext length: p_len];
if (outputData) {
value = [NSString stringWithUTF8String: [outputData bytes]];
if (outputData && [outputData length] > 0) {
char lastByte;
[outputData getBytes:&lastByte range:NSMakeRange([outputData length]-1, 1)];
if (lastByte == 0x0) {
// string is null terminated
value = [NSString stringWithUTF8String: [outputData bytes]];
} else {
// string is not null terminated
value = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];
[value autorelease];
}
} else {
*ex = [NSException exceptionWithName: kAES128ECError reason:@"Empty data" userInfo: nil];
}
@@ -659,7 +668,7 @@ static const NSString *kAES256GCMError = @"kAES256GCMError";
EVP_CIPHER_CTX_free(ctx);
if (rv > 0) {
if (outputData) {
if (outputData && [outputData length] > 0) {
char lastByte;
[outputData getBytes:&lastByte range:NSMakeRange([outputData length]-1, 1)];
if (lastByte == 0x0) {
+2 -2
View File
@@ -1302,7 +1302,7 @@ static const NSString *kEncryptedUserNamePrefix = @"uenc";
NSString *tmp, *cacheKey;
SOGoCache *cache;
if (![[SOGoSystemDefaults sharedSystemDefaults] isURLEncryptionEnabled])
if (![[SOGoSystemDefaults sharedSystemDefaults] isURLEncryptionEnabled] || [username isEqualToString: @"anonymous"])
return username;
cache = [SOGoCache sharedCache];
@@ -1337,7 +1337,7 @@ static const NSString *kEncryptedUserNamePrefix = @"uenc";
NSString *tmp, *cacheKey;
SOGoCache *cache;
if (![[SOGoSystemDefaults sharedSystemDefaults] isURLEncryptionEnabled])
if (![[SOGoSystemDefaults sharedSystemDefaults] isURLEncryptionEnabled] || [username isEqualToString: @"anonymous"])
return username;
cache = [SOGoCache sharedCache];