diff --git a/SignalServiceKit/src/Loki/API/LokiAPITarget.swift b/SignalServiceKit/src/Loki/API/LokiAPITarget.swift index c3305638e..6320a1fe2 100644 --- a/SignalServiceKit/src/Loki/API/LokiAPITarget.swift +++ b/SignalServiceKit/src/Loki/API/LokiAPITarget.swift @@ -11,7 +11,6 @@ internal final class LokiAPITarget : NSObject, NSCoding { /// Only supported by snode targets. case getMessages = "retrieve" case sendMessage = "store" - case getStats = "get_stats" } internal struct KeySet { diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI+Encryption.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI+Encryption.swift index 8b626b0ad..7b4d2ced8 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI+Encryption.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI+Encryption.swift @@ -33,8 +33,8 @@ extension OnionRequestAPI { let snodeX25519PublicKey = Data(hex: hexEncodedSnodeX25519PublicKey) let ephemeralKeyPair = Curve25519.generateKeyPair() let ephemeralSharedSecret = try Curve25519.generateSharedSecret(fromPublicKey: snodeX25519PublicKey, privateKey: ephemeralKeyPair.privateKey) - let key = "LOKI" - let symmetricKey = try HMAC(key: key.bytes, variant: .sha256).authenticate(ephemeralSharedSecret.bytes) + let salt = "LOKI" + let symmetricKey = try HMAC(key: salt.bytes, variant: .sha256).authenticate(ephemeralSharedSecret.bytes) let ciphertext = try encrypt(plaintext, usingAESGCMWithSymmetricKey: Data(bytes: symmetricKey)) return (ciphertext, Data(bytes: symmetricKey), ephemeralKeyPair.publicKey) } diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift index afa4727e0..141308e22 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift @@ -4,9 +4,9 @@ import PromiseKit /// See the "Onion Requests" section of [The Session Whitepaper](https://arxiv.org/pdf/2002.04609.pdf) for more information. internal enum OnionRequestAPI { /// - Note: Must only be modified from `LokiAPI.workQueue`. - internal static var guardSnodes: Set = [] + private static var guardSnodes: Set = [] /// - Note: Must only be modified from `LokiAPI.workQueue`. - internal static var paths: Set = [] + private static var paths: Set = [] private static var snodePool: Set { let unreliableSnodes = Set(LokiAPI.failureCount.keys) @@ -111,7 +111,7 @@ internal enum OnionRequestAPI { return Set(guardSnodes.map { guardSnode in let result = [ guardSnode ] + (0..<(pathSize - 1)).map { _ in // randomElement() uses the system's default random generator, which is cryptographically secure - let pathSnode = unusedSnodes.randomElement()! // Safe because of the minSnodeCount check above + let pathSnode = unusedSnodes.randomElement()! // Safe because of the pathSnodeCount check above unusedSnodes.remove(pathSnode) // All used snodes should be unique return pathSnode }