mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-01 14:13:22 +01:00
Update libsignal-client to 0.37.0
This commit is contained in:
committed by
Clark Chen
parent
6d9a66cc41
commit
036bd51298
@@ -51,47 +51,12 @@ public class SignalSealedSessionCipher {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Revert the change here to use the libsignal SealedSessionCipher when the API changes
|
||||
public byte[] multiRecipientEncrypt(SignalProtocolStore signalProtocolStore, List<SignalProtocolAddress> recipients, Map<SignalProtocolAddress, SessionRecord> sessionMap, UnidentifiedSenderMessageContent content)
|
||||
public byte[] multiRecipientEncrypt(List<SignalProtocolAddress> recipients, Map<SignalProtocolAddress, SessionRecord> sessionMap, UnidentifiedSenderMessageContent content)
|
||||
throws InvalidKeyException, UntrustedIdentityException, NoSessionException, InvalidRegistrationIdException
|
||||
{
|
||||
try (SignalSessionLock.Lock unused = lock.acquire()) {
|
||||
if (sessionMap == null) {
|
||||
return cipher.multiRecipientEncrypt(recipients, content);
|
||||
}
|
||||
List<SessionRecord> recipientSessions = recipients.stream().map(sessionMap::get).collect(Collectors.toList());
|
||||
if (recipientSessions.stream().anyMatch(Objects::isNull)) {
|
||||
throw new NoSessionException("Failed to find one or more sessions.");
|
||||
}
|
||||
// Unsafely access the native handles for the recipients and sessions,
|
||||
// because try-with-resources syntax doesn't support a List of resources.
|
||||
long[] recipientHandles = new long[recipients.size()];
|
||||
int i = 0;
|
||||
for (SignalProtocolAddress nextRecipient : recipients) {
|
||||
recipientHandles[i] = nextRecipient.unsafeNativeHandleWithoutGuard();
|
||||
i++;
|
||||
}
|
||||
|
||||
long[] recipientSessionHandles = new long[recipientSessions.size()];
|
||||
i = 0;
|
||||
for (SessionRecord nextSession : recipientSessions) {
|
||||
recipientSessionHandles[i] = nextSession.unsafeNativeHandleWithoutGuard();
|
||||
i++;
|
||||
}
|
||||
|
||||
try (NativeHandleGuard contentGuard = new NativeHandleGuard(content)) {
|
||||
byte[] result =
|
||||
Native.SealedSessionCipher_MultiRecipientEncrypt(
|
||||
recipientHandles,
|
||||
recipientSessionHandles,
|
||||
contentGuard.nativeHandle(),
|
||||
signalProtocolStore);
|
||||
// Manually keep the lists of recipients and sessions from being garbage collected
|
||||
// while we're using their native handles.
|
||||
Native.keepAlive(recipients);
|
||||
Native.keepAlive(recipientSessions);
|
||||
return result;
|
||||
}
|
||||
return cipher.multiRecipientEncrypt(recipients, recipientSessions, content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class SignalServiceCipher {
|
||||
contentHint.getType(),
|
||||
groupId);
|
||||
|
||||
return sessionCipher.multiRecipientEncrypt(signalProtocolStore, destinations, sessionMap, messageContent);
|
||||
return sessionCipher.multiRecipientEncrypt(destinations, sessionMap, messageContent);
|
||||
}
|
||||
|
||||
public OutgoingPushMessage encrypt(SignalProtocolAddress destination,
|
||||
|
||||
Reference in New Issue
Block a user