diff --git a/NearbyShare/Connection/InboundNearbyConnection.swift b/NearbyShare/Connection/InboundNearbyConnection.swift index c2f945b..6cc9ffa 100644 --- a/NearbyShare/Connection/InboundNearbyConnection.swift +++ b/NearbyShare/Connection/InboundNearbyConnection.swift @@ -387,11 +387,10 @@ class InboundNearbyConnection: NearbyConnection { private func processPairedKeyEncryptionFrame(_ frame: Sharing_Nearby_Frame) throws { - let pkeFrame = frame.v1.pairedKeyEncryption - - log("[InboundNearbyConnection \(self.id)] Processing paired key encryption frame with secretIDHash: \(pkeFrame.secretIDHash.hex)") - log("Signed data: " + pkeFrame.signedData.hex) + guard frame.hasV1, frame.v1.hasPairedKeyEncryption else { throw NearbyError.requiredFieldMissing("shareNearbyFrame.v1.pairedKeyEncryption") } + + let pkeFrame = frame.v1.pairedKeyEncryption // Check if we can accept the connection automatically if !pkeFrame.secretIDHash.isEmpty, diff --git a/NearbyShare/Connection/OutboundNearbyConnection.swift b/NearbyShare/Connection/OutboundNearbyConnection.swift index c0cf157..f135337 100644 --- a/NearbyShare/Connection/OutboundNearbyConnection.swift +++ b/NearbyShare/Connection/OutboundNearbyConnection.swift @@ -304,7 +304,13 @@ class OutboundNearbyConnection: NearbyConnection { pairedEncryption.v1.pairedKeyResult.status = .success } - + else { + + log("[OutboundNearbyConnection \(self.id)] No private key available, cannot send signing certificate!") + + pairedEncryption.v1.pairedKeyEncryption.secretIDHash = Data.randomData(length: 6) + pairedEncryption.v1.pairedKeyEncryption.signedData = Data.randomData(length: 72) + } if let qrKey = qrCodePrivateKey, let authKey = authKey { let signature = qrKey.sign(msg: authKey.data())