Debug
This commit is contained in:
parent
3ec93bb51c
commit
ce86d9a196
|
@ -72,17 +72,17 @@ public enum MessageReceiver {
|
|||
case .closedGroupCiphertext:
|
||||
guard let hexEncodedGroupPublicKey = envelope.source, SNMessagingKitConfiguration.shared.storage.isClosedGroup(hexEncodedGroupPublicKey) else { throw Error.invalidGroupPublicKey }
|
||||
do {
|
||||
var keyPairs = Storage.shared.getClosedGroupEncryptionKeyPairs(for: hexEncodedGroupPublicKey)
|
||||
guard !keyPairs.isEmpty else { throw Error.noGroupKeyPair }
|
||||
var encryptionKeyPairs = Storage.shared.getClosedGroupEncryptionKeyPairs(for: hexEncodedGroupPublicKey)
|
||||
guard !encryptionKeyPairs.isEmpty else { throw Error.noGroupKeyPair }
|
||||
// Loop through all known group key pairs in reverse order (i.e. try the latest key pair first (which'll more than
|
||||
// likely be the one we want) but try older ones in case that didn't work)
|
||||
var keyPair = keyPairs.removeLast()
|
||||
var encryptionKeyPair = encryptionKeyPairs.removeLast()
|
||||
func decrypt() throws {
|
||||
do {
|
||||
(plaintext, sender) = try decryptWithSessionProtocol(ciphertext: ciphertext, using: keyPair)
|
||||
(plaintext, sender) = try decryptWithSessionProtocol(ciphertext: ciphertext, using: encryptionKeyPair)
|
||||
} catch {
|
||||
if !keyPairs.isEmpty {
|
||||
keyPair = keyPairs.removeLast()
|
||||
if !encryptionKeyPairs.isEmpty {
|
||||
encryptionKeyPair = encryptionKeyPairs.removeLast()
|
||||
try decrypt()
|
||||
} else {
|
||||
throw error
|
||||
|
|
|
@ -175,7 +175,14 @@ public final class MessageSender : NSObject {
|
|||
do {
|
||||
switch destination {
|
||||
case .contact(let publicKey): ciphertext = try encryptWithSessionProtocol(plaintext, for: publicKey)
|
||||
case .closedGroup(let groupPublicKey): ciphertext = try encryptWithSessionProtocol(plaintext, for: groupPublicKey)
|
||||
case .closedGroup(let groupPublicKey):
|
||||
|
||||
/*
|
||||
ciphertext = try encryptWithSessionProtocol(plaintext, for: groupPublicKey)
|
||||
*/
|
||||
|
||||
guard let encryptionKeyPair = Storage.shared.getLatestClosedGroupEncryptionKeyPair(for: groupPublicKey) else { throw Error.noKeyPair }
|
||||
ciphertext = try encryptWithSessionProtocol(plaintext, for: encryptionKeyPair.hexEncodedPublicKey)
|
||||
case .openGroup(_, _): preconditionFailure()
|
||||
}
|
||||
} catch {
|
||||
|
|
Loading…
Reference in New Issue