From bc03bd000f22965997715c664a58e9b9bcfbdf41 Mon Sep 17 00:00:00 2001 From: consuelita Date: Mon, 13 Dec 2021 13:59:27 -0600 Subject: [PATCH] Linux Dependencies --- Package.swift | 50 +++++++++++++++++++++++++++++- Sources/ShadowSwift/DarkStar.swift | 9 +++++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 89f6ebb..5a6852e 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,7 @@ import PackageDescription +#if os(macOS) let package = Package( name: "ShadowSwift", platforms: [ @@ -17,7 +18,7 @@ let package = Package( .package(url: "https://github.com/OperatorFoundation/Chord.git", from: "0.0.15"), .package(url: "https://github.com/OperatorFoundation/Datable.git", from: "3.1.2"), .package(url: "https://github.com/apple/swift-log.git", from: "1.4.2"), - .package(url: "https://github.com/OperatorFoundation/SwiftHexTools.git", from: "1.2.4"), + .package(url: "https://github.com/OperatorFoundation/SwiftHexTools.git", from: "1.2.5"), .package(url: "https://github.com/OperatorFoundation/Transmission.git", from: "1.0.4"), .package(url: "https://github.com/OperatorFoundation/Transport.git", from: "2.3.5"), .package(url: "https://github.com/apple/swift-crypto", from: "2.0.0") @@ -46,3 +47,50 @@ let package = Package( swiftLanguageVersions: [.v5] ) +#else +let package = Package( + name: "ShadowSwift", + platforms: [ + .macOS(.v10_15), + .iOS(.v14)], + products: [ + .library( + name: "ShadowSwift", + targets: ["ShadowSwift"]), + ], + dependencies: [ + .package(url: "https://github.com/OperatorFoundation/Chord.git", from: "0.0.15"), + .package(url: "https://github.com/OperatorFoundation/Datable.git", from: "3.1.2"), + .package(url: "https://github.com/OperatorFoundation/NetworkLinux.git", from: "0.4.5"), + .package(url: "https://github.com/apple/swift-log.git", from: "1.4.2"), + .package(url: "https://github.com/OperatorFoundation/SwiftHexTools.git", from: "1.2.5"), + .package(url: "https://github.com/OperatorFoundation/Transmission.git", from: "1.0.4"), + .package(url: "https://github.com/OperatorFoundation/Transport.git", from: "2.3.5"), + .package(url: "https://github.com/apple/swift-crypto", from: "2.0.0") + ], + targets: [ + .target( + name: "ShadowSwift", + dependencies: [ + "Chord", + "Datable", + "NetworkLinux", + "Transmission", + "Transport", + .product(name: "Logging", package: "swift-log"), + .product(name: "Crypto", package: "swift-crypto") + ]), + .testTarget( + name: "ShadowSwiftTests", + dependencies: [ + "Datable", + "ShadowSwift", + "SwiftHexTools", + "Chord", + .product(name: "Logging", package: "swift-log")], + exclude: ["Info.plist"]), + ], + + swiftLanguageVersions: [.v5] +) +#endif diff --git a/Sources/ShadowSwift/DarkStar.swift b/Sources/ShadowSwift/DarkStar.swift index 0e631ad..bd5637f 100644 --- a/Sources/ShadowSwift/DarkStar.swift +++ b/Sources/ShadowSwift/DarkStar.swift @@ -8,10 +8,17 @@ import Foundation import Crypto import Transmission -import Network import Datable import SwiftHexTools +#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) +import CryptoKit +import Network +#else +import Crypto +import NetworkLinux +#endif + let P256KeySize = 32 // compact format let ConfirmationSize = 32 let NonceSize = 32