Skip to content

Commit

Permalink
Always try all omemo prekeys when importing a new bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Dec 5, 2024
1 parent 6757587 commit c07ec82
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Monal/Classes/MLOMEMO.m
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,9 @@ -(void) processOMEMOKeys:(MLXMLNode*) item forJid:(NSString*) jid andRid:(NSNumb
{
// select random preKey and try to import it
const uint32_t preKeyIdxToTest = arc4random_uniform((uint32_t)preKeyIds.count);
// load preKey
NSNumber* preKeyId = preKeyIds[preKeyIdxToTest];
[preKeyIds removeObjectAtIndex:preKeyIdxToTest];
processedKeys++;
if(preKeyId == nil)
continue;;
NSData* key = [bundle findFirst:@"prekeys/preKeyPublic<preKeyId=%@>#|base64", preKeyId];
Expand Down Expand Up @@ -810,7 +811,7 @@ -(void) processOMEMOKeys:(MLXMLNode*) item forJid:(NSString*) jid andRid:(NSNumb
[self notifyKnownDevicesUpdated:jid];

return;
} while(++processedKeys < preKeyIds.count);
} while(preKeyIds.count > 0);
DDLogError(@"Could not import a single prekey from bundle for rid %@ (tried %lu keys)", rid, processedKeys);
//TODO: should we blacklist this device id?
@synchronized(self.state.queuedSessionRepairs) {
Expand Down

0 comments on commit c07ec82

Please sign in to comment.