Make peerInfo dynamic to add IV_CIPHERS

Fixes #193
This commit is contained in:
Davide De Rosa 2021-01-03 00:56:02 +01:00
parent 119d2f02e4
commit 7ea088e4a1
3 changed files with 16 additions and 3 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Added
- Handle `--data-ciphers` from OpenVPN 2.5
## 3.2.0 (2021-01-07)
### Changed

View File

@ -156,7 +156,11 @@ extension OpenVPN {
}
// peer info
raw.appendSized(Z(CoreConfiguration.OpenVPN.peerInfo, nullTerminated: true))
var extra: [String: String] = [:]
if let dataCiphers = options.dataCiphers {
extra["IV_CIPHERS"] = dataCiphers.map { $0.rawValue }.joined(separator: ":")
}
raw.appendSized(Z(CoreConfiguration.OpenVPN.peerInfo(extra: extra), nullTerminated: true))
if CoreConfiguration.logsSensitiveData {
log.debug("TLS.auth: Put plaintext (\(raw.count) bytes): \(raw.toHex())")

View File

@ -63,7 +63,7 @@ extension CoreConfiguration {
// MARK: Authentication
static let peerInfo: String = {
static func peerInfo(extra: [String: String]? = nil) -> String {
let platform: String
#if os(iOS)
platform = "ios"
@ -83,9 +83,12 @@ extension CoreConfiguration {
if LZOIsSupported() {
info.append("IV_LZO=1")
}
if let extra = extra {
info.append(contentsOf: extra.map { "\($0)=\($1)" })
}
info.append("")
return info.joined(separator: "\n")
}()
}
static let randomLength = 32