Skip to content

Commit

Permalink
removed prints
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoSax committed Oct 28, 2021
1 parent 8e0fe99 commit be7f8da
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 38 deletions.
5 changes: 0 additions & 5 deletions Sources/ShadowSwift/DarkStar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public struct DarkStar
guard let serverIdentifier = DarkStar.makeServerIdentifier(endpoint) else {return nil}
let serverEphemeralPublicKeyData = serverEphemeralPublicKey.compactRepresentation!
let clientEphemeralPublicKeyData = clientEphemeralPublicKey.compactRepresentation!

print("SCC1: \(symmetricKeyToData(key: clientSharedKey).hex)")
print("SCC2: \(serverIdentifier.hex)")
print("SCC3: \(serverEphemeralPublicKeyData.hex)")
print("SCC4: \(clientEphemeralPublicKeyData.hex)")

var hmac = HMAC<SHA256>(key: clientSharedKey)
hmac.update(data: serverIdentifier)
Expand Down
5 changes: 0 additions & 5 deletions Sources/ShadowSwift/DarkStarCipher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ class DarkStarCipher
let sealedBox = try AES.GCM.seal(plaintext, using: self.key, nonce: nonce)
cipherText = sealedBox.ciphertext
tag = sealedBox.tag
print("encrypt Key: \(DarkStar.symmetricKeyToData(key: self.key).hex)")
print("encrypt nonce: \(Data(nonce).hex)")
print("encrypt plaintext: \(plaintext.hex)")
print("encrypt cipherText: \(cipherText.hex)")
print("encrypt tag: \(tag.hex)")
}
catch let encryptError
{
Expand Down
3 changes: 0 additions & 3 deletions Sources/ShadowSwift/DarkStarClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public class DarkStarClient
{
guard let data = DarkStar.generateClientConfirmationCode(connection: connection, theirPublicKey: theirPublicKey, myPrivateKey: myPrivateKey, endpoint: endpoint, serverPersistentPublicKey: serverPersistentPublicKey, clientEphemeralPublicKey: clientEphemeralPublicKey) else {return false}

print(data.hex)

return connection.write(data: data)
}

Expand Down Expand Up @@ -63,7 +61,6 @@ public class DarkStarClient
let hashed = hash.finalize()

let hashedData = Data(hashed)
print("shared key: \(hashedData.hex)")
return SymmetricKey(data: hashedData)
}

Expand Down
27 changes: 2 additions & 25 deletions Sources/ShadowSwift/DarkStarServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class DarkStarServer
static public func handleServerConfirmationCode(connection: Connection, sharedKey: SymmetricKey, endpoint: NWEndpoint, serverEphemeralPublicKey: P256.KeyAgreement.PublicKey, clientEphemeralPublicKey: P256.KeyAgreement.PublicKey) -> Bool
{
guard let data = DarkStar.generateServerConfirmationCode(clientSharedKey: sharedKey, endpoint: endpoint, serverEphemeralPublicKey: serverEphemeralPublicKey, clientEphemeralPublicKey: clientEphemeralPublicKey) else {return false}
print("server confirmation code: \(data.hex)")
return connection.write(data: data)
}

Expand All @@ -29,36 +28,19 @@ public class DarkStarServer

guard let code = generateClientConfirmationCode(connection: connection, theirPublicKey: theirPublicKey, myPrivateKey: myPrivateKey, endpoint: endpoint, serverPersistentPublicKey: serverPersistentPublicKey, clientEphemeralPublicKey: clientEphemeralPublicKey) else {return false}

print("server copy confirmation code: \(code.hex)")
print("client copy confirmation code: \(data!.hex)")


return data == code
}

static public func generateClientConfirmationCode(connection: Connection, theirPublicKey: P256.KeyAgreement.PublicKey, myPrivateKey: P256.KeyAgreement.PrivateKey, endpoint: NWEndpoint, serverPersistentPublicKey: P256.KeyAgreement.PublicKey, clientEphemeralPublicKey: P256.KeyAgreement.PublicKey) -> Data?
{
print(serverPersistentPublicKey.compactRepresentation!.hex)
print(clientEphemeralPublicKey.compactRepresentation!.hex)
print(theirPublicKey)


guard let ecdh = try? myPrivateKey.sharedSecretFromKeyAgreement(with: theirPublicKey) else {return nil}
let ecdhData = DarkStar.sharedSecretToData(secret: ecdh)

print("(client confirmation) ecdhData: \(ecdhData.hex)")

guard let serverIdentifier = DarkStar.makeServerIdentifier(endpoint) else {return nil}

print("(client confirmation) serverIdentifier: \(serverIdentifier.hex)")


let serverPersistentPublicKeyData = serverPersistentPublicKey.compactRepresentation!

print("(client confirmation) SPPubKey: \(serverPersistentPublicKeyData.hex)")


let clientEphemeralPublicKeyData = clientEphemeralPublicKey.compactRepresentation!

print("(client confirmation) CEPubKey: \(clientEphemeralPublicKeyData.hex)")

var hash = SHA256()
hash.update(data: ecdhData)
Expand Down Expand Up @@ -88,11 +70,6 @@ public class DarkStarServer
let serverEphemeralPublicKeyData = serverEphemeralPublicKey.compactRepresentation!

guard let serverIdentifier = DarkStar.makeServerIdentifier(serverEndpoint) else {return nil}

print("ecdh1: \(ephemeralECDHData.hex)")
print("ecdh2: \(persistentECDHData.hex)")
print("SEPub: \(serverEphemeralPublicKeyData.hex)")
print("ServerIdentifier: \(serverIdentifier)")

var hash = SHA256()
hash.update(data: ephemeralECDHData)
Expand Down

0 comments on commit be7f8da

Please sign in to comment.