Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Fix malformed key generation message
Browse files Browse the repository at this point in the history
Make nullTerminated argument explicit, easier to debug.

Fixes #67
  • Loading branch information
keeshux committed Apr 13, 2019
1 parent 0a956f5 commit 322242d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Make `hostname` optional and pick `resolvedAddresses` if nil.

### Fixed

- Negotiation times out with SoftEther. [#67](https://github.com/keeshux/tunnelkit/issues/67)

## 1.6.1 (2019-04-07)

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions TunnelKit/Sources/Core/SessionProxy+Authenticator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension SessionProxy {
raw.append(random1)
raw.append(random2)

// opts
// opts (empty string)
raw.appendSized(Z(UInt8(0)))

// credentials
Expand All @@ -107,7 +107,7 @@ extension SessionProxy {
}

// peer info
raw.appendSized(Z(CoreConfiguration.peerInfo))
raw.appendSized(Z(CoreConfiguration.peerInfo, nullTerminated: true))

if CoreConfiguration.logsSensitiveData {
log.debug("TLS.auth: Put plaintext (\(raw.count) bytes): \(raw.toHex())")
Expand Down
2 changes: 1 addition & 1 deletion TunnelKit/Sources/Core/SessionProxy+EncryptionBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extension SessionProxy {
_ serverSessionId: Data?,
_ size: Int) throws -> ZeroingData {

let seed = Z(label)
let seed = Z(label, nullTerminated: false)
seed.append(clientSeed)
seed.append(serverSeed)
if let csi = clientSessionId {
Expand Down
2 changes: 1 addition & 1 deletion TunnelKit/Sources/Core/ZeroingData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ func Z(_ data: Data) -> ZeroingData {
// return ZeroingData(data: data, offset: offset, count: count)
//}

func Z(_ string: String, nullTerminated: Bool = false) -> ZeroingData {
func Z(_ string: String, nullTerminated: Bool) -> ZeroingData {
return ZeroingData(string: string, nullTerminated: nullTerminated)
}

0 comments on commit 322242d

Please sign in to comment.