Remove dead code and placeholders

- Remove NoisePostQuantum.swift entirely (placeholder with no implementation)
- Remove Double Ratchet placeholder code from NoiseChannelKeyRotation.swift
- Remove NoisePostQuantumTests that tested mock implementations
- Handle TODO for version negotiation rejection (now properly disconnects)
- Remove legacy comment about removed message type 0x02
- Keep deprecated ownerID field as it's still used for compatibility

This cleanup removes ~400 lines of placeholder code that was not
being used and unlikely to be implemented in the near future.
This commit is contained in:
jack
2025-07-22 11:20:07 +02:00
parent 9fef19a595
commit ce6e90701c
5 changed files with 10 additions and 396 deletions
-76
View File
@@ -307,80 +307,4 @@ class NoiseKeyRotationTests: XCTestCase {
XCTAssertTrue(decrypted, "Failed to decrypt with any valid key")
}
}
// MARK: - Post-Quantum Framework Tests
class NoisePostQuantumTests: XCTestCase {
func testHybridKeyGeneration() throws {
let (publicKey, privateKey) = try HybridNoiseKeyExchange.generateKeyPair(algorithm: .classicalOnly)
XCTAssertNotNil(publicKey.classical)
XCTAssertNil(publicKey.postQuantum) // No PQ component yet
XCTAssertEqual(publicKey.serialized.count, 32) // Just Curve25519
XCTAssertNotNil(privateKey.classical)
XCTAssertNil(privateKey.postQuantum)
}
func testHybridKeyAgreement() throws {
// Generate two keypairs
let (alicePub, alicePriv) = try HybridNoiseKeyExchange.generateKeyPair(algorithm: .classicalOnly)
let (bobPub, bobPriv) = try HybridNoiseKeyExchange.generateKeyPair(algorithm: .classicalOnly)
// Perform key agreement
let aliceShared = try HybridNoiseKeyExchange.performKeyAgreement(
localPrivate: alicePriv,
remotePublic: bobPub,
algorithm: .classicalOnly
)
let bobShared = try HybridNoiseKeyExchange.performKeyAgreement(
localPrivate: bobPriv,
remotePublic: alicePub,
algorithm: .classicalOnly
)
// Shared secrets should match
XCTAssertEqual(
aliceShared.combinedSecret().withUnsafeBytes { Data($0) },
bobShared.combinedSecret().withUnsafeBytes { Data($0) }
)
}
func testMigrationConfig() {
let config = NoiseProtocolMigration.getMigrationConfig()
XCTAssertEqual(config.currentPhase, .classicalOnly)
XCTAssertEqual(config.preferredAlgorithm, .classicalOnly)
XCTAssertTrue(config.acceptedAlgorithms.contains(.classicalOnly))
XCTAssertNil(config.migrationDeadline)
}
#if DEBUG
func testMockPostQuantum() throws {
// Test mock PQ implementation
let (publicKey, privateKey) = try MockPostQuantumKeyExchange.generateKeyPair()
XCTAssertEqual(publicKey.count, MockPostQuantumKeyExchange.publicKeySize)
XCTAssertEqual(privateKey.count, 32) // Mock uses smaller private key
let (sharedSecret, ciphertext) = try MockPostQuantumKeyExchange.encapsulate(
remotePublicKey: publicKey
)
XCTAssertEqual(ciphertext.count, MockPostQuantumKeyExchange.ciphertextSize)
XCTAssertEqual(sharedSecret.count, MockPostQuantumKeyExchange.sharedSecretSize)
let decapsulatedSecret = try MockPostQuantumKeyExchange.decapsulate(
ciphertext: ciphertext,
privateKey: privateKey
)
// In real implementation, these would match
// Mock just returns deterministic values
XCTAssertEqual(decapsulatedSecret.count, 32)
}
#endif
}