diff --git a/Sources/ShadowSwift/DarkStar.swift b/Sources/ShadowSwift/DarkStar.swift index 3c5a6a6..c500da1 100644 --- a/Sources/ShadowSwift/DarkStar.swift +++ b/Sources/ShadowSwift/DarkStar.swift @@ -163,7 +163,7 @@ public struct DarkStar - static public func handleTheirEphemeralPublicKey(connection: Connection, bloomFilter: BloomFilter) -> P256.KeyAgreement.PublicKey? + static public func handleTheirEphemeralPublicKey(connection: Connection, bloomFilter: BloomFilter?) -> P256.KeyAgreement.PublicKey? { // Receive their ephemeral key guard let theirEphemeralPublicKeyData = connection.read(size: P256KeySize) else @@ -171,10 +171,17 @@ public struct DarkStar return nil } - // TODO: See if theirEphemeralPublicKeyData is in the BloomFilter, return nil if it is. - - // TODO: If it's not in a BloomFilter, add it to the BloomFilter and Save the BloomFilter - + if let serverBloomFilter = bloomFilter // Server + { + // TODO: See if theirEphemeralPublicKeyData is in the BloomFilter, return nil if it is. + + // TODO: If it's not in a BloomFilter, add it to the BloomFilter and Save the BloomFilter + } + else // Client + { + + } + guard let theirEphemeralPublicKey = try? P256.KeyAgreement.PublicKey(compactRepresentation: theirEphemeralPublicKeyData) else { return nil diff --git a/Sources/ShadowSwift/DarkStarClient.swift b/Sources/ShadowSwift/DarkStarClient.swift index f4f2e32..51d5128 100644 --- a/Sources/ShadowSwift/DarkStarClient.swift +++ b/Sources/ShadowSwift/DarkStarClient.swift @@ -176,7 +176,8 @@ public class DarkStarClient guard DarkStarClient.handleClientConfirmationCode(connection: connection, theirPublicKey: serverPersistentPublicKey, myPrivateKey: clientEphemeralPrivateKey, endpoint: endpoint, serverPersistentPublicKey: serverPersistentPublicKey, clientEphemeralPublicKey: clientEphemeralPublicKey) else {return nil} // Receive server ephemeral key - guard let serverEphemeralPublicKey = DarkStar.handleTheirEphemeralPublicKey(connection: connection) else {return nil} + guard let serverEphemeralPublicKey = DarkStar.handleTheirEphemeralPublicKey(connection: connection, bloomFilter: nil) else + {return nil} // Create shared key guard let clientToServerSharedKey = DarkStarClient.createClientToServerSharedKey(clientEphemeralPrivateKey: clientEphemeralPrivateKey, serverEphemeralPublicKey: serverEphemeralPublicKey, serverPersistentPublicKey: serverPersistentPublicKey, serverEndpoint: endpoint) else {return nil} diff --git a/Sources/ShadowSwift/DarkStarServer.swift b/Sources/ShadowSwift/DarkStarServer.swift index b570c27..4917798 100644 --- a/Sources/ShadowSwift/DarkStarServer.swift +++ b/Sources/ShadowSwift/DarkStarServer.swift @@ -154,7 +154,7 @@ public class DarkStarServer let serverPersistentPublicKey = serverPersistentPrivateKey.publicKey // Receive client ephemeral key - guard let clientEphemeralPublicKey = DarkStar.handleTheirEphemeralPublicKey(connection: connection) else + guard let clientEphemeralPublicKey = DarkStar.handleTheirEphemeralPublicKey(connection: connection, bloomFilter: bloomFilter) else { let transport = TransmissionToTransportConnection({return connection}) diff --git a/Sources/ShadowSwift/DarkStarServerConnection.swift b/Sources/ShadowSwift/DarkStarServerConnection.swift index 5e61451..5680b4b 100644 --- a/Sources/ShadowSwift/DarkStarServerConnection.swift +++ b/Sources/ShadowSwift/DarkStarServerConnection.swift @@ -110,7 +110,7 @@ open class DarkStarServerConnection: Transport.Connection return nil } - guard let server = DarkStarServer(serverPersistentPrivateKey: serverPersistentPrivateKey, endpoint: endpoint, connection: connection) else + guard let server = DarkStarServer(serverPersistentPrivateKey: serverPersistentPrivateKey, endpoint: endpoint, connection: connection, bloomFilter: bloomFilter) else { logger.error("Failed to init DarkStarServer") return nil