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

Commit

Permalink
Merge pull request #16 from keeshux/add-more-crypto-algorithms
Browse files Browse the repository at this point in the history
Add more crypto algorithms
  • Loading branch information
keeshux authored Sep 6, 2018
2 parents 3c3efd9 + 1fbfe5b commit a54c767
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions TunnelKit/Sources/Core/SessionProxy+Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,73 @@ import Foundation
extension SessionProxy {

/// The available encryption algorithms.
public enum Cipher: String, Codable {
public enum Cipher: String, Codable, CustomStringConvertible {

// WARNING: must match OpenSSL algorithm names

/// AES encryption with 128-bit key size and CBC.
case aes128cbc = "AES-128-CBC"

/// AES encryption with 192-bit key size and CBC.
case aes192cbc = "AES-192-CBC"

/// AES encryption with 256-bit key size and CBC.
case aes256cbc = "AES-256-CBC"

/// AES encryption with 128-bit key size and GCM.
case aes128gcm = "AES-128-GCM"

/// AES encryption with 192-bit key size and GCM.
case aes192gcm = "AES-192-GCM"

/// AES encryption with 256-bit key size and GCM.
case aes256gcm = "AES-256-GCM"

/// Digest should be ignored when this is `true`.
public var embedsDigest: Bool {
return rawValue.hasSuffix("-GCM")
}

/// Returns a generic name for this cipher.
public var genericName: String {
return rawValue.hasSuffix("-GCM") ? "AES-GCM" : "AES-CBC"
}

/// :nodoc:
public var description: String {
return rawValue
}
}

/// The available message digest algorithms.
public enum Digest: String, Codable {
public enum Digest: String, Codable, CustomStringConvertible {

// WARNING: must match OpenSSL algorithm names

/// SHA1 message digest.
case sha1 = "SHA1"

/// SHA224 message digest.
case sha224 = "SHA224"

/// SHA256 message digest.
case sha256 = "SHA256"

/// SHA256 message digest.
case sha384 = "SHA384"

/// SHA256 message digest.
case sha512 = "SHA512"

/// Returns a generic name for this digest.
public var genericName: String {
return "HMAC"
}

/// :nodoc:
public var description: String {
return "\(genericName)-\(rawValue)"
}
}

/// The way to create a `SessionProxy.Configuration` object for a `SessionProxy`.
Expand Down

0 comments on commit a54c767

Please sign in to comment.