diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f52778e8..5ec53b0b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ jobs: id: set-up-homebrew uses: Homebrew/actions/setup-homebrew@main - name: Install dependencies - run: brew install swift-sh mockolo + run: brew install mockolo - name: Setup config and TSL files run: | export RESOURCES_DIRECTORY="Modules/ConfigLib/Sources/ConfigLib/Resources" @@ -73,12 +73,12 @@ jobs: if [ -f "$TSL_FILES_DIRECTORY/eu-lotl.xml" ]; then echo "Getting TSL (local LOTL)" - python3 scripts/TSLXMLDownloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False" + python3 scripts/tsl_xml_downloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False" echo "Finished downloading TSL" else echo "Getting TSL (remote LOTL)" - python3 scripts/TSLXMLDownloader.py --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False" + python3 scripts/tsl_xml_downloader.py --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False" echo "Finished downloading TSL" fi @@ -100,10 +100,8 @@ jobs: echo APP_VERSION=$(xcodebuild -project ${{ github.workspace }}/RIADigiDoc.xcodeproj -showBuildSettings | grep MARKETING_VERSION | tr -d 'MARKETING_VERSION =') >> $GITHUB_ENV - name: Fetch default configuration run: | - echo "Cleaning swift-sh cache" - swift-sh --clean-cache echo "Fetching default configuration" - swift-sh SetupConfiguration/Sources/main.swift + python3 scripts/setup_configuration.py - name: Run tests run: | cd ${{ github.workspace }} @@ -112,6 +110,7 @@ jobs: xcodebuild test \ -project RIADigiDoc.xcodeproj \ + -skipPackagePluginValidation \ -scheme AllTests \ -destination 'platform=iOS Simulator,name=iPhone 17' \ -resultBundlePath TestResults.xcresult \ @@ -142,6 +141,7 @@ jobs: xcodebuild clean build \ -project RIADigiDoc.xcodeproj \ + -skipPackagePluginValidation \ -scheme RIADigiDoc \ -destination 'platform=iOS Simulator,name=iPhone 17' \ -derivedDataPath "${{ github.workspace }}/build" \ diff --git a/.swiftlint.yml b/.swiftlint.yml index f1d0d4da..636be18e 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -2,7 +2,6 @@ excluded: - RIADigiDocTests/Mocks/*/*.swift - Modules/**/Mocks/*/*.swift - Extensions/**/Mocks/*/*.swift - - SetupConfiguration/**/*.swift - build - SourcePackages - .build diff --git a/Extensions/FileImportShareExtension/UI/ShareViewController.swift b/Extensions/FileImportShareExtension/UI/ShareViewController.swift index 49d8919a..8dafa8d8 100644 --- a/Extensions/FileImportShareExtension/UI/ShareViewController.swift +++ b/Extensions/FileImportShareExtension/UI/ShareViewController.swift @@ -33,10 +33,10 @@ class ShareViewController: UIViewController, Sendable, Loggable { viewModel.status = .processing let shareView = ShareView( - statusChanged: { - Task { [weak self] in - guard let self else { return } + statusChanged: { [weak self] in + guard let self else { return } + Task { let sharedItems = await self.extractSharedFileItems() await self.viewModel.importFiles(sharedItems) } @@ -70,12 +70,7 @@ class ShareViewController: UIViewController, Sendable, Loggable { ) } else if item != nil { if let itemData = item as? Data { - Task { [weak self] in - guard let self = self else { - continuation.resume(throwing: FileImportError.dataConversionFailed) - return - } - + Task { do { let url = try await self.viewModel.convertNSDataToURL(data: itemData) continuation.resume(returning: url) diff --git a/Modules/CommonsLib/Package.swift b/Modules/CommonsLib/Package.swift index 28672fd5..c3c21be7 100644 --- a/Modules/CommonsLib/Package.swift +++ b/Modules/CommonsLib/Package.swift @@ -15,7 +15,7 @@ let package = Package( .library(name: "CommonsLibMocks", targets: ["CommonsLibMocks"]) ], dependencies: [ - .package(url: "https://github.com/hmlongco/Factory", exact: .init(2, 5, 3)) + .package(url: "https://github.com/hmlongco/Factory", exact: .init(3, 2, 1)) ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/Modules/ConfigLib/Package.resolved b/Modules/ConfigLib/Package.resolved index bcdd449d..1e47c662 100644 --- a/Modules/ConfigLib/Package.resolved +++ b/Modules/ConfigLib/Package.resolved @@ -1,42 +1,33 @@ { - "originHash" : "6794c5056d41f37e2f96d93bfea289f47405c85c8782a0eb4b4aee7dd4a4439b", - "pins" : [ + "originHash": "6794c5056d41f37e2f96d93bfea289f47405c85c8782a0eb4b4aee7dd4a4439b", + "pins": [ { - "identity" : "alamofire", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Alamofire/Alamofire.git", - "state" : { - "revision" : "513364f870f6bfc468f9d2ff0a95caccc10044c5", - "version" : "5.10.2" + "identity": "alamofire", + "kind": "remoteSourceControl", + "location": "https://github.com/Alamofire/Alamofire.git", + "state": { + "revision": "513364f870f6bfc468f9d2ff0a95caccc10044c5", + "version": "5.10.2" } }, { - "identity" : "factory", - "kind" : "remoteSourceControl", - "location" : "https://github.com/hmlongco/Factory", - "state" : { - "revision" : "ccc898f21992ebc130bc04cc197460a5ae230bcf", - "version" : "2.5.3" + "identity": "factory", + "kind": "remoteSourceControl", + "location": "https://github.com/hmlongco/Factory", + "state": { + "revision": "ccc898f21992ebc130bc04cc197460a5ae230bcf", + "version": "2.5.3" } }, { - "identity" : "swiftyrsa", - "kind" : "remoteSourceControl", - "location" : "https://github.com/TakeScoop/SwiftyRSA", - "state" : { - "revision" : "6521919ad0e99dff927685f142d8136479acb452", - "version" : "1.8.0" - } - }, - { - "identity" : "zipfoundation", - "kind" : "remoteSourceControl", - "location" : "https://github.com/weichsel/ZIPFoundation", - "state" : { - "revision" : "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0", - "version" : "0.9.19" + "identity": "zipfoundation", + "kind": "remoteSourceControl", + "location": "https://github.com/weichsel/ZIPFoundation", + "state": { + "revision": "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0", + "version": "0.9.19" } } ], - "version" : 3 + "version": 3 } diff --git a/Modules/ConfigLib/Package.swift b/Modules/ConfigLib/Package.swift index 18ce9f2e..7bee16d1 100644 --- a/Modules/ConfigLib/Package.swift +++ b/Modules/ConfigLib/Package.swift @@ -15,9 +15,8 @@ let package = Package( .library(name: "ConfigLibMocks", targets: ["ConfigLibMocks"]) ], dependencies: [ - .package(url: "https://github.com/hmlongco/Factory", exact: .init(2, 5, 3)), - .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 11, 2)), - .package(url: "https://github.com/TakeScoop/SwiftyRSA", exact: .init(1, 8, 0)), + .package(url: "https://github.com/hmlongco/Factory", exact: .init(3, 2, 1)), + .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 12, 0)), .package(path: "../CommonsLib"), .package(path: "../UtilsLib"), .package(path: "../Test/CommonsTestShared") @@ -30,7 +29,6 @@ let package = Package( dependencies: [ "Alamofire", "CommonsLib", - "SwiftyRSA", "UtilsLib", .product(name: "FactoryKit", package: "Factory") ], diff --git a/Modules/ConfigLib/Sources/ConfigLib/Configuration/Loader/ConfigurationLoader.swift b/Modules/ConfigLib/Sources/ConfigLib/Configuration/Loader/ConfigurationLoader.swift index 22ce0466..595de26b 100644 --- a/Modules/ConfigLib/Sources/ConfigLib/Configuration/Loader/ConfigurationLoader.swift +++ b/Modules/ConfigLib/Sources/ConfigLib/Configuration/Loader/ConfigurationLoader.swift @@ -390,8 +390,8 @@ public actor ConfigurationLoader: ConfigurationLoaderProtocol, Loggable { continuation.yield(config) } - continuation.onTermination = { @Sendable _ in - Task { [weak self] in + continuation.onTermination = { @Sendable [weak self] _ in + Task { await self?.removeContinuation(token) } } diff --git a/Modules/CryptoLib/Package.resolved b/Modules/CryptoLib/Package.resolved index 0c5f00d3..d4e67072 100644 --- a/Modules/CryptoLib/Package.resolved +++ b/Modules/CryptoLib/Package.resolved @@ -1,114 +1,105 @@ { - "originHash" : "1c80178f8bd730294fcd0478e01571248cf4d68e7a1e40318555c644dcd397cb", - "pins" : [ + "originHash": "1c80178f8bd730294fcd0478e01571248cf4d68e7a1e40318555c644dcd397cb", + "pins": [ { - "identity" : "alamofire", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Alamofire/Alamofire.git", - "state" : { - "revision" : "513364f870f6bfc468f9d2ff0a95caccc10044c5", - "version" : "5.10.2" + "identity": "alamofire", + "kind": "remoteSourceControl", + "location": "https://github.com/Alamofire/Alamofire.git", + "state": { + "revision": "513364f870f6bfc468f9d2ff0a95caccc10044c5", + "version": "5.10.2" } }, { - "identity" : "asn1", - "kind" : "remoteSourceControl", - "location" : "https://github.com/leif-ibsen/ASN1", - "state" : { - "revision" : "e38d1b8b43d8b53ffadde9836f34289176bb7a0c", - "version" : "2.7.0" + "identity": "asn1", + "kind": "remoteSourceControl", + "location": "https://github.com/leif-ibsen/ASN1", + "state": { + "revision": "e38d1b8b43d8b53ffadde9836f34289176bb7a0c", + "version": "2.7.0" } }, { - "identity" : "asn1decoder", - "kind" : "remoteSourceControl", - "location" : "https://github.com/filom/ASN1Decoder", - "state" : { - "revision" : "7e1523662c69d019a3299bbfb22fb824141dd1f6", - "version" : "1.10.0" + "identity": "asn1decoder", + "kind": "remoteSourceControl", + "location": "https://github.com/filom/ASN1Decoder", + "state": { + "revision": "7e1523662c69d019a3299bbfb22fb824141dd1f6", + "version": "1.10.0" } }, { - "identity" : "bigint", - "kind" : "remoteSourceControl", - "location" : "https://github.com/leif-ibsen/BigInt.git", - "state" : { - "revision" : "afb70a0038bfbba845271b60fa9a58d5840f8017", - "version" : "1.21.0" + "identity": "bigint", + "kind": "remoteSourceControl", + "location": "https://github.com/leif-ibsen/BigInt.git", + "state": { + "revision": "afb70a0038bfbba845271b60fa9a58d5840f8017", + "version": "1.21.0" } }, { - "identity" : "digest", - "kind" : "remoteSourceControl", - "location" : "https://github.com/leif-ibsen/Digest.git", - "state" : { - "revision" : "95ba89b494aaff5f3cd2933c03b9a890323dbf2c", - "version" : "1.13.0" + "identity": "digest", + "kind": "remoteSourceControl", + "location": "https://github.com/leif-ibsen/Digest.git", + "state": { + "revision": "95ba89b494aaff5f3cd2933c03b9a890323dbf2c", + "version": "1.13.0" } }, { - "identity" : "factory", - "kind" : "remoteSourceControl", - "location" : "https://github.com/hmlongco/Factory", - "state" : { - "revision" : "ccc898f21992ebc130bc04cc197460a5ae230bcf", - "version" : "2.5.3" + "identity": "factory", + "kind": "remoteSourceControl", + "location": "https://github.com/hmlongco/Factory", + "state": { + "revision": "ccc898f21992ebc130bc04cc197460a5ae230bcf", + "version": "2.5.3" } }, { - "identity" : "swift-asn1", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-asn1.git", - "state" : { - "revision" : "f70225981241859eb4aa1a18a75531d26637c8cc", - "version" : "1.4.0" + "identity": "swift-asn1", + "kind": "remoteSourceControl", + "location": "https://github.com/apple/swift-asn1.git", + "state": { + "revision": "f70225981241859eb4aa1a18a75531d26637c8cc", + "version": "1.4.0" } }, { - "identity" : "swift-certificates", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-certificates.git", - "state" : { - "revision" : "274f8668d3ec5d2892904d8465635c5ea659f767", - "version" : "1.7.0" + "identity": "swift-certificates", + "kind": "remoteSourceControl", + "location": "https://github.com/apple/swift-certificates.git", + "state": { + "revision": "274f8668d3ec5d2892904d8465635c5ea659f767", + "version": "1.7.0" } }, { - "identity" : "swift-crypto", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-crypto.git", - "state" : { - "revision" : "95ba0316a9b733e92bb6b071255ff46263bbe7dc", - "version" : "3.15.1" + "identity": "swift-crypto", + "kind": "remoteSourceControl", + "location": "https://github.com/apple/swift-crypto.git", + "state": { + "revision": "95ba0316a9b733e92bb6b071255ff46263bbe7dc", + "version": "3.15.1" } }, { - "identity" : "swiftecc", - "kind" : "remoteSourceControl", - "location" : "https://github.com/leif-ibsen/SwiftECC.git", - "state" : { - "revision" : "85c529c9c56b649a8d8edcef60aab3925ab0f69f", - "version" : "5.5.0" + "identity": "swiftecc", + "kind": "remoteSourceControl", + "location": "https://github.com/leif-ibsen/SwiftECC.git", + "state": { + "revision": "85c529c9c56b649a8d8edcef60aab3925ab0f69f", + "version": "5.5.0" } }, { - "identity" : "swiftyrsa", - "kind" : "remoteSourceControl", - "location" : "https://github.com/TakeScoop/SwiftyRSA", - "state" : { - "revision" : "6521919ad0e99dff927685f142d8136479acb452", - "version" : "1.8.0" - } - }, - { - "identity" : "zipfoundation", - "kind" : "remoteSourceControl", - "location" : "https://github.com/weichsel/ZIPFoundation", - "state" : { - "revision" : "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0", - "version" : "0.9.19" + "identity": "zipfoundation", + "kind": "remoteSourceControl", + "location": "https://github.com/weichsel/ZIPFoundation", + "state": { + "revision": "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0", + "version": "0.9.19" } } ], - "version" : 3 + "version": 3 } diff --git a/Modules/CryptoLib/Package.swift b/Modules/CryptoLib/Package.swift index f5725925..55dcc6ec 100644 --- a/Modules/CryptoLib/Package.swift +++ b/Modules/CryptoLib/Package.swift @@ -17,8 +17,8 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/filom/ASN1Decoder", exact: .init(1, 10, 0)), - .package(url: "https://github.com/leif-ibsen/BigInt.git", exact: .init(1, 23, 0)), - .package(url: "https://github.com/hmlongco/Factory", exact: .init(2, 5, 3)), + .package(url: "https://github.com/leif-ibsen/BigInt.git", exact: .init(1, 24, 0)), + .package(url: "https://github.com/hmlongco/Factory", exact: .init(3, 2, 1)), .package(path: "../ConfigLib"), .package(path: "../CommonsLib"), .package(path: "../IdCardLib"), diff --git a/Modules/IdCardLib/Package.swift b/Modules/IdCardLib/Package.swift index 02ead18a..c33d9932 100644 --- a/Modules/IdCardLib/Package.swift +++ b/Modules/IdCardLib/Package.swift @@ -11,7 +11,7 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/leif-ibsen/BigInt.git", exact: .init(1, 23, 0)) + .package(url: "https://github.com/leif-ibsen/BigInt.git", exact: .init(1, 24, 0)) ], targets: [ .binaryTarget( diff --git a/Modules/LibdigidocLib/Package.resolved b/Modules/LibdigidocLib/Package.resolved index 001de7f0..17a73a8f 100644 --- a/Modules/LibdigidocLib/Package.resolved +++ b/Modules/LibdigidocLib/Package.resolved @@ -1,42 +1,33 @@ { - "originHash" : "03b6bdf568bef3309b6ae752c4991bfc1604e222c6edd9930ad9662582913434", - "pins" : [ + "originHash": "03b6bdf568bef3309b6ae752c4991bfc1604e222c6edd9930ad9662582913434", + "pins": [ { - "identity" : "alamofire", - "kind" : "remoteSourceControl", - "location" : "https://github.com/Alamofire/Alamofire.git", - "state" : { - "revision" : "513364f870f6bfc468f9d2ff0a95caccc10044c5", - "version" : "5.10.2" + "identity": "alamofire", + "kind": "remoteSourceControl", + "location": "https://github.com/Alamofire/Alamofire.git", + "state": { + "revision": "513364f870f6bfc468f9d2ff0a95caccc10044c5", + "version": "5.10.2" } }, { - "identity" : "factory", - "kind" : "remoteSourceControl", - "location" : "https://github.com/hmlongco/Factory", - "state" : { - "revision" : "ccc898f21992ebc130bc04cc197460a5ae230bcf", - "version" : "2.5.3" + "identity": "factory", + "kind": "remoteSourceControl", + "location": "https://github.com/hmlongco/Factory", + "state": { + "revision": "ccc898f21992ebc130bc04cc197460a5ae230bcf", + "version": "2.5.3" } }, { - "identity" : "swiftyrsa", - "kind" : "remoteSourceControl", - "location" : "https://github.com/TakeScoop/SwiftyRSA", - "state" : { - "revision" : "6521919ad0e99dff927685f142d8136479acb452", - "version" : "1.8.0" - } - }, - { - "identity" : "zipfoundation", - "kind" : "remoteSourceControl", - "location" : "https://github.com/weichsel/ZIPFoundation", - "state" : { - "revision" : "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0", - "version" : "0.9.19" + "identity": "zipfoundation", + "kind": "remoteSourceControl", + "location": "https://github.com/weichsel/ZIPFoundation", + "state": { + "revision": "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0", + "version": "0.9.19" } } ], - "version" : 3 + "version": 3 } diff --git a/Modules/LibdigidocLib/Package.swift b/Modules/LibdigidocLib/Package.swift index 71ece81c..8823b10f 100644 --- a/Modules/LibdigidocLib/Package.swift +++ b/Modules/LibdigidocLib/Package.swift @@ -12,7 +12,7 @@ let package = Package( .library(name: "LibdigidocLibSwiftMocks", targets: ["LibdigidocLibSwiftMocks"]) ], dependencies: [ - .package(url: "https://github.com/hmlongco/Factory", exact: .init(2, 5, 3)), + .package(url: "https://github.com/hmlongco/Factory", exact: .init(3, 2, 1)), .package(path: "../ConfigLib"), .package(path: "../CommonsLib"), .package(path: "../UtilsLib"), diff --git a/Modules/MobileIdLib/Package.swift b/Modules/MobileIdLib/Package.swift index 6923dc74..e5ca051c 100644 --- a/Modules/MobileIdLib/Package.swift +++ b/Modules/MobileIdLib/Package.swift @@ -14,8 +14,8 @@ let package = Package( .library(name: "MobileIdLibMocks", targets: ["MobileIdLibMocks"]) ], dependencies: [ - .package(url: "https://github.com/hmlongco/Factory", exact: .init(2, 5, 3)), - .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 11, 2)), + .package(url: "https://github.com/hmlongco/Factory", exact: .init(3, 2, 1)), + .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 12, 0)), .package(path: "../CommonsLib"), .package(path: "../UtilsLib") ], diff --git a/Modules/SmartIdLib/Package.swift b/Modules/SmartIdLib/Package.swift index ea5228f1..361dc8a1 100644 --- a/Modules/SmartIdLib/Package.swift +++ b/Modules/SmartIdLib/Package.swift @@ -14,8 +14,8 @@ let package = Package( .library(name: "SmartIdLibMocks", targets: ["SmartIdLibMocks"]) ], dependencies: [ - .package(url: "https://github.com/hmlongco/Factory", exact: .init(2, 5, 3)), - .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 11, 2)), + .package(url: "https://github.com/hmlongco/Factory", exact: .init(3, 2, 1)), + .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 12, 0)), .package(path: "../UtilsLib"), .package(path: "../CommonsLib") ], diff --git a/Modules/Test/CommonsTestShared/Package.swift b/Modules/Test/CommonsTestShared/Package.swift index 6dfc771b..79406217 100644 --- a/Modules/Test/CommonsTestShared/Package.swift +++ b/Modules/Test/CommonsTestShared/Package.swift @@ -15,7 +15,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/weichsel/ZIPFoundation", exact: .init(0, 9, 20)), - .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 11, 2)), + .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 12, 0)), .package(path: "../CommonsLib") ], targets: [ diff --git a/Modules/UtilsLib/Package.swift b/Modules/UtilsLib/Package.swift index 559a3692..2efda3fd 100644 --- a/Modules/UtilsLib/Package.swift +++ b/Modules/UtilsLib/Package.swift @@ -15,8 +15,8 @@ let package = Package( .library(name: "UtilsLibMocks", targets: ["UtilsLibMocks"]) ], dependencies: [ - .package(url: "https://github.com/hmlongco/Factory", exact: .init(2, 5, 3)), - .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 11, 2)), + .package(url: "https://github.com/hmlongco/Factory", exact: .init(3, 2, 1)), + .package(url: "https://github.com/Alamofire/Alamofire.git", exact: .init(5, 12, 0)), .package(url: "https://github.com/weichsel/ZIPFoundation", exact: .init(0, 9, 20)), .package(path: "../CommonsLib"), .package(path: "../ConfigLib"), diff --git a/RIADigiDoc.xcodeproj/project.pbxproj b/RIADigiDoc.xcodeproj/project.pbxproj index d741f1f0..27663a47 100644 --- a/RIADigiDoc.xcodeproj/project.pbxproj +++ b/RIADigiDoc.xcodeproj/project.pbxproj @@ -28,6 +28,7 @@ DF4E43CB2D0BA38600967997 /* FileImportShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = DF4E43C12D0BA38600967997 /* FileImportShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; DF4E6D822D11DE7B00F6111A /* CommonsLib in Frameworks */ = {isa = PBXBuildFile; productRef = DF4E6D812D11DE7B00F6111A /* CommonsLib */; }; DF4E6D842D120CFC00F6111A /* UtilsLib in Frameworks */ = {isa = PBXBuildFile; productRef = DF4E6D832D120CFC00F6111A /* UtilsLib */; }; + DF54F82F2D431BD50021D05A /* X509 in Frameworks */ = {isa = PBXBuildFile; productRef = DF54F82E2D431BD50021D05A /* X509 */; }; DF5903762ECCC41F00D1A278 /* MobileIdLibMocks in Frameworks */ = {isa = PBXBuildFile; productRef = DF5903752ECCC41F00D1A278 /* MobileIdLibMocks */; }; DF5903782ECCC42500D1A278 /* SmartIdLibMocks in Frameworks */ = {isa = PBXBuildFile; productRef = DF5903772ECCC42500D1A278 /* SmartIdLibMocks */; }; DF5C54272E82F07A006E2251 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = DFA3EE5C2D14C9B7001D951B /* Alamofire */; }; @@ -53,7 +54,6 @@ DFB663A22F16917E00804545 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DFB663A12F16917E00804545 /* SwiftUI.framework */; }; DFB663AF2F16918100804545 /* WidgetExtensionExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = DFB6639E2F16917D00804545 /* WidgetExtensionExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; DFBD09F62CE3FBDC006AF9C2 /* LibdigidocLib in Frameworks */ = {isa = PBXBuildFile; productRef = DFBD09F52CE3FBDC006AF9C2 /* LibdigidocLib */; }; - DF54F82F2D431BD50021D05A /* X509 in Frameworks */ = {isa = PBXBuildFile; productRef = DF54F82E2D431BD50021D05A /* X509 */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -124,7 +124,7 @@ 1A3E9ED22E79D35E00033299 /* build-openldap-iphonesimulator.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-openldap-iphonesimulator.sh"; sourceTree = ""; }; 1A3E9ED62E79DD6E00033299 /* build-openldap-iphoneos.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-openldap-iphoneos.sh"; sourceTree = ""; }; 1A438FCF2E7224CE00546B86 /* generate-mocks.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "generate-mocks.sh"; sourceTree = ""; }; - 1A438FD02E7224CE00546B86 /* TSLXMLDownloader.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = TSLXMLDownloader.py; sourceTree = ""; }; + 1A438FD02E7224CE00546B86 /* tsl_xml_downloader.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = tsl_xml_downloader.py; sourceTree = ""; }; 1A7D36992E79EB8000CAD7A6 /* build-xcframeworks.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-xcframeworks.sh"; sourceTree = ""; }; 1AA9FF6C2E71A14200FFDC35 /* CryptoLib */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = CryptoLib; sourceTree = ""; }; 1AD26AB72E7AB14200A3629D /* build-libcdoc-sim.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-libcdoc-sim.sh"; sourceTree = ""; }; @@ -137,6 +137,7 @@ DF5CDD242F2BB42C002AB47F /* run-ci-tests.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "run-ci-tests.sh"; sourceTree = ""; }; DF64D0E12EC363C200FF73C6 /* SmartIdLib */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = SmartIdLib; sourceTree = ""; }; DF67D4F92D28531600F09EB9 /* ConfigLib */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = ConfigLib; sourceTree = ""; }; + DF8ADFC92FF5672E0016D019 /* setup_configuration.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = setup_configuration.py; sourceTree = ""; }; DFA16B492CD18C7C0099D34F /* libdigidoclib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = libdigidoclib.xcodeproj; sourceTree = ""; }; DFA23CBB2EB6CBF7000403E4 /* MobileIdLib */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = MobileIdLib; sourceTree = ""; }; DFA3EE432D14962C001D951B /* FileImportShareExtension */ = {isa = PBXFileReference; lastKnownFileType = folder; name = FileImportShareExtension; path = Extensions/FileImportShareExtension; sourceTree = ""; }; @@ -578,7 +579,8 @@ 1A3E9ED22E79D35E00033299 /* build-openldap-iphonesimulator.sh */, 1A3E9ED62E79DD6E00033299 /* build-openldap-iphoneos.sh */, 1A438FCF2E7224CE00546B86 /* generate-mocks.sh */, - 1A438FD02E7224CE00546B86 /* TSLXMLDownloader.py */, + DF8ADFC92FF5672E0016D019 /* setup_configuration.py */, + 1A438FD02E7224CE00546B86 /* tsl_xml_downloader.py */, ); path = scripts; sourceTree = ""; @@ -745,7 +747,6 @@ DFDB14772CC97B0E00153876 /* Sources */, DFDB14782CC97B0E00153876 /* Frameworks */, DFDB14792CC97B0E00153876 /* Resources */, - DFED7A602CC9A42A00D8BCA9 /* SwiftLint */, DFD24C3B2CD1B718004C1D2E /* Embed Frameworks */, DF4E43CC2D0BA38600967997 /* Embed Foundation Extensions */, DF1D59572F3BF3F800855E2E /* Setup Firebase Crashlytics */, @@ -753,6 +754,7 @@ buildRules = ( ); dependencies = ( + DF56ACDE2FF5E0CA007A834D /* PBXTargetDependency */, DF4E43CA2D0BA38600967997 /* PBXTargetDependency */, DFB663AE2F16918100804545 /* PBXTargetDependency */, ); @@ -986,26 +988,6 @@ shellPath = /bin/sh; shellScript = "\"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run\"\n"; }; - DFED7A602CC9A42A00D8BCA9 /* SwiftLint */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 8; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = SwiftLint; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 1; - shellPath = /bin/sh; - shellScript = "if [ \"${CONFIGURATION}\" = \"Debug\" ]; then\n SWIFT_PACKAGE_DIR=\"${BUILD_DIR%Build/*}SourcePackages/artifacts\"\n SWIFTLINT_CMD=$(ls \"$SWIFT_PACKAGE_DIR\"/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-*/bin/swiftlint | head -n 1)\n\n if test -f \"$SWIFTLINT_CMD\" 2>&1\n then\n \"$SWIFTLINT_CMD\"\n else\n echo \"warning: `swiftlint` command not found - See https://github.com/realm/SwiftLint#installation for installation instructions.\"\n fi\nelse\n echo \"Skipping SwiftLint for '${CONFIGURATION}' configuration.\"\nfi\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -1059,6 +1041,10 @@ target = DF4E43C02D0BA38600967997 /* FileImportShareExtension */; targetProxy = DF4E43C92D0BA38600967997 /* PBXContainerItemProxy */; }; + DF56ACDE2FF5E0CA007A834D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + productRef = DF56ACDD2FF5E0CA007A834D /* SwiftLintBuildToolPlugin */; + }; DFB663AE2F16918100804545 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = DFB6639D2F16917D00804545 /* WidgetExtensionExtension */; @@ -1701,7 +1687,15 @@ repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git"; requirement = { kind = exactVersion; - version = 12.12.1; + version = 12.15.0; + }; + }; + DF54F82D2D431BD50021D05A /* XCRemoteSwiftPackageReference "swift-certificates" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apple/swift-certificates.git"; + requirement = { + kind = exactVersion; + version = 1.19.2; }; }; DF9AFE902E00D30A0062C64D /* XCRemoteSwiftPackageReference "Factory" */ = { @@ -1709,7 +1703,7 @@ repositoryURL = "https://github.com/hmlongco/Factory"; requirement = { kind = exactVersion; - version = 2.5.3; + version = 3.2.1; }; }; DFA3EE592D14C4C2001D951B /* XCRemoteSwiftPackageReference "Alamofire" */ = { @@ -1717,7 +1711,7 @@ repositoryURL = "https://github.com/Alamofire/Alamofire.git"; requirement = { kind = exactVersion; - version = 5.11.2; + version = 5.12.0; }; }; DFED7A5F2CC9A3B200D8BCA9 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */ = { @@ -1725,15 +1719,7 @@ repositoryURL = "https://github.com/SimplyDanny/SwiftLintPlugins"; requirement = { kind = exactVersion; - version = 0.63.2; - }; - }; - DF54F82D2D431BD50021D05A /* XCRemoteSwiftPackageReference "swift-certificates" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/apple/swift-certificates.git"; - requirement = { - kind = exactVersion; - version = 1.19.0; + version = 0.65.0; }; }; /* End XCRemoteSwiftPackageReference section */ @@ -1818,6 +1804,16 @@ isa = XCSwiftPackageProductDependency; productName = UtilsLib; }; + DF54F82E2D431BD50021D05A /* X509 */ = { + isa = XCSwiftPackageProductDependency; + package = DF54F82D2D431BD50021D05A /* XCRemoteSwiftPackageReference "swift-certificates" */; + productName = X509; + }; + DF56ACDD2FF5E0CA007A834D /* SwiftLintBuildToolPlugin */ = { + isa = XCSwiftPackageProductDependency; + package = DFED7A5F2CC9A3B200D8BCA9 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */; + productName = "plugin:SwiftLintBuildToolPlugin"; + }; DF5903752ECCC41F00D1A278 /* MobileIdLibMocks */ = { isa = XCSwiftPackageProductDependency; productName = MobileIdLibMocks; @@ -1917,11 +1913,6 @@ isa = XCSwiftPackageProductDependency; productName = LibdigidocLib; }; - DF54F82E2D431BD50021D05A /* X509 */ = { - isa = XCSwiftPackageProductDependency; - package = DF54F82D2D431BD50021D05A /* XCRemoteSwiftPackageReference "swift-certificates" */; - productName = X509; - }; /* End XCSwiftPackageProductDependency section */ }; rootObject = DFDB14732CC97B0E00153876 /* Project object */; diff --git a/RIADigiDoc.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RIADigiDoc.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 0718496b..8a9470a6 100644 --- a/RIADigiDoc.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RIADigiDoc.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "b4f054ad9c471fab72929d2e5687dd7f818e958401197162c86062302c1826d8", + "originHash" : "c46b3a148e4bd58cb2204eb2ed30e5d408f2439e5d7d989a705fdebb4533e608", "pins" : [ { "identity" : "abseil-cpp-binary", @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Alamofire/Alamofire.git", "state" : { - "revision" : "e938f8c66708e7352fc7e3512647fa54255b267a", - "version" : "5.11.2" + "revision" : "7595cbcf59809f9977c5f6378500de2ad73b7ddb", + "version" : "5.12.0" } }, { @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/google/app-check.git", "state" : { - "revision" : "61b85103a1aeed8218f17c794687781505fbbef5", - "version" : "11.2.0" + "revision" : "bb4002485ff867768dec13bf904a2ddb050bd1b1", + "version" : "11.3.0" } }, { @@ -51,8 +51,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/leif-ibsen/BigInt", "state" : { - "revision" : "c2f49bee454760e433bafff17bfdc5b96f75d7c8", - "version" : "1.23.0" + "revision" : "7c7b1be2f6714ce03833879b0aab4b20293c0207", + "version" : "1.24.0" } }, { @@ -69,8 +69,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/hmlongco/Factory", "state" : { - "revision" : "ccc898f21992ebc130bc04cc197460a5ae230bcf", - "version" : "2.5.3" + "revision" : "cacafd638e8af1dac8abd6a4ab013d53983e2703", + "version" : "3.2.1" } }, { @@ -78,8 +78,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/firebase/firebase-ios-sdk.git", "state" : { - "revision" : "46579c364d39b86ec9fb8f613e19f023700a929c", - "version" : "12.12.1" + "revision" : "42e81d245e30e49ea6a5830cf2842d44a1591270", + "version" : "12.15.0" } }, { @@ -87,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/googleads/google-ads-on-device-conversion-ios-sdk", "state" : { - "revision" : "19dffda9a9caf8d86570ff846535902d8509d7bf", - "version" : "3.5.0" + "revision" : "dc39082d8881109d35b94b1c122164c0e8d08a55", + "version" : "3.6.1" } }, { @@ -96,8 +96,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/google/GoogleAppMeasurement.git", "state" : { - "revision" : "5100f946bd32778662047a823bf145c6da32d85d", - "version" : "12.12.1" + "revision" : "144855f40d8668927f256a3045f7fdc4c3f4338b", + "version" : "12.15.0" } }, { @@ -186,8 +186,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-certificates.git", "state" : { - "revision" : "5aa1c0d1bc204908df47c2075bdbb39573d05e8d", - "version" : "1.19.0" + "revision" : "eaa10d47d19919979dd8df22ff4fd6349b1108d4", + "version" : "1.19.2" } }, { @@ -213,17 +213,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/SimplyDanny/SwiftLintPlugins", "state" : { - "revision" : "8a4640d14777685ba8f14e832373160498fbab92", - "version" : "0.63.2" - } - }, - { - "identity" : "swiftyrsa", - "kind" : "remoteSourceControl", - "location" : "https://github.com/TakeScoop/SwiftyRSA", - "state" : { - "revision" : "6521919ad0e99dff927685f142d8136479acb452", - "version" : "1.8.0" + "revision" : "3292bab28e6e92000161348003fdef8edc4e582d", + "version" : "0.65.0" } }, { diff --git a/RIADigiDoc/DI/AppContainer.swift b/RIADigiDoc/DI/AppContainer.swift index ebdf4655..ad0a9d64 100644 --- a/RIADigiDoc/DI/AppContainer.swift +++ b/RIADigiDoc/DI/AppContainer.swift @@ -170,9 +170,10 @@ extension Container { } public var certificateUtil: Factory { - self { @MainActor in CertificateUtil() } + self { CertificateUtil() } } + @MainActor public var proxyUtil: Factory { self { @MainActor in ProxyUtil( dataStore: self.dataStore(), diff --git a/RIADigiDoc/Domain/Model/DependencyLicense.swift b/RIADigiDoc/Domain/Model/DependencyLicense.swift index a7854847..f4de4d4b 100644 --- a/RIADigiDoc/Domain/Model/DependencyLicense.swift +++ b/RIADigiDoc/Domain/Model/DependencyLicense.swift @@ -64,16 +64,6 @@ struct DependencyLicenses { license: "OpenSSL License", url: URL(string: "https://www.openssl.org/source/license.txt") ), - DependencyLicense( - name: "SwCrypt", - license: "MIT licence", - url: URL(string: "https://github.com/soyersoyer/SwCrypt/blob/master/LICENSE.md") - ), - DependencyLicense( - name: "SwiftyRSA", - license: "MIT licence", - url: URL(string: "https://github.com/TakeScoop/SwiftyRSA/blob/master/LICENSE") - ), DependencyLicense( name: "SwiftLintPlugins", license: "MIT licence", diff --git a/RIADigiDoc/RIADigiDocApp.swift b/RIADigiDoc/RIADigiDocApp.swift index d144dc7f..84970218 100644 --- a/RIADigiDoc/RIADigiDocApp.swift +++ b/RIADigiDoc/RIADigiDocApp.swift @@ -25,7 +25,7 @@ import ConfigLib import CommonsLib @main -struct RIADigiDocApp: App { +struct RIADigiDocApp: App, Loggable { @State private var languageSettings: LanguageSettings @State private var themeSettings: ThemeSettings @State private var crashReportManager: CrashReportManager @@ -73,8 +73,14 @@ struct RIADigiDocApp: App { let isRecentDocumentsMigrationDone = await dataStore.getIsRecentDocumentsMigrationDone() if !isRecentDocumentsMigrationDone { - try await documentsMigrator.migrateRecentDocuments() - await dataStore.setIsRecentDocumentsMigrationDone(true) + do { + try await documentsMigrator.migrateRecentDocuments() + await dataStore.setIsRecentDocumentsMigrationDone(true) + } catch { + RIADigiDocApp.logger().error( + "Unable to migrate recent documents: \(String(describing: error))" + ) + } } await languageSettings.loadSelectedLanguage() diff --git a/RIADigiDoc/UI/Component/Container/Crypto/EncryptView.swift b/RIADigiDoc/UI/Component/Container/Crypto/EncryptView.swift index cafd2b14..2b9ab3ff 100644 --- a/RIADigiDoc/UI/Component/Container/Crypto/EncryptView.swift +++ b/RIADigiDoc/UI/Component/Container/Crypto/EncryptView.swift @@ -178,8 +178,8 @@ struct EncryptView: View { fileUtil: FileUtilProtocol = Container.shared.fileUtil() ) { _viewModel = State(wrappedValue: Container.shared.encryptViewModel()) - self.isWithEncryption = isWithEncryption - self.isWithDecryption = isWithDecryption + _isWithEncryption = State(wrappedValue: isWithEncryption) + _isWithDecryption = State(wrappedValue: isWithDecryption) self.nameUtil = nameUtil self.recipientUtil = recipientUtil self.fileUtil = fileUtil diff --git a/RIADigiDoc/UI/Component/Container/Crypto/Recipient/EncryptRecipientView.swift b/RIADigiDoc/UI/Component/Container/Crypto/Recipient/EncryptRecipientView.swift index 564e9df9..7bade179 100644 --- a/RIADigiDoc/UI/Component/Container/Crypto/Recipient/EncryptRecipientView.swift +++ b/RIADigiDoc/UI/Component/Container/Crypto/Recipient/EncryptRecipientView.swift @@ -343,7 +343,10 @@ struct EncryptRecipientView: View { } .onChange(of: viewModel.successMessage) { _, message in guard let message, !message.key.isEmpty else { return } - let localizedMessage = languageSettings.localized(message.key, [message.args.joined(separator: ", ")]) + let localizedMessage = languageSettings.localized( + message.key, + [message.args.joined(separator: ", ")] + ) Toast.show(localizedMessage, type: .success) if voiceOverEnabled { diff --git a/RIADigiDoc/UI/Component/CryptoFileOpeningView.swift b/RIADigiDoc/UI/Component/CryptoFileOpeningView.swift index aa456aa4..68741972 100644 --- a/RIADigiDoc/UI/Component/CryptoFileOpeningView.swift +++ b/RIADigiDoc/UI/Component/CryptoFileOpeningView.swift @@ -95,7 +95,10 @@ struct CryptoFileOpeningView: View { } } } else { - let localizedMessage = languageSettings.localized(errorMessage?.key ?? "General error", errorMessage?.args ?? []) + let localizedMessage = languageSettings.localized( + errorMessage?.key ?? "General error", + errorMessage?.args ?? [] + ) Toast.show(localizedMessage) if voiceOverEnabled { diff --git a/RIADigiDoc/UI/Component/FileOpeningView.swift b/RIADigiDoc/UI/Component/FileOpeningView.swift index 115c5db1..0c2af827 100644 --- a/RIADigiDoc/UI/Component/FileOpeningView.swift +++ b/RIADigiDoc/UI/Component/FileOpeningView.swift @@ -136,7 +136,10 @@ struct FileOpeningView: View { } } } else { - let localizedMessage = languageSettings.localized(errorMessage?.key ?? "General error", errorMessage?.args ?? []) + let localizedMessage = languageSettings.localized( + errorMessage?.key ?? "General error", + errorMessage?.args ?? [] + ) Toast.show(localizedMessage) if voiceOverEnabled { diff --git a/RIADigiDoc/Util/Certificate/CertificateUtil.swift b/RIADigiDoc/Util/Certificate/CertificateUtil.swift index e3d85bc2..2db5255d 100644 --- a/RIADigiDoc/Util/Certificate/CertificateUtil.swift +++ b/RIADigiDoc/Util/Certificate/CertificateUtil.swift @@ -24,8 +24,6 @@ import X509 import UtilsLib public struct CertificateUtil: CertificateUtilProtocol, Loggable { - public init() {} - public func pemToDerData(fromPEM pem: Data) -> Data? { guard let pemString = String(data: pem, encoding: .utf8) else { return nil } let lines = pemString.components(separatedBy: .newlines) diff --git a/RIADigiDoc/Util/Proxy/ProxyUtil.swift b/RIADigiDoc/Util/Proxy/ProxyUtil.swift index 3b45e15f..4442ba21 100644 --- a/RIADigiDoc/Util/Proxy/ProxyUtil.swift +++ b/RIADigiDoc/Util/Proxy/ProxyUtil.swift @@ -23,16 +23,8 @@ import LibdigidocLibSwift public struct ProxyUtil: ProxyUtilProtocol { - private let dataStore: DataStoreProtocol - private let keychainStore: KeychainStoreProtocol - - public init( - dataStore: DataStoreProtocol, - keychainStore: KeychainStoreProtocol - ) { - self.dataStore = dataStore - self.keychainStore = keychainStore - } + let dataStore: DataStoreProtocol + let keychainStore: KeychainStoreProtocol public func isPortValid(_ port: Int) -> Bool { return 1 <= port && port <= 65535 diff --git a/RIADigiDoc/Util/Proxy/ProxyUtilProtocol.swift b/RIADigiDoc/Util/Proxy/ProxyUtilProtocol.swift index b2b6de13..323afe4c 100644 --- a/RIADigiDoc/Util/Proxy/ProxyUtilProtocol.swift +++ b/RIADigiDoc/Util/Proxy/ProxyUtilProtocol.swift @@ -20,6 +20,7 @@ import CommonsLib /// @mockable +@MainActor public protocol ProxyUtilProtocol: Sendable { func isPortValid(_ port: Int) -> Bool func getProxyInfo() async -> ProxyInfo diff --git a/RIADigiDocTests/Util/Proxy/ProxyUtilTests.swift b/RIADigiDocTests/Util/Proxy/ProxyUtilTests.swift index d716c872..e47462a9 100644 --- a/RIADigiDocTests/Util/Proxy/ProxyUtilTests.swift +++ b/RIADigiDocTests/Util/Proxy/ProxyUtilTests.swift @@ -21,6 +21,7 @@ import CommonsLib import Foundation import Testing +@MainActor final class ProxyUtilTests { private let proxyUtil: ProxyUtil diff --git a/RIADigiDocTests/ViewModel/MyEid/MyEidPinChangeViewModelTests.swift b/RIADigiDocTests/ViewModel/MyEid/MyEidPinChangeViewModelTests.swift index d71fd16f..a44a9903 100644 --- a/RIADigiDocTests/ViewModel/MyEid/MyEidPinChangeViewModelTests.swift +++ b/RIADigiDocTests/ViewModel/MyEid/MyEidPinChangeViewModelTests.swift @@ -62,7 +62,6 @@ final class MyEidPinChangeViewModelTests { #expect(viewModel.isFirstStep == true) } - // MARK: - handleBackButton tests @Test diff --git a/SetupConfiguration/Package.swift b/SetupConfiguration/Package.swift deleted file mode 100644 index 03670b98..00000000 --- a/SetupConfiguration/Package.swift +++ /dev/null @@ -1,14 +0,0 @@ -// swift-tools-version:4.2 -import PackageDescription - -let package = Package(name: "SetupConfiguration") - -package.products = [ - .executable(name: "SetupConfiguration", targets: ["SetupConfiguration"]) -] -package.dependencies = [ - -] -package.targets = [ - .target(name: "SetupConfiguration", dependencies: [], path: "Sources") -] diff --git a/SetupConfiguration/Sources/SwCrypt/.gitignore b/SetupConfiguration/Sources/SwCrypt/.gitignore deleted file mode 100755 index 101296b9..00000000 --- a/SetupConfiguration/Sources/SwCrypt/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -## Build generated -build/ -DerivedData -test_output - -## Various settings -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata - -## Other -*.xccheckout -*.moved-aside -*.xcuserstate -*.xcscmblueprint - -## Obj-C/Swift specific -*.hmap -*.ipa diff --git a/SetupConfiguration/Sources/SwCrypt/Package.swift b/SetupConfiguration/Sources/SwCrypt/Package.swift deleted file mode 100644 index a105813e..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Package.swift +++ /dev/null @@ -1,25 +0,0 @@ -// swift-tools-version:4.0 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "SwCrypt", - products: [ - // Products define the executables and libraries produced by a package, and make them visible to other packages. - .library( - name: "SwCrypt", - targets: ["SwCrypt"]), - ], - dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), - ], - targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages which this package depends on. - .target( - name: "SwCrypt", - dependencies: []) - ] -) diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/LICENSE.md b/SetupConfiguration/Sources/SwCrypt/Sources/LICENSE.md deleted file mode 100755 index 74a38574..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 Soyer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/README.md b/SetupConfiguration/Sources/SwCrypt/Sources/README.md deleted file mode 100755 index 6ef51a91..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/README.md +++ /dev/null @@ -1,165 +0,0 @@ -[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) - -SwCrypt -========= - -### Create public and private RSA keys in DER format -``` -let (privateKey, publicKey) = try! CC.RSA.generateKeyPair(2048) -``` -### Convert them to PEM format -``` -let privateKeyPEM = try SwKeyConvert.PrivateKey.derToPKCS1PEM(privateKey) -let publicKeyPEM = SwKeyConvert.PublicKey.derToPKCS8PEM(publicKey) -``` -### Or read them from strings with PEM data -``` -let privateKeyDER = SwKeyConvert.PrivateKey.pemToPKCS1DER(privateKeyPEM) -let publicKeyDER = SwKeyConvert.PublicKey.pemToPKCS1DER(publicKeyPEM) -``` -### Or encrypt, decrypt the private key (OpenSSL compatible) -``` -try SwKeyConvert.PrivateKey.encryptPEM(privateKeyPEM, passphrase: "longpassword", mode: .aes256CBC) -try SwKeyConvert.PrivateKey.decryptPEM(privEncrypted, passphrase: "longpassword") -``` -### Get public key from private keys in DER format -``` -let publicKeyDER = try? CC.RSA.getPublicKeyFromPrivateKey(privateKeyDER!) -``` -### Encrypt, decrypt data with RSA -``` -try CC.RSA.encrypt(data, derKey: publicKey, tag: tag, padding: .oaep, digest: .sha1) -try CC.RSA.decrypt(data, derKey: privateKey, tag: tag, padding: .oaep, digest: .sha1) -``` -### Sign, verify data with RSA -``` -let sign = try? CC.RSA.sign(testMessage, derKey: privKey, padding: .pss, - digest: .sha256, saltLen: 16) -let verified = try? CC.RSA.verify(testMessage, derKey: pubKey, padding: .pss, - digest: .sha256, saltLen: 16, signedData: sign!) -``` -### Elliptic curve functions -``` -let keys = try? CC.EC.generateKeyPair(384) -let signed = try? CC.EC.signHash(keys!.0, hash: hash) -let verified = try? CC.EC.verifyHash(keys!.1, hash: hash, signedData: signed!) - -let shared = try? CC.EC.computeSharedSecret(keys!.0, publicKey: partnerPubKey) - -let privComponents = try? CC.EC.getPrivateKeyComponents(keys!.0) -let pubComponents = try? CC.EC.getPublicKeyComponents(keys!.1) - -let pubKey = try? CC.EC.createFromData(keySize, x, y) -let pubKey = try? CC.EC.getPublicKeyFromPrivateKey(keys!.0) - -``` -### Diffie-Hellman functions -``` -let dh = try CC.DH.DH(dhParam: .rfc3526Group5) -let myPubKey = try dh.generateKey() -let commonKey = try dh.computeKey(partnerPubKey!) -``` -### Encrypt, decrypt data with symmetric ciphers -``` -try CC.crypt(.encrypt, blockMode: .cbc, algorithm: .aes, padding: .pkcs7Padding, data: data, key: aesKey, iv: iv) -try CC.crypt(.decrypt, blockMode: .cfb, algorithm: .aes, padding: .pkcs7Padding, data: data, key: aesKey, iv: iv) -``` -### Encrypt, decrypt data with symmetric authenticating ciphers -``` -try CC.cryptAuth(.encrypt, blockMode: .gcm, algorithm: .aes, data: data, aData: aData, key: aesKey, iv: iv, tagLength: tagLength) -try CC.cryptAuth(.decrypt, blockMode: .ccm, algorithm: .aes, data: data, aData: aData, key: aesKey, iv: iv, tagLength: tagLength) -``` -### Digest functions -``` -CC.digest(data, alg: .md5) -CC.digest(data, alg: .sha256) -CC.digest(data, alg: .sha512) -``` -### HMAC function -``` -CC.HMAC(data, alg: .sha512, key: key) -``` -### CMAC function -``` -CC.CMAC.AESCMAC(input, key: key) -``` -### CRC function -``` -let output = try? CC.CRC.crc(input, mode: .crc32) -``` -### KeyDerivation -``` -CC.KeyDerivation.PBKDF2(password, salt: salt, prf: .sha256, rounds: 4096) -``` -### Symmetric Key Wrapping -``` -try CC.KeyWrap.SymmetricKeyWrap(CC.KeyWrap.rfc3394IV, kek: kek, rawKey: rawKey) -try CC.KeyWrap.SymmetricKeyUnwrap(CC.KeyWrap.rfc3394IV, kek: kek, wrappedKey: wrappedKey) -``` -### Upsert, get, delete keys from KeyStore -``` -try SwKeyStore.upsertKey(privateKeyPEM, keyTag: "priv", options: [kSecAttrAccessible:kSecAttrAccessibleWhenUnlockedThisDeviceOnly]) -try SwKeyStore.getKey("priv") -try SwKeyStore.delKey("priv") -``` ------ - - -Check availability ---------------------- - -SwCrypt uses dlopen and dlsym to load the CommonCrypto's functions, because not all of them are available in public header files. You have to check the availability before using them. - -``` -let digestAvailable : Bool = CC.digestAvailable() -let ramdomAvailable : Bool = CC.randomAvailable(() -let hmacAvailable : Bool = CC.hmacAvailable() -let cryptorAvailable : Bool = CC.cryptorAvailable -let keyDerivationAvailable : Bool = CC.KeyDerivation.available() -let keyWrapAvailable : Bool = CC.KeyWrap.available() -let rsaAvailable : Bool = CC.RSA.available() -let dhAvailable : Bool = CC.DH.available() -let ecAvailable : Bool = CC.EC.available() -let crcAvailable : Bool = CC.CRC.available() -let cmacAvailable : Bool = CC.CMAC.available() -let gcmAvailable : Bool = CC.GCM.available() -let ccmAvailable : Bool = CC.CCM.available() - -or all in one turn: -let ccAvailable : Bool = CC.available() -``` - -Install -------- -Just copy [SwCrypt.swift](https://github.com/soyersoyer/SwCrypt/blob/master/SwCrypt/SwCrypt.swift) to your project or use the [Carthage](https://github.com/Carthage/Carthage) dependency manager. - -### CocoaPods -[CocoaPods][] is a dependency manager for Cocoa projects. To install SwCrypt with CocoaPods: - - 1. Make sure CocoaPods is [installed][CocoaPods Installation]. - - 2. Update your Podfile to include the following: - - ``` ruby - pod 'SwCrypt' - ``` - - 3. Run `pod install`. - -[CocoaPods]: https://cocoapods.org -[CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started - - -Inspired from -------------- - - - - - - - - - - - - -License -------- - -This project is copyrighted under the MIT license. diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.podspec b/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.podspec deleted file mode 100755 index 6d774c3d..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.podspec +++ /dev/null @@ -1,16 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = "SwCrypt" - spec.version = "5.1.3" - spec.summary = "RSA public/private key generation, RSA, AES encryption/decryption, RSA sign/verify in Swift with CommonCrypto in iOS and OS X" - spec.homepage = "https://github.com/soyersoyer/SwCrypt" - spec.license = { :type => 'MIT' } - spec.authors = { "soyersoyer" => 'soyer@irl.hu' } - spec.swift_version = "4.2" - spec.ios.deployment_target = "8.0" - spec.osx.deployment_target = "10.12" - spec.watchos.deployment_target = "3.0" - spec.tvos.deployment_target = "11.0" - spec.requires_arc = true - spec.source = { git: "https://github.com/soyersoyer/SwCrypt.git", :tag => spec.version } - spec.source_files = "SwCrypt/**/*.{h,swift}" -end diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.xcodeproj/project.pbxproj b/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.xcodeproj/project.pbxproj deleted file mode 100755 index 0b4ba642..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1066 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 2C6840A91F8C3A6E00BF8DD7 /* SwCrypt.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0A71E921CBC7DB4002C5C88 /* SwCrypt.swift */; }; - A0086F222172C48D0052F457 /* SwCrypt.podspec in Resources */ = {isa = PBXBuildFile; fileRef = A0086F212172C48D0052F457 /* SwCrypt.podspec */; }; - A01057F821C03ADD008392E0 /* SwCrypt.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A0A71E781CBC7D74002C5C88 /* SwCrypt.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - A051E37E1DBA5DA4004293E9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A051E37D1DBA5DA4004293E9 /* AppDelegate.swift */; }; - A051E3801DBA5DA4004293E9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A051E37F1DBA5DA4004293E9 /* ViewController.swift */; }; - A051E3831DBA5DA4004293E9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A051E3811DBA5DA4004293E9 /* Main.storyboard */; }; - A051E3851DBA5DA4004293E9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A051E3841DBA5DA4004293E9 /* Assets.xcassets */; }; - A051E3881DBA5DA4004293E9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A051E3861DBA5DA4004293E9 /* LaunchScreen.storyboard */; }; - A0A71E7C1CBC7D74002C5C88 /* SwCrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = A0A71E7B1CBC7D74002C5C88 /* SwCrypt.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A0A71E881CBC7D74002C5C88 /* SwCryptTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0A71E871CBC7D74002C5C88 /* SwCryptTests.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - A01057F521C03AC8008392E0 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = A0A71E6F1CBC7D74002C5C88 /* Project object */; - proxyType = 1; - remoteGlobalIDString = A051E37A1DBA5DA3004293E9; - remoteInfo = dummyTestApp; - }; - A0A71E841CBC7D74002C5C88 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = A0A71E6F1CBC7D74002C5C88 /* Project object */; - proxyType = 1; - remoteGlobalIDString = A0A71E771CBC7D74002C5C88; - remoteInfo = SwCrypt; - }; - A0C5816C21C02C60003BF9B8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = A0A71E6F1CBC7D74002C5C88 /* Project object */; - proxyType = 1; - remoteGlobalIDString = A0A71E771CBC7D74002C5C88; - remoteInfo = SwCrypt; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - A01057F921C03ADD008392E0 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - A01057F821C03ADD008392E0 /* SwCrypt.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - A0086F212172C48D0052F457 /* SwCrypt.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SwCrypt.podspec; sourceTree = ""; }; - A03DFA252173C0F600A9D5DD /* SwCrypt_macOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwCrypt_macOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - A03DFA322173C16400A9D5DD /* SwCrypt_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwCrypt_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - A03DFA3F2173C1CA00A9D5DD /* SwCrypt_watchOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwCrypt_watchOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - A042DCB91CC0800F00271902 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; - A051E37B1DBA5DA3004293E9 /* dummyTestApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = dummyTestApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; - A051E37D1DBA5DA4004293E9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - A051E37F1DBA5DA4004293E9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - A051E3821DBA5DA4004293E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - A051E3841DBA5DA4004293E9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - A051E3871DBA5DA4004293E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - A051E3891DBA5DA4004293E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - A051E38F1DBA5DDB004293E9 /* dummyTestApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = dummyTestApp.entitlements; sourceTree = ""; }; - A0A71E781CBC7D74002C5C88 /* SwCrypt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwCrypt.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - A0A71E7B1CBC7D74002C5C88 /* SwCrypt.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwCrypt.h; sourceTree = ""; }; - A0A71E7D1CBC7D74002C5C88 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - A0A71E821CBC7D74002C5C88 /* SwCryptTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwCryptTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - A0A71E871CBC7D74002C5C88 /* SwCryptTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwCryptTests.swift; sourceTree = ""; }; - A0A71E891CBC7D74002C5C88 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - A0A71E921CBC7DB4002C5C88 /* SwCrypt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwCrypt.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - A03DFA222173C0F600A9D5DD /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A03DFA2F2173C16400A9D5DD /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A03DFA3C2173C1CA00A9D5DD /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A051E3781DBA5DA3004293E9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A0A71E741CBC7D74002C5C88 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A0A71E7F1CBC7D74002C5C88 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 2C6840A41F8C391200BF8DD7 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; - A051E37C1DBA5DA4004293E9 /* dummyTestApp */ = { - isa = PBXGroup; - children = ( - A051E38F1DBA5DDB004293E9 /* dummyTestApp.entitlements */, - A051E37D1DBA5DA4004293E9 /* AppDelegate.swift */, - A051E37F1DBA5DA4004293E9 /* ViewController.swift */, - A051E3811DBA5DA4004293E9 /* Main.storyboard */, - A051E3841DBA5DA4004293E9 /* Assets.xcassets */, - A051E3861DBA5DA4004293E9 /* LaunchScreen.storyboard */, - A051E3891DBA5DA4004293E9 /* Info.plist */, - ); - path = dummyTestApp; - sourceTree = ""; - }; - A0A71E6E1CBC7D74002C5C88 = { - isa = PBXGroup; - children = ( - A0086F212172C48D0052F457 /* SwCrypt.podspec */, - A042DCB91CC0800F00271902 /* README.md */, - A0A71E7A1CBC7D74002C5C88 /* SwCrypt */, - A0A71E861CBC7D74002C5C88 /* SwCryptTests */, - A051E37C1DBA5DA4004293E9 /* dummyTestApp */, - A0A71E791CBC7D74002C5C88 /* Products */, - 2C6840A41F8C391200BF8DD7 /* Frameworks */, - ); - sourceTree = ""; - }; - A0A71E791CBC7D74002C5C88 /* Products */ = { - isa = PBXGroup; - children = ( - A0A71E781CBC7D74002C5C88 /* SwCrypt.framework */, - A0A71E821CBC7D74002C5C88 /* SwCryptTests.xctest */, - A051E37B1DBA5DA3004293E9 /* dummyTestApp.app */, - A03DFA252173C0F600A9D5DD /* SwCrypt_macOS.framework */, - A03DFA322173C16400A9D5DD /* SwCrypt_tvOS.framework */, - A03DFA3F2173C1CA00A9D5DD /* SwCrypt_watchOS.framework */, - ); - name = Products; - sourceTree = ""; - }; - A0A71E7A1CBC7D74002C5C88 /* SwCrypt */ = { - isa = PBXGroup; - children = ( - A0A71E921CBC7DB4002C5C88 /* SwCrypt.swift */, - A0A71E7B1CBC7D74002C5C88 /* SwCrypt.h */, - A0A71E7D1CBC7D74002C5C88 /* Info.plist */, - ); - path = SwCrypt; - sourceTree = ""; - }; - A0A71E861CBC7D74002C5C88 /* SwCryptTests */ = { - isa = PBXGroup; - children = ( - A0A71E871CBC7D74002C5C88 /* SwCryptTests.swift */, - A0A71E891CBC7D74002C5C88 /* Info.plist */, - ); - path = SwCryptTests; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - A03DFA202173C0F600A9D5DD /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A03DFA2D2173C16400A9D5DD /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A03DFA3A2173C1CA00A9D5DD /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A0A71E751CBC7D74002C5C88 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - A0A71E7C1CBC7D74002C5C88 /* SwCrypt.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - A03DFA242173C0F600A9D5DD /* SwCrypt macOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = A03DFA2A2173C0F700A9D5DD /* Build configuration list for PBXNativeTarget "SwCrypt macOS" */; - buildPhases = ( - A03DFA202173C0F600A9D5DD /* Headers */, - A03DFA212173C0F600A9D5DD /* Sources */, - A03DFA222173C0F600A9D5DD /* Frameworks */, - A03DFA232173C0F600A9D5DD /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "SwCrypt macOS"; - productName = "SwCrypt macOS"; - productReference = A03DFA252173C0F600A9D5DD /* SwCrypt_macOS.framework */; - productType = "com.apple.product-type.framework"; - }; - A03DFA312173C16400A9D5DD /* SwCrypt tvOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = A03DFA372173C16500A9D5DD /* Build configuration list for PBXNativeTarget "SwCrypt tvOS" */; - buildPhases = ( - A03DFA2D2173C16400A9D5DD /* Headers */, - A03DFA2E2173C16400A9D5DD /* Sources */, - A03DFA2F2173C16400A9D5DD /* Frameworks */, - A03DFA302173C16400A9D5DD /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "SwCrypt tvOS"; - productName = "SwCrypt tvOS"; - productReference = A03DFA322173C16400A9D5DD /* SwCrypt_tvOS.framework */; - productType = "com.apple.product-type.framework"; - }; - A03DFA3E2173C1CA00A9D5DD /* SwCrypt watchOS */ = { - isa = PBXNativeTarget; - buildConfigurationList = A03DFA442173C1CA00A9D5DD /* Build configuration list for PBXNativeTarget "SwCrypt watchOS" */; - buildPhases = ( - A03DFA3A2173C1CA00A9D5DD /* Headers */, - A03DFA3B2173C1CA00A9D5DD /* Sources */, - A03DFA3C2173C1CA00A9D5DD /* Frameworks */, - A03DFA3D2173C1CA00A9D5DD /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "SwCrypt watchOS"; - productName = "SwCrypt watchOS"; - productReference = A03DFA3F2173C1CA00A9D5DD /* SwCrypt_watchOS.framework */; - productType = "com.apple.product-type.framework"; - }; - A051E37A1DBA5DA3004293E9 /* dummyTestApp */ = { - isa = PBXNativeTarget; - buildConfigurationList = A051E38C1DBA5DA4004293E9 /* Build configuration list for PBXNativeTarget "dummyTestApp" */; - buildPhases = ( - A051E3771DBA5DA3004293E9 /* Sources */, - A051E3781DBA5DA3004293E9 /* Frameworks */, - A051E3791DBA5DA3004293E9 /* Resources */, - A01057F921C03ADD008392E0 /* Embed Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - A0C5816D21C02C60003BF9B8 /* PBXTargetDependency */, - ); - name = dummyTestApp; - productName = dummyTestApp; - productReference = A051E37B1DBA5DA3004293E9 /* dummyTestApp.app */; - productType = "com.apple.product-type.application"; - }; - A0A71E771CBC7D74002C5C88 /* SwCrypt */ = { - isa = PBXNativeTarget; - buildConfigurationList = A0A71E8C1CBC7D74002C5C88 /* Build configuration list for PBXNativeTarget "SwCrypt" */; - buildPhases = ( - A0A71E731CBC7D74002C5C88 /* Sources */, - A0A71E741CBC7D74002C5C88 /* Frameworks */, - A0A71E751CBC7D74002C5C88 /* Headers */, - A0A71E761CBC7D74002C5C88 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = SwCrypt; - productName = SwCrypt; - productReference = A0A71E781CBC7D74002C5C88 /* SwCrypt.framework */; - productType = "com.apple.product-type.framework"; - }; - A0A71E811CBC7D74002C5C88 /* SwCryptTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = A0A71E8F1CBC7D74002C5C88 /* Build configuration list for PBXNativeTarget "SwCryptTests" */; - buildPhases = ( - A0A71E7E1CBC7D74002C5C88 /* Sources */, - A0A71E7F1CBC7D74002C5C88 /* Frameworks */, - A0A71E801CBC7D74002C5C88 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - A0A71E851CBC7D74002C5C88 /* PBXTargetDependency */, - A01057F621C03AC8008392E0 /* PBXTargetDependency */, - ); - name = SwCryptTests; - productName = SwCryptTests; - productReference = A0A71E821CBC7D74002C5C88 /* SwCryptTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - A0A71E6F1CBC7D74002C5C88 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 1000; - ORGANIZATIONNAME = irl; - TargetAttributes = { - A03DFA242173C0F600A9D5DD = { - CreatedOnToolsVersion = 10.0; - ProvisioningStyle = Manual; - }; - A03DFA312173C16400A9D5DD = { - CreatedOnToolsVersion = 10.0; - ProvisioningStyle = Manual; - }; - A03DFA3E2173C1CA00A9D5DD = { - CreatedOnToolsVersion = 10.0; - ProvisioningStyle = Manual; - }; - A051E37A1DBA5DA3004293E9 = { - CreatedOnToolsVersion = 8.0; - DevelopmentTeam = X5L4X5ZF45; - LastSwiftMigration = 0900; - ProvisioningStyle = Automatic; - SystemCapabilities = { - com.apple.Keychain = { - enabled = 1; - }; - }; - }; - A0A71E771CBC7D74002C5C88 = { - CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0900; - ProvisioningStyle = Manual; - }; - A0A71E811CBC7D74002C5C88 = { - CreatedOnToolsVersion = 7.3; - DevelopmentTeam = X5L4X5ZF45; - LastSwiftMigration = 0900; - ProvisioningStyle = Manual; - TestTargetID = A051E37A1DBA5DA3004293E9; - }; - }; - }; - buildConfigurationList = A0A71E721CBC7D74002C5C88 /* Build configuration list for PBXProject "SwCrypt" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = A0A71E6E1CBC7D74002C5C88; - productRefGroup = A0A71E791CBC7D74002C5C88 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - A0A71E771CBC7D74002C5C88 /* SwCrypt */, - A0A71E811CBC7D74002C5C88 /* SwCryptTests */, - A051E37A1DBA5DA3004293E9 /* dummyTestApp */, - A03DFA242173C0F600A9D5DD /* SwCrypt macOS */, - A03DFA312173C16400A9D5DD /* SwCrypt tvOS */, - A03DFA3E2173C1CA00A9D5DD /* SwCrypt watchOS */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - A03DFA232173C0F600A9D5DD /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A03DFA302173C16400A9D5DD /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A03DFA3D2173C1CA00A9D5DD /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A051E3791DBA5DA3004293E9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A051E3881DBA5DA4004293E9 /* LaunchScreen.storyboard in Resources */, - A051E3851DBA5DA4004293E9 /* Assets.xcassets in Resources */, - A051E3831DBA5DA4004293E9 /* Main.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A0A71E761CBC7D74002C5C88 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A0086F222172C48D0052F457 /* SwCrypt.podspec in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A0A71E801CBC7D74002C5C88 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - A03DFA212173C0F600A9D5DD /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A03DFA2E2173C16400A9D5DD /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A03DFA3B2173C1CA00A9D5DD /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A051E3771DBA5DA3004293E9 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A051E3801DBA5DA4004293E9 /* ViewController.swift in Sources */, - A051E37E1DBA5DA4004293E9 /* AppDelegate.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A0A71E731CBC7D74002C5C88 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2C6840A91F8C3A6E00BF8DD7 /* SwCrypt.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - A0A71E7E1CBC7D74002C5C88 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A0A71E881CBC7D74002C5C88 /* SwCryptTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - A01057F621C03AC8008392E0 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = A051E37A1DBA5DA3004293E9 /* dummyTestApp */; - targetProxy = A01057F521C03AC8008392E0 /* PBXContainerItemProxy */; - }; - A0A71E851CBC7D74002C5C88 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = A0A71E771CBC7D74002C5C88 /* SwCrypt */; - targetProxy = A0A71E841CBC7D74002C5C88 /* PBXContainerItemProxy */; - }; - A0C5816D21C02C60003BF9B8 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = A0A71E771CBC7D74002C5C88 /* SwCrypt */; - targetProxy = A0C5816C21C02C60003BF9B8 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - A051E3811DBA5DA4004293E9 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - A051E3821DBA5DA4004293E9 /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - A051E3861DBA5DA4004293E9 /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - A051E3871DBA5DA4004293E9 /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - A03DFA2B2173C0F700A9D5DD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "-"; - CODE_SIGN_STYLE = Manual; - COMBINE_HIDPI_IMAGES = YES; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_VERSION = A; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = SwCrypt/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.13; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "hu.irl.SwCrypt-macOS"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = macosx; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.2; - }; - name = Debug; - }; - A03DFA2C2173C0F700A9D5DD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "-"; - CODE_SIGN_STYLE = Manual; - COMBINE_HIDPI_IMAGES = YES; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_VERSION = A; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = SwCrypt/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.13; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "hu.irl.SwCrypt-macOS"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = macosx; - SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; - }; - name = Release; - }; - A03DFA382173C16500A9D5DD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Manual; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = SwCrypt/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "hu.irl.SwCrypt-tvOS"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = appletvos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 12.0; - }; - name = Debug; - }; - A03DFA392173C16500A9D5DD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Manual; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = SwCrypt/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "hu.irl.SwCrypt-tvOS"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = appletvos; - SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 12.0; - }; - name = Release; - }; - A03DFA452173C1CA00A9D5DD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - APPLICATION_EXTENSION_API_ONLY = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Manual; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = SwCrypt/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "hu.irl.SwCrypt-watchOS"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = watchos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 5.0; - }; - name = Debug; - }; - A03DFA462173C1CA00A9D5DD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - APPLICATION_EXTENSION_API_ONLY = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = ""; - CODE_SIGN_STYLE = Manual; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = SwCrypt/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "hu.irl.SwCrypt-watchOS"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SDKROOT = watchos; - SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; - TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 5.0; - }; - name = Release; - }; - A051E38A1DBA5DA4004293E9 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_SUSPICIOUS_MOVES = YES; - CODE_SIGN_ENTITLEMENTS = dummyTestApp/dummyTestApp.entitlements; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = X5L4X5ZF45; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - ); - INFOPLIST_FILE = dummyTestApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = hu.irl.dummyTestAppa; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; - }; - name = Debug; - }; - A051E38B1DBA5DA4004293E9 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_SUSPICIOUS_MOVES = YES; - CODE_SIGN_ENTITLEMENTS = dummyTestApp/dummyTestApp.entitlements; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = X5L4X5ZF45; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - ); - INFOPLIST_FILE = dummyTestApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = hu.irl.dummyTestAppa; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; - }; - name = Release; - }; - A0A71E8A1CBC7D74002C5C88 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - A0A71E8B1CBC7D74002C5C88 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - A0A71E8D1CBC7D74002C5C88 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Manual; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = SwCrypt/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = hu.irl.SwCrypt; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.2; - }; - name = Debug; - }; - A0A71E8E1CBC7D74002C5C88 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Manual; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = SwCrypt/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = hu.irl.SwCrypt; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.2; - }; - name = Release; - }; - A0A71E901CBC7D74002C5C88 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Manual; - DEVELOPMENT_TEAM = X5L4X5ZF45; - INFOPLIST_FILE = SwCryptTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = hu.irl.SwCryptTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/dummyTestApp.app/dummyTestApp"; - }; - name = Debug; - }; - A0A71E911CBC7D74002C5C88 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CODE_SIGN_STYLE = Manual; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = SwCryptTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = hu.irl.SwCryptTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/dummyTestApp.app/dummyTestApp"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - A03DFA2A2173C0F700A9D5DD /* Build configuration list for PBXNativeTarget "SwCrypt macOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A03DFA2B2173C0F700A9D5DD /* Debug */, - A03DFA2C2173C0F700A9D5DD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - A03DFA372173C16500A9D5DD /* Build configuration list for PBXNativeTarget "SwCrypt tvOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A03DFA382173C16500A9D5DD /* Debug */, - A03DFA392173C16500A9D5DD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - A03DFA442173C1CA00A9D5DD /* Build configuration list for PBXNativeTarget "SwCrypt watchOS" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A03DFA452173C1CA00A9D5DD /* Debug */, - A03DFA462173C1CA00A9D5DD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - A051E38C1DBA5DA4004293E9 /* Build configuration list for PBXNativeTarget "dummyTestApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A051E38A1DBA5DA4004293E9 /* Debug */, - A051E38B1DBA5DA4004293E9 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - A0A71E721CBC7D74002C5C88 /* Build configuration list for PBXProject "SwCrypt" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A0A71E8A1CBC7D74002C5C88 /* Debug */, - A0A71E8B1CBC7D74002C5C88 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - A0A71E8C1CBC7D74002C5C88 /* Build configuration list for PBXNativeTarget "SwCrypt" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A0A71E8D1CBC7D74002C5C88 /* Debug */, - A0A71E8E1CBC7D74002C5C88 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - A0A71E8F1CBC7D74002C5C88 /* Build configuration list for PBXNativeTarget "SwCryptTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A0A71E901CBC7D74002C5C88 /* Debug */, - A0A71E911CBC7D74002C5C88 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = A0A71E6F1CBC7D74002C5C88 /* Project object */; -} diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.xcodeproj/xcshareddata/xcschemes/SwCrypt.xcscheme b/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.xcodeproj/xcshareddata/xcschemes/SwCrypt.xcscheme deleted file mode 100755 index 14d89198..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt.xcodeproj/xcshareddata/xcschemes/SwCrypt.xcscheme +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/Info.plist b/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/Info.plist deleted file mode 100755 index d3de8eef..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - NSPrincipalClass - - - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/SwCrypt.h b/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/SwCrypt.h deleted file mode 100755 index c11b3d57..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/SwCrypt.h +++ /dev/null @@ -1,11 +0,0 @@ - #import - -//! Project version number for SwCrypt. -FOUNDATION_EXPORT double SwCryptVersionNumber; - -//! Project version string for SwCrypt. -FOUNDATION_EXPORT const unsigned char SwCryptVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/SwCrypt.swift b/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/SwCrypt.swift deleted file mode 100755 index 40a7504c..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/SwCrypt/SwCrypt.swift +++ /dev/null @@ -1,2410 +0,0 @@ -import Foundation - -open class SwKeyStore { - - public enum SecError: OSStatus, Error { - case unimplemented = -4 - case param = -50 - case allocate = -108 - case notAvailable = -25291 - case authFailed = -25293 - case duplicateItem = -25299 - case itemNotFound = -25300 - case interactionNotAllowed = -25308 - case decode = -26275 - case missingEntitlement = -34018 - - public static var debugLevel = 1 - - init(_ status: OSStatus, function: String = #function, file: String = #file, line: Int = #line) { - self = SecError(rawValue: status)! - if SecError.debugLevel > 0 { - print("\(file):\(line): [\(function)] \(self._domain): \(self) (\(self.rawValue))") - } - } - init(_ type: SecError, function: String = #function, file: String = #file, line: Int = #line) { - self = type - if SecError.debugLevel > 0 { - print("\(file):\(line): [\(function)] \(self._domain): \(self) (\(self.rawValue))") - } - } - } - - public static func upsertKey(_ pemKey: String, keyTag: String, - options: [NSString : AnyObject] = [:]) throws { - let pemKeyAsData = pemKey.data(using: String.Encoding.utf8)! - - var parameters: [NSString : AnyObject] = [ - kSecClass: kSecClassKey, - kSecAttrKeyType: kSecAttrKeyTypeRSA, - kSecAttrIsPermanent: true as AnyObject, - kSecAttrApplicationTag: keyTag as AnyObject, - kSecValueData: pemKeyAsData as AnyObject - ] - options.forEach { k, v in - parameters[k] = v - } - - var status = SecItemAdd(parameters as CFDictionary, nil) - if status == errSecDuplicateItem { - try delKey(keyTag) - status = SecItemAdd(parameters as CFDictionary, nil) - } - guard status == errSecSuccess else { throw SecError(status) } - } - - public static func getKey(_ keyTag: String) throws -> String { - let parameters: [NSString : AnyObject] = [ - kSecClass : kSecClassKey, - kSecAttrKeyType : kSecAttrKeyTypeRSA, - kSecAttrApplicationTag : keyTag as AnyObject, - kSecReturnData : true as AnyObject - ] - var data: AnyObject? - let status = SecItemCopyMatching(parameters as CFDictionary, &data) - guard status == errSecSuccess else { throw SecError(status) } - - guard let pemKeyAsData = data as? Data else { - throw SecError(.decode) - } - guard let result = String(data: pemKeyAsData, encoding: String.Encoding.utf8) else { - throw SecError(.decode) - } - return result - } - - public static func delKey(_ keyTag: String) throws { - let parameters: [NSString : AnyObject] = [ - kSecClass : kSecClassKey, - kSecAttrApplicationTag: keyTag as AnyObject - ] - let status = SecItemDelete(parameters as CFDictionary) - guard status == errSecSuccess else { throw SecError(status) } - } -} - -open class SwKeyConvert { - - public enum SwError: Error { - case invalidKey - case badPassphrase - case keyNotEncrypted - - public static var debugLevel = 1 - - init(_ type: SwError, function: String = #function, file: String = #file, line: Int = #line) { - self = type - if SwError.debugLevel > 0 { - print("\(file):\(line): [\(function)] \(self._domain): \(self)") - } - } - } - - open class PrivateKey { - - public static func pemToPKCS1DER(_ pemKey: String) throws -> Data { - guard let derKey = try? PEM.PrivateKey.toDER(pemKey) else { - throw SwError(.invalidKey) - } - guard let pkcs1DERKey = PKCS8.PrivateKey.stripHeaderIfAny(derKey) else { - throw SwError(.invalidKey) - } - return pkcs1DERKey - } - - public static func derToPKCS1PEM(_ derKey: Data) -> String { - return PEM.PrivateKey.toPEM(derKey) - } - - public typealias EncMode = PEM.EncryptedPrivateKey.EncMode - - public static func encryptPEM(_ pemKey: String, passphrase: String, - mode: EncMode) throws -> String { - do { - let derKey = try PEM.PrivateKey.toDER(pemKey) - return PEM.EncryptedPrivateKey.toPEM(derKey, passphrase: passphrase, mode: mode) - } catch { - throw SwError(.invalidKey) - } - } - - public static func decryptPEM(_ pemKey: String, passphrase: String) throws -> String { - do { - let derKey = try PEM.EncryptedPrivateKey.toDER(pemKey, passphrase: passphrase) - return PEM.PrivateKey.toPEM(derKey) - } catch PEM.SwError.badPassphrase { - throw SwError(.badPassphrase) - } catch PEM.SwError.keyNotEncrypted { - throw SwError(.keyNotEncrypted) - } catch { - throw SwError(.invalidKey) - } - } - } - - open class PublicKey { - - public static func pemToPKCS1DER(_ pemKey: String) throws -> Data { - guard let derKey = try? PEM.PublicKey.toDER(pemKey) else { - throw SwError(.invalidKey) - } - guard let pkcs1DERKey = PKCS8.PublicKey.stripHeaderIfAny(derKey) else { - throw SwError(.invalidKey) - } - return pkcs1DERKey - } - - public static func pemToPKCS8DER(_ pemKey: String) throws -> Data { - guard let derKey = try? PEM.PublicKey.toDER(pemKey) else { - throw SwError(.invalidKey) - } - return derKey - } - - public static func derToPKCS1PEM(_ derKey: Data) -> String { - return PEM.PublicKey.toPEM(derKey) - } - - public static func derToPKCS8PEM(_ derKey: Data) -> String { - let pkcs8Key = PKCS8.PublicKey.addHeader(derKey) - return PEM.PublicKey.toPEM(pkcs8Key) - } - - } - -} - -open class PKCS8 { - - open class PrivateKey { - - // https://lapo.it/asn1js/ - public static func getPKCS1DEROffset(_ derKey: Data) -> Int? { - let bytes = derKey.bytesView - - var offset = 0 - guard bytes.length > offset else { return nil } - guard bytes[offset] == 0x30 else { return nil } - - offset += 1 - - guard bytes.length > offset else { return nil } - if bytes[offset] > 0x80 { - offset += Int(bytes[offset]) - 0x80 - } - offset += 1 - - guard bytes.length > offset else { return nil } - guard bytes[offset] == 0x02 else { return nil } - - offset += 3 - - // without PKCS8 header - guard bytes.length > offset else { return nil } - if bytes[offset] == 0x02 { - return 0 - } - - let OID: [UInt8] = [0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00] - - guard bytes.length > offset + OID.count else { return nil } - let slice = derKey.bytesViewRange(NSRange(location: offset, length: OID.count)) - - guard OID.elementsEqual(slice) else { return nil } - - offset += OID.count - - guard bytes.length > offset else { return nil } - guard bytes[offset] == 0x04 else { return nil } - - offset += 1 - - guard bytes.length > offset else { return nil } - if bytes[offset] > 0x80 { - offset += Int(bytes[offset]) - 0x80 - } - offset += 1 - - guard bytes.length > offset else { return nil } - guard bytes[offset] == 0x30 else { return nil } - - return offset - } - - public static func stripHeaderIfAny(_ derKey: Data) -> Data? { - guard let offset = getPKCS1DEROffset(derKey) else { - return nil - } - return derKey.subdata(in: offset.. Bool { - return getPKCS1DEROffset(derKey) != nil - } - - } - - open class PublicKey { - - public static func addHeader(_ derKey: Data) -> Data { - var result = Data() - - let encodingLength: Int = encodedOctets(derKey.count + 1).count - let OID: [UInt8] = [0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00] - - var builder: [UInt8] = [] - - // ASN.1 SEQUENCE - builder.append(0x30) - - // Overall size, made of OID + bitstring encoding + actual key - let size = OID.count + 2 + encodingLength + derKey.count - let encodedSize = encodedOctets(size) - builder.append(contentsOf: encodedSize) - result.append(builder, count: builder.count) - result.append(OID, count: OID.count) - builder.removeAll(keepingCapacity: false) - - builder.append(0x03) - builder.append(contentsOf: encodedOctets(derKey.count + 1)) - builder.append(0x00) - result.append(builder, count: builder.count) - - // Actual key bytes - result.append(derKey) - - return result - } - - // https://lapo.it/asn1js/ - public static func getPKCS1DEROffset(_ derKey: Data) -> Int? { - let bytes = derKey.bytesView - - var offset = 0 - guard bytes.length > offset else { return nil } - guard bytes[offset] == 0x30 else { return nil } - - offset += 1 - - guard bytes.length > offset else { return nil } - if bytes[offset] > 0x80 { - offset += Int(bytes[offset]) - 0x80 - } - offset += 1 - - // without PKCS8 header - guard bytes.length > offset else { return nil } - if bytes[offset] == 0x02 { - return 0 - } - - let OID: [UInt8] = [0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, - 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00] - - guard bytes.length > offset + OID.count else { return nil } - let slice = derKey.bytesViewRange(NSRange(location: offset, length: OID.count)) - - guard OID.elementsEqual(slice) else { return nil } - offset += OID.count - - // Type - guard bytes.length > offset else { return nil } - guard bytes[offset] == 0x03 else { return nil } - - offset += 1 - - guard bytes.length > offset else { return nil } - if bytes[offset] > 0x80 { - offset += Int(bytes[offset]) - 0x80 - } - offset += 1 - - // Contents should be separated by a null from the header - guard bytes.length > offset else { return nil } - guard bytes[offset] == 0x00 else { return nil } - - offset += 1 - guard bytes.length > offset else { return nil } - - return offset - } - - public static func stripHeaderIfAny(_ derKey: Data) -> Data? { - guard let offset = getPKCS1DEROffset(derKey) else { - return nil - } - return derKey.subdata(in: offset.. Bool { - return getPKCS1DEROffset(derKey) != nil - } - - fileprivate static func encodedOctets(_ int: Int) -> [UInt8] { - // Short form - if int < 128 { - return [UInt8(int)] - } - - // Long form - let i = (int / 256) + 1 - var len = int - var result: [UInt8] = [UInt8(i + 0x80)] - - for _ in 0..> 8 - } - - return result - } - } -} - -open class PEM { - - public enum SwError: Error { - case parse(String) - case badPassphrase - case keyNotEncrypted - - public static var debugLevel = 1 - - init(_ type: SwError, function: String = #function, file: String = #file, line: Int = #line) { - self = type - if SwError.debugLevel > 0 { - print("\(file):\(line): [\(function)] \(self._domain): \(self)") - } - } - } - - open class PrivateKey { - - public static func toDER(_ pemKey: String) throws -> Data { - guard let strippedKey = stripHeader(pemKey) else { - throw SwError(.parse("header")) - } - guard let data = PEM.base64Decode(strippedKey) else { - throw SwError(.parse("base64decode")) - } - return data - } - - public static func toPEM(_ derKey: Data) -> String { - let base64 = PEM.base64Encode(derKey) - return addRSAHeader(base64) - } - - fileprivate static let prefix = "-----BEGIN PRIVATE KEY-----\n" - fileprivate static let suffix = "\n-----END PRIVATE KEY-----" - fileprivate static let rsaPrefix = "-----BEGIN RSA PRIVATE KEY-----\n" - fileprivate static let rsaSuffix = "\n-----END RSA PRIVATE KEY-----" - - fileprivate static func addHeader(_ base64: String) -> String { - return prefix + base64 + suffix - } - - fileprivate static func addRSAHeader(_ base64: String) -> String { - return rsaPrefix + base64 + rsaSuffix - } - - fileprivate static func stripHeader(_ pemKey: String) -> String? { - return PEM.stripHeaderFooter(pemKey, header: prefix, footer: suffix) ?? - PEM.stripHeaderFooter(pemKey, header: rsaPrefix, footer: rsaSuffix) - } - } - - open class PublicKey { - - public static func toDER(_ pemKey: String) throws -> Data { - guard let strippedKey = stripHeader(pemKey) else { - throw SwError(.parse("header")) - } - guard let data = PEM.base64Decode(strippedKey) else { - throw SwError(.parse("base64decode")) - } - return data - } - - public static func toPEM(_ derKey: Data) -> String { - let base64 = PEM.base64Encode(derKey) - return addHeader(base64) - } - - fileprivate static let pemPrefix = "-----BEGIN PUBLIC KEY-----\n" - fileprivate static let pemSuffix = "\n-----END PUBLIC KEY-----" - - fileprivate static func addHeader(_ base64: String) -> String { - return pemPrefix + base64 + pemSuffix - } - - fileprivate static func stripHeader(_ pemKey: String) -> String? { - return PEM.stripHeaderFooter(pemKey, header: pemPrefix, footer: pemSuffix) - } - } - - // OpenSSL PKCS#1 compatible encrypted private key - open class EncryptedPrivateKey { - - public enum EncMode { - case aes128CBC, aes256CBC - } - - public static func toDER(_ pemKey: String, passphrase: String) throws -> Data { - guard let strippedKey = PrivateKey.stripHeader(pemKey) else { - throw SwError(.parse("header")) - } - guard let mode = getEncMode(strippedKey) else { - throw SwError(.keyNotEncrypted) - } - guard let iv = getIV(strippedKey) else { - throw SwError(.parse("iv")) - } - let aesKey = getAESKey(mode, passphrase: passphrase, iv: iv) - let base64Data = String(strippedKey[strippedKey.index(strippedKey.startIndex, offsetBy: aesHeaderLength)...]) - guard let data = PEM.base64Decode(base64Data) else { - throw SwError(.parse("base64decode")) - } - guard let decrypted = try? decryptKey(data, key: aesKey, iv: iv) else { - throw SwError(.badPassphrase) - } - guard PKCS8.PrivateKey.hasCorrectHeader(decrypted) else { - throw SwError(.badPassphrase) - } - return decrypted - } - - public static func toPEM(_ derKey: Data, passphrase: String, mode: EncMode) -> String { - let iv = CC.generateRandom(16) - let aesKey = getAESKey(mode, passphrase: passphrase, iv: iv) - let encrypted = encryptKey(derKey, key: aesKey, iv: iv) - let encryptedDERKey = addEncryptHeader(encrypted, iv: iv, mode: mode) - return PrivateKey.addRSAHeader(encryptedDERKey) - } - - fileprivate static let aes128CBCInfo = "Proc-Type: 4,ENCRYPTED\nDEK-Info: AES-128-CBC," - fileprivate static let aes256CBCInfo = "Proc-Type: 4,ENCRYPTED\nDEK-Info: AES-256-CBC," - fileprivate static let aesInfoLength = aes128CBCInfo.count - fileprivate static let aesIVInHexLength = 32 - fileprivate static let aesHeaderLength = aesInfoLength + aesIVInHexLength - - fileprivate static func addEncryptHeader(_ key: Data, iv: Data, mode: EncMode) -> String { - return getHeader(mode) + iv.hexadecimalString() + "\n\n" + PEM.base64Encode(key) - } - - fileprivate static func getHeader(_ mode: EncMode) -> String { - switch mode { - case .aes128CBC: return aes128CBCInfo - case .aes256CBC: return aes256CBCInfo - } - } - - fileprivate static func getEncMode(_ strippedKey: String) -> EncMode? { - if strippedKey.hasPrefix(aes128CBCInfo) { - return .aes128CBC - } - if strippedKey.hasPrefix(aes256CBCInfo) { - return .aes256CBC - } - return nil - } - - fileprivate static func getIV(_ strippedKey: String) -> Data? { - let ivInHex = String(strippedKey[strippedKey.index(strippedKey.startIndex, offsetBy: aesInfoLength) ..< strippedKey.index(strippedKey.startIndex, offsetBy: aesHeaderLength)]) - return ivInHex.dataFromHexadecimalString() - } - - fileprivate static func getAESKey(_ mode: EncMode, passphrase: String, iv: Data) -> Data { - switch mode { - case .aes128CBC: return getAES128Key(passphrase, iv: iv) - case .aes256CBC: return getAES256Key(passphrase, iv: iv) - } - } - - fileprivate static func getAES128Key(_ passphrase: String, iv: Data) -> Data { - // 128bit_Key = MD5(Passphrase + Salt) - let pass = passphrase.data(using: String.Encoding.utf8)! - let salt = iv.subdata(in: 0..<8) - - var key = pass - key.append(salt) - return CC.digest(key, alg: .md5) - } - - fileprivate static func getAES256Key(_ passphrase: String, iv: Data) -> Data { - // 128bit_Key = MD5(Passphrase + Salt) - // 256bit_Key = 128bit_Key + MD5(128bit_Key + Passphrase + Salt) - let pass = passphrase.data(using: String.Encoding.utf8)! - let salt = iv.subdata(in: 0 ..< 8) - - var first = pass - first.append(salt) - let aes128Key = CC.digest(first, alg: .md5) - - var sec = aes128Key - sec.append(pass) - sec.append(salt) - - var aes256Key = aes128Key - aes256Key.append(CC.digest(sec, alg: .md5)) - return aes256Key - } - - fileprivate static func encryptKey(_ data: Data, key: Data, iv: Data) -> Data { - return try! CC.crypt( - .encrypt, blockMode: .cbc, algorithm: .aes, padding: .pkcs7Padding, - data: data, key: key, iv: iv) - } - - fileprivate static func decryptKey(_ data: Data, key: Data, iv: Data) throws -> Data { - return try CC.crypt( - .decrypt, blockMode: .cbc, algorithm: .aes, padding: .pkcs7Padding, - data: data, key: key, iv: iv) - } - - } - - fileprivate static func stripHeaderFooter(_ data: String, header: String, footer: String) -> String? { - guard data.hasPrefix(header) else { - return nil - } - guard let r = data.range(of: footer) else { - return nil - } - return String(data[header.endIndex ..< r.lowerBound]) - } - - fileprivate static func base64Decode(_ base64Data: String) -> Data? { - return Data(base64Encoded: base64Data, options: [.ignoreUnknownCharacters]) - } - - fileprivate static func base64Encode(_ key: Data) -> String { - return key.base64EncodedString( - options: [.lineLength64Characters, .endLineWithLineFeed]) - } - -} - -open class CC { - - public typealias CCCryptorStatus = Int32 - public enum CCError: CCCryptorStatus, Error { - case paramError = -4300 - case bufferTooSmall = -4301 - case memoryFailure = -4302 - case alignmentError = -4303 - case decodeError = -4304 - case unimplemented = -4305 - case overflow = -4306 - case rngFailure = -4307 - case unspecifiedError = -4308 - case callSequenceError = -4309 - case keySizeError = -4310 - case invalidKey = -4311 - - public static var debugLevel = 1 - - init(_ status: CCCryptorStatus, function: String = #function, - file: String = #file, line: Int = #line) { - self = CCError(rawValue: status)! - if CCError.debugLevel > 0 { - print("\(file):\(line): [\(function)] \(self._domain): \(self) (\(self.rawValue))") - } - } - init(_ type: CCError, function: String = #function, file: String = #file, line: Int = #line) { - self = type - if CCError.debugLevel > 0 { - print("\(file):\(line): [\(function)] \(self._domain): \(self) (\(self.rawValue))") - } - } - } - - public static func generateRandom(_ size: Int) -> Data { - var data = Data(count: size) - data.withUnsafeMutableBytes { dataBytes in - _ = CCRandomGenerateBytes!(dataBytes, size) - } - return data - } - - public typealias CCDigestAlgorithm = UInt32 - public enum DigestAlgorithm: CCDigestAlgorithm { - case none = 0 - case md5 = 3 - case rmd128 = 4, rmd160 = 5, rmd256 = 6, rmd320 = 7 - case sha1 = 8 - case sha224 = 9, sha256 = 10, sha384 = 11, sha512 = 12 - - var length: Int { - return CCDigestGetOutputSize!(self.rawValue) - } - } - - public static func digest(_ data: Data, alg: DigestAlgorithm) -> Data { - var output = Data(count: alg.length) - withUnsafePointers(data, &output, { dataBytes, outputBytes in - _ = CCDigest!(alg.rawValue, - dataBytes, - data.count, - outputBytes) - }) - return output - } - - public typealias CCHmacAlgorithm = UInt32 - public enum HMACAlg: CCHmacAlgorithm { - case sha1, md5, sha256, sha384, sha512, sha224 - - var digestLength: Int { - switch self { - case .sha1: return 20 - case .md5: return 16 - case .sha256: return 32 - case .sha384: return 48 - case .sha512: return 64 - case .sha224: return 28 - } - } - } - - public static func HMAC(_ data: Data, alg: HMACAlg, key: Data) -> Data { - var buffer = Data(count: alg.digestLength) - withUnsafePointers(key, data, &buffer, { keyBytes, dataBytes, bufferBytes in - CCHmac!(alg.rawValue, - keyBytes, key.count, - dataBytes, data.count, - bufferBytes) - }) - return buffer - } - - public typealias CCOperation = UInt32 - public enum OpMode: CCOperation { - case encrypt = 0, decrypt - } - - public typealias CCMode = UInt32 - public enum BlockMode: CCMode { - case ecb = 1, cbc, cfb, ctr, f8, lrw, ofb, xts, rc4, cfb8 - var needIV: Bool { - switch self { - case .cbc, .cfb, .ctr, .ofb, .cfb8: return true - default: return false - } - } - } - - public enum AuthBlockMode: CCMode { - case gcm = 11, ccm - } - - public typealias CCAlgorithm = UInt32 - public enum Algorithm: CCAlgorithm { - case aes = 0, des, threeDES, cast, rc4, rc2, blowfish - - var blockSize: Int? { - switch self { - case .aes: return 16 - case .des: return 8 - case .threeDES: return 8 - case .cast: return 8 - case .rc2: return 8 - case .blowfish: return 8 - default: return nil - } - } - } - - public typealias CCPadding = UInt32 - public enum Padding: CCPadding { - case noPadding = 0, pkcs7Padding - } - - public static func crypt(_ opMode: OpMode, blockMode: BlockMode, - algorithm: Algorithm, padding: Padding, - data: Data, key: Data, iv: Data) throws -> Data { - if blockMode.needIV { - guard iv.count == algorithm.blockSize else { throw CCError(.paramError) } - } - - var cryptor: CCCryptorRef? = nil - var status = withUnsafePointers(iv, key, { ivBytes, keyBytes in - return CCCryptorCreateWithMode!( - opMode.rawValue, blockMode.rawValue, - algorithm.rawValue, padding.rawValue, - ivBytes, keyBytes, key.count, - nil, 0, 0, - CCModeOptions(), &cryptor) - }) - - guard status == noErr else { throw CCError(status) } - - defer { _ = CCCryptorRelease!(cryptor!) } - - let needed = CCCryptorGetOutputLength!(cryptor!, data.count, true) - var result = Data(count: needed) - let rescount = result.count - var updateLen: size_t = 0 - status = withUnsafePointers(data, &result, { dataBytes, resultBytes in - return CCCryptorUpdate!( - cryptor!, - dataBytes, data.count, - resultBytes, rescount, - &updateLen) - }) - guard status == noErr else { throw CCError(status) } - - - var finalLen: size_t = 0 - status = result.withUnsafeMutableBytes { resultBytes in - return CCCryptorFinal!( - cryptor!, - resultBytes + updateLen, - rescount - updateLen, - &finalLen) - } - guard status == noErr else { throw CCError(status) } - - - result.count = updateLen + finalLen - return result - } - - // The same behaviour as in the CCM pdf - // http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf - public static func cryptAuth(_ opMode: OpMode, blockMode: AuthBlockMode, algorithm: Algorithm, - data: Data, aData: Data, - key: Data, iv: Data, tagLength: Int) throws -> Data { - let cryptFun = blockMode == .gcm ? GCM.crypt : CCM.crypt - if opMode == .encrypt { - let (cipher, tag) = try cryptFun(opMode, algorithm, data, - key, iv, aData, tagLength) - var result = cipher - result.append(tag) - return result - } else { - let cipher = data.subdata(in: 0..<(data.count - tagLength)) - let tag = data.subdata( - in: (data.count - tagLength).. Bool { - return CCDigest != nil && - CCDigestGetOutputSize != nil - } - - public static func randomAvailable() -> Bool { - return CCRandomGenerateBytes != nil - } - - public static func hmacAvailable() -> Bool { - return CCHmac != nil - } - - public static func cryptorAvailable() -> Bool { - return CCCryptorCreateWithMode != nil && - CCCryptorGetOutputLength != nil && - CCCryptorUpdate != nil && - CCCryptorFinal != nil && - CCCryptorRelease != nil - } - - public static func available() -> Bool { - return digestAvailable() && - randomAvailable() && - hmacAvailable() && - cryptorAvailable() && - KeyDerivation.available() && - KeyWrap.available() && - RSA.available() && - DH.available() && - EC.available() && - CRC.available() && - CMAC.available() && - GCM.available() && - CCM.available() - } - - fileprivate typealias CCCryptorRef = UnsafeRawPointer - fileprivate typealias CCRNGStatus = CCCryptorStatus - fileprivate typealias CC_LONG = UInt32 - fileprivate typealias CCModeOptions = UInt32 - - fileprivate typealias CCRandomGenerateBytesT = @convention(c) ( - _ bytes: UnsafeMutableRawPointer, - _ count: size_t) -> CCRNGStatus - fileprivate typealias CCDigestGetOutputSizeT = @convention(c) ( - _ algorithm: CCDigestAlgorithm) -> size_t - fileprivate typealias CCDigestT = @convention(c) ( - _ algorithm: CCDigestAlgorithm, - _ data: UnsafeRawPointer, - _ dataLen: size_t, - _ output: UnsafeMutableRawPointer) -> CInt - - fileprivate typealias CCHmacT = @convention(c) ( - _ algorithm: CCHmacAlgorithm, - _ key: UnsafeRawPointer, - _ keyLength: Int, - _ data: UnsafeRawPointer, - _ dataLength: Int, - _ macOut: UnsafeMutableRawPointer) -> Void - fileprivate typealias CCCryptorCreateWithModeT = @convention(c)( - _ op: CCOperation, - _ mode: CCMode, - _ alg: CCAlgorithm, - _ padding: CCPadding, - _ iv: UnsafeRawPointer?, - _ key: UnsafeRawPointer, _ keyLength: Int, - _ tweak: UnsafeRawPointer?, _ tweakLength: Int, - _ numRounds: Int32, _ options: CCModeOptions, - _ cryptorRef: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate typealias CCCryptorGetOutputLengthT = @convention(c)( - _ cryptorRef: CCCryptorRef, - _ inputLength: size_t, - _ final: Bool) -> size_t - fileprivate typealias CCCryptorUpdateT = @convention(c)( - _ cryptorRef: CCCryptorRef, - _ dataIn: UnsafeRawPointer, - _ dataInLength: Int, - _ dataOut: UnsafeMutableRawPointer, - _ dataOutAvailable: Int, - _ dataOutMoved: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate typealias CCCryptorFinalT = @convention(c)( - _ cryptorRef: CCCryptorRef, - _ dataOut: UnsafeMutableRawPointer, - _ dataOutAvailable: Int, - _ dataOutMoved: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate typealias CCCryptorReleaseT = @convention(c) - (_ cryptorRef: CCCryptorRef) -> CCCryptorStatus - - - fileprivate static let dl = dlopen("/usr/lib/system/libcommonCrypto.dylib", RTLD_NOW) - fileprivate static let CCRandomGenerateBytes: CCRandomGenerateBytesT? = - getFunc(dl!, f: "CCRandomGenerateBytes") - fileprivate static let CCDigestGetOutputSize: CCDigestGetOutputSizeT? = - getFunc(dl!, f: "CCDigestGetOutputSize") - fileprivate static let CCDigest: CCDigestT? = getFunc(dl!, f: "CCDigest") - fileprivate static let CCHmac: CCHmacT? = getFunc(dl!, f: "CCHmac") - fileprivate static let CCCryptorCreateWithMode: CCCryptorCreateWithModeT? = - getFunc(dl!, f: "CCCryptorCreateWithMode") - fileprivate static let CCCryptorGetOutputLength: CCCryptorGetOutputLengthT? = - getFunc(dl!, f: "CCCryptorGetOutputLength") - fileprivate static let CCCryptorUpdate: CCCryptorUpdateT? = - getFunc(dl!, f: "CCCryptorUpdate") - fileprivate static let CCCryptorFinal: CCCryptorFinalT? = - getFunc(dl!, f: "CCCryptorFinal") - fileprivate static let CCCryptorRelease: CCCryptorReleaseT? = - getFunc(dl!, f: "CCCryptorRelease") - - open class GCM { - - public static func crypt(_ opMode: OpMode, algorithm: Algorithm, data: Data, - key: Data, iv: Data, - aData: Data, tagLength: Int) throws -> (Data, Data) { - var result = Data(count: data.count) - var tagLength_ = tagLength - var tag = Data(count: tagLength) - let status = withUnsafePointers(key, iv, aData, data, &result, &tag, { - keyBytes, ivBytes, aDataBytes, dataBytes, resultBytes, tagBytes in - return CCCryptorGCM!(opMode.rawValue, algorithm.rawValue, - keyBytes, key.count, ivBytes, iv.count, - aDataBytes, aData.count, - dataBytes, data.count, - resultBytes, tagBytes, &tagLength_) - }) - guard status == noErr else { throw CCError(status) } - - tag.count = tagLength_ - return (result, tag) - } - - public static func available() -> Bool { - if CCCryptorGCM != nil { - return true - } - return false - } - - fileprivate typealias CCCryptorGCMT = @convention(c) (_ op: CCOperation, _ alg: CCAlgorithm, - _ key: UnsafeRawPointer, _ keyLength: Int, - _ iv: UnsafeRawPointer, _ ivLen: Int, - _ aData: UnsafeRawPointer, _ aDataLen: Int, - _ dataIn: UnsafeRawPointer, _ dataInLength: Int, - _ dataOut: UnsafeMutableRawPointer, - _ tag: UnsafeRawPointer, _ tagLength: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCCryptorGCM: CCCryptorGCMT? = getFunc(dl!, f: "CCCryptorGCM") - - } - - open class CCM { - - public static func crypt(_ opMode: OpMode, algorithm: Algorithm, data: Data, - key: Data, iv: Data, - aData: Data, tagLength: Int) throws -> (Data, Data) { - var cryptor: CCCryptorRef? = nil - var status = key.withUnsafeBytes { keyBytes in - return CCCryptorCreateWithMode!( - opMode.rawValue, AuthBlockMode.ccm.rawValue, - algorithm.rawValue, Padding.noPadding.rawValue, - nil, keyBytes, key.count, nil, 0, - 0, CCModeOptions(), &cryptor) - } - guard status == noErr else { throw CCError(status) } - defer { _ = CCCryptorRelease!(cryptor!) } - - status = CCCryptorAddParameter!(cryptor!, - Parameter.dataSize.rawValue, nil, data.count) - guard status == noErr else { throw CCError(status) } - - status = CCCryptorAddParameter!(cryptor!, Parameter.macSize.rawValue, nil, tagLength) - guard status == noErr else { throw CCError(status) } - - status = iv.withUnsafeBytes { ivBytes in - return CCCryptorAddParameter!(cryptor!, Parameter.iv.rawValue, ivBytes, iv.count) - } - guard status == noErr else { throw CCError(status) } - - status = aData.withUnsafeBytes { aDataBytes in - return CCCryptorAddParameter!(cryptor!, Parameter.authData.rawValue, aDataBytes, aData.count) - } - guard status == noErr else { throw CCError(status) } - - var result = Data(count: data.count) - let rescount = result.count - var updateLen: size_t = 0 - status = withUnsafePointers(data, &result, { dataBytes, resultBytes in - return CCCryptorUpdate!( - cryptor!, dataBytes, data.count, - resultBytes, rescount, - &updateLen) - }) - guard status == noErr else { throw CCError(status) } - - var finalLen: size_t = 0 - status = result.withUnsafeMutableBytes { resultBytes in - return CCCryptorFinal!(cryptor!, resultBytes + updateLen, - rescount - updateLen, - &finalLen) - } - guard status == noErr else { throw CCError(status) } - - result.count = updateLen + finalLen - - var tagLength_ = tagLength - var tag = Data(count: tagLength) - status = tag.withUnsafeMutableBytes { tagBytes in - return CCCryptorGetParameter!(cryptor!, Parameter.authTag.rawValue, - tagBytes, &tagLength_) - } - guard status == noErr else { throw CCError(status) } - - tag.count = tagLength_ - - return (result, tag) - } - - public static func available() -> Bool { - if CCCryptorAddParameter != nil && - CCCryptorGetParameter != nil { - return true - } - return false - } - - fileprivate typealias CCParameter = UInt32 - fileprivate enum Parameter: CCParameter { - case iv, authData, macSize, dataSize, authTag - } - fileprivate typealias CCCryptorAddParameterT = @convention(c) (_ cryptorRef: CCCryptorRef, - _ parameter: CCParameter, - _ data: UnsafeRawPointer?, _ dataLength: size_t) -> CCCryptorStatus - fileprivate static let CCCryptorAddParameter: CCCryptorAddParameterT? = - getFunc(dl!, f: "CCCryptorAddParameter") - - fileprivate typealias CCCryptorGetParameterT = @convention(c) (_ cryptorRef: CCCryptorRef, - _ parameter: CCParameter, - _ data: UnsafeRawPointer, _ dataLength: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCCryptorGetParameter: CCCryptorGetParameterT? = - getFunc(dl!, f: "CCCryptorGetParameter") - } - - open class RSA { - - public typealias CCAsymmetricPadding = UInt32 - - public enum AsymmetricPadding: CCAsymmetricPadding { - case pkcs1 = 1001 - case oaep = 1002 - } - - public enum AsymmetricSAPadding: UInt32 { - case pkcs15 = 1001 - case pss = 1002 - } - - public static func generateKeyPair(_ keySize: Int = 4096) throws -> (Data, Data) { - var privateKey: CCRSACryptorRef? = nil - var publicKey: CCRSACryptorRef? = nil - let status = CCRSACryptorGeneratePair!( - keySize, - 65537, - &publicKey, - &privateKey) - guard status == noErr else { throw CCError(status) } - - defer { - CCRSACryptorRelease!(privateKey!) - CCRSACryptorRelease!(publicKey!) - } - - let privDERKey = try exportToDERKey(privateKey!) - let pubDERKey = try exportToDERKey(publicKey!) - - return (privDERKey, pubDERKey) - } - - public static func getPublicKeyFromPrivateKey(_ derKey: Data) throws -> Data { - let key = try importFromDERKey(derKey) - defer { CCRSACryptorRelease!(key) } - - guard getKeyType(key) == .privateKey else { throw CCError(.paramError) } - - let publicKey = CCRSACryptorGetPublicKeyFromPrivateKey!(key) - defer { CCRSACryptorRelease!(publicKey) } - - let pubDERKey = try exportToDERKey(publicKey) - - return pubDERKey - } - - public static func encrypt(_ data: Data, derKey: Data, tag: Data, - padding: AsymmetricPadding, - digest: DigestAlgorithm) throws -> Data { - let key = try importFromDERKey(derKey) - defer { CCRSACryptorRelease!(key) } - - var bufferSize = getKeySize(key) - var buffer = Data(count: bufferSize) - - let status = withUnsafePointers(data, tag, &buffer, { - dataBytes, tagBytes, bufferBytes in - return CCRSACryptorEncrypt!( - key, - padding.rawValue, - dataBytes, data.count, - bufferBytes, &bufferSize, - tagBytes, tag.count, - digest.rawValue) - }) - guard status == noErr else { throw CCError(status) } - - buffer.count = bufferSize - - return buffer - } - - public static func decrypt(_ data: Data, derKey: Data, tag: Data, - padding: AsymmetricPadding, - digest: DigestAlgorithm) throws -> (Data, Int) { - let key = try importFromDERKey(derKey) - defer { CCRSACryptorRelease!(key) } - - let blockSize = getKeySize(key) - - var bufferSize = blockSize - var buffer = Data(count: bufferSize) - - let status = withUnsafePointers(data, tag, &buffer, { - dataBytes, tagBytes, bufferBytes in - return CCRSACryptorDecrypt!( - key, - padding.rawValue, - dataBytes, data.count, - bufferBytes, &bufferSize, - tagBytes, tag.count, - digest.rawValue) - }) - guard status == noErr else { throw CCError(status) } - buffer.count = bufferSize - - return (buffer, blockSize) - } - - fileprivate static func importFromDERKey(_ derKey: Data) throws -> CCRSACryptorRef { - var key: CCRSACryptorRef? = nil - let status = derKey.withUnsafeBytes { derKeyBytes in - return CCRSACryptorImport!( - derKeyBytes, - derKey.count, - &key) - } - guard status == noErr else { throw CCError(status) } - - return key! - } - - fileprivate static func exportToDERKey(_ key: CCRSACryptorRef) throws -> Data { - var derKeyLength = 8192 - var derKey = Data(count: derKeyLength) - let status = derKey.withUnsafeMutableBytes { derKeyBytes in - return CCRSACryptorExport!(key, derKeyBytes, &derKeyLength) - } - guard status == noErr else { throw CCError(status) } - - derKey.count = derKeyLength - return derKey - } - - fileprivate static func getKeyType(_ key: CCRSACryptorRef) -> KeyType { - return KeyType(rawValue: CCRSAGetKeyType!(key))! - } - - fileprivate static func getKeySize(_ key: CCRSACryptorRef) -> Int { - return Int(CCRSAGetKeySize!(key)/8) - } - - public static func sign(_ message: Data, derKey: Data, padding: AsymmetricSAPadding, - digest: DigestAlgorithm, saltLen: Int) throws -> Data { - let key = try importFromDERKey(derKey) - defer { CCRSACryptorRelease!(key) } - guard getKeyType(key) == .privateKey else { throw CCError(.paramError) } - - let keySize = getKeySize(key) - - switch padding { - case .pkcs15: - let hash = CC.digest(message, alg: digest) - var signedDataLength = keySize - var signedData = Data(count:signedDataLength) - let status = withUnsafePointers(hash, &signedData, { - hashBytes, signedDataBytes in - return CCRSACryptorSign!( - key, - AsymmetricPadding.pkcs1.rawValue, - hashBytes, hash.count, - digest.rawValue, 0 /*unused*/, - signedDataBytes, &signedDataLength) - }) - guard status == noErr else { throw CCError(status) } - - signedData.count = signedDataLength - return signedData - case .pss: - let encMessage = try add_pss_padding( - digest, - saltLength: saltLen, - keyLength: keySize, - message: message) - return try crypt(encMessage, key: key) - } - } - - public static func verify(_ message: Data, derKey: Data, padding: AsymmetricSAPadding, - digest: DigestAlgorithm, saltLen: Int, - signedData: Data) throws -> Bool { - let key = try importFromDERKey(derKey) - defer { CCRSACryptorRelease!(key) } - guard getKeyType(key) == .publicKey else { throw CCError(.paramError) } - - let keySize = getKeySize(key) - - switch padding { - case .pkcs15: - let hash = CC.digest(message, alg: digest) - let status = withUnsafePointers(hash, signedData, { - hashBytes, signedDataBytes in - return CCRSACryptorVerify!( - key, - padding.rawValue, - hashBytes, hash.count, - digest.rawValue, 0 /*unused*/, - signedDataBytes, signedData.count) - }) - let kCCNotVerified: CCCryptorStatus = -4306 - if status == kCCNotVerified { - return false - } - guard status == noErr else { throw CCError(status) } - return true - case .pss: - let encoded = try crypt(signedData, key:key) - return try verify_pss_padding( - digest, - saltLength: saltLen, - keyLength: keySize, - message: message, - encMessage: encoded) - } - } - - fileprivate static func crypt(_ data: Data, key: CCRSACryptorRef) throws -> Data { - var outLength = data.count - var out = Data(count: outLength) - - let status = withUnsafePointers(data, &out, { dataBytes, outBytes in - return CCRSACryptorCrypt!( - key, - dataBytes, data.count, - outBytes, &outLength) - }) - - guard status == noErr else { throw CCError(status) } - out.count = outLength - - return out - } - - fileprivate static func mgf1(_ digest: DigestAlgorithm, - seed: Data, maskLength: Int) -> Data { - var tseed = seed - tseed.append(contentsOf: [0,0,0,0] as [UInt8]) - - var interval = maskLength / digest.length - if maskLength % digest.length != 0 { - interval += 1 - } - - func pack(_ n: Int) -> [UInt8] { - return [ - UInt8(n>>24 & 0xff), - UInt8(n>>16 & 0xff), - UInt8(n>>8 & 0xff), - UInt8(n>>0 & 0xff) - ] - } - - var mask = Data() - for counter in 0 ..< interval { - tseed.replaceSubrange((tseed.count - 4) ..< tseed.count, with: pack(counter)) - mask.append(CC.digest(tseed, alg: digest)) - } - mask.count = maskLength - return mask - } - - fileprivate static func xorData(_ data1: Data, _ data2: Data) -> Data { - precondition(data1.count == data2.count) - - var ret = Data(count: data1.count) - let retcount = ret.count - withUnsafePointers(data1, data2, &ret, {( - b1: UnsafePointer, - b2: UnsafePointer, - r: UnsafeMutablePointer) in - for i in 0 ..< retcount { - r[i] = b1[i] ^ b2[i] - } - }) - return ret - } - - fileprivate static func add_pss_padding(_ digest: DigestAlgorithm, - saltLength: Int, - keyLength: Int, - message: Data) throws -> Data { - - if keyLength < 16 || saltLength < 0 { - throw CCError(.paramError) - } - - // The maximal bit size of a non-negative integer is one less than the bit - // size of the key since the first bit is used to store sign - let emBits = keyLength * 8 - 1 - var emLength = emBits / 8 - if emBits % 8 != 0 { - emLength += 1 - } - - let hash = CC.digest(message, alg: digest) - - if emLength < hash.count + saltLength + 2 { - throw CCError(.paramError) - } - - let salt = CC.generateRandom(saltLength) - - var mPrime = Data(count: 8) - mPrime.append(hash) - mPrime.append(salt) - let mPrimeHash = CC.digest(mPrime, alg: digest) - - let padding = Data(count: emLength - saltLength - hash.count - 2) - var db = padding - db.append([0x01] as [UInt8], count: 1) - db.append(salt) - let dbMask = mgf1(digest, seed: mPrimeHash, maskLength: emLength - hash.count - 1) - var maskedDB = xorData(db, dbMask) - - let zeroBits = 8 * emLength - emBits - maskedDB.withUnsafeMutableBytes { maskedDBBytes in - maskedDBBytes[0] &= 0xff >> UInt8(zeroBits) - } - - var ret = maskedDB - ret.append(mPrimeHash) - ret.append([0xBC] as [UInt8], count: 1) - return ret - } - - fileprivate static func verify_pss_padding(_ digest: DigestAlgorithm, - saltLength: Int, keyLength: Int, - message: Data, - encMessage: Data) throws -> Bool { - if keyLength < 16 || saltLength < 0 { - throw CCError(.paramError) - } - - guard encMessage.count > 0 else { - return false - } - - let emBits = keyLength * 8 - 1 - var emLength = emBits / 8 - if emBits % 8 != 0 { - emLength += 1 - } - - let hash = CC.digest(message, alg: digest) - - if emLength < hash.count + saltLength + 2 { - return false - } - if encMessage.bytesView[encMessage.count-1] != 0xBC { - return false - } - let zeroBits = 8 * emLength - emBits - let zeroBitsM = 8 - zeroBits - let maskedDBLength = emLength - hash.count - 1 - let maskedDB = encMessage.subdata(in: 0..> zeroBitsM != 0 { - return false - } - let mPrimeHash = encMessage.subdata(in: maskedDBLength ..< maskedDBLength + hash.count) - let dbMask = mgf1(digest, seed: mPrimeHash, maskLength: emLength - hash.count - 1) - var db = xorData(maskedDB, dbMask) - db.withUnsafeMutableBytes { dbBytes in - dbBytes[0] &= 0xff >> UInt8(zeroBits) - } - - let zeroLength = emLength - hash.count - saltLength - 2 - let zeroString = Data(count:zeroLength) - if db.subdata(in: 0 ..< zeroLength) != zeroString { - return false - } - if db.bytesView[zeroLength] != 0x01 { - return false - } - let salt = db.subdata(in: (db.count - saltLength) ..< db.count) - var mPrime = Data(count:8) - mPrime.append(hash) - mPrime.append(salt) - let mPrimeHash2 = CC.digest(mPrime, alg: digest) - if mPrimeHash != mPrimeHash2 { - return false - } - return true - } - - - public static func available() -> Bool { - return CCRSACryptorGeneratePair != nil && - CCRSACryptorGetPublicKeyFromPrivateKey != nil && - CCRSACryptorRelease != nil && - CCRSAGetKeyType != nil && - CCRSAGetKeySize != nil && - CCRSACryptorEncrypt != nil && - CCRSACryptorDecrypt != nil && - CCRSACryptorExport != nil && - CCRSACryptorImport != nil && - CCRSACryptorSign != nil && - CCRSACryptorVerify != nil && - CCRSACryptorCrypt != nil - } - - fileprivate typealias CCRSACryptorRef = UnsafeRawPointer - fileprivate typealias CCRSAKeyType = UInt32 - fileprivate enum KeyType: CCRSAKeyType { - case publicKey = 0, privateKey - case blankPublicKey = 97, blankPrivateKey - case badKey = 99 - } - - fileprivate typealias CCRSACryptorGeneratePairT = @convention(c) ( - _ keySize: Int, - _ e: UInt32, - _ publicKey: UnsafeMutablePointer, - _ privateKey: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCRSACryptorGeneratePair: CCRSACryptorGeneratePairT? = - getFunc(CC.dl!, f: "CCRSACryptorGeneratePair") - - fileprivate typealias CCRSACryptorGetPublicKeyFromPrivateKeyT = @convention(c) (CCRSACryptorRef) -> CCRSACryptorRef - fileprivate static let CCRSACryptorGetPublicKeyFromPrivateKey: CCRSACryptorGetPublicKeyFromPrivateKeyT? = - getFunc(CC.dl!, f: "CCRSACryptorGetPublicKeyFromPrivateKey") - - fileprivate typealias CCRSACryptorReleaseT = @convention(c) (CCRSACryptorRef) -> Void - fileprivate static let CCRSACryptorRelease: CCRSACryptorReleaseT? = - getFunc(dl!, f: "CCRSACryptorRelease") - - fileprivate typealias CCRSAGetKeyTypeT = @convention(c) (CCRSACryptorRef) -> CCRSAKeyType - fileprivate static let CCRSAGetKeyType: CCRSAGetKeyTypeT? = getFunc(dl!, f: "CCRSAGetKeyType") - - fileprivate typealias CCRSAGetKeySizeT = @convention(c) (CCRSACryptorRef) -> Int32 - fileprivate static let CCRSAGetKeySize: CCRSAGetKeySizeT? = getFunc(dl!, f: "CCRSAGetKeySize") - - fileprivate typealias CCRSACryptorEncryptT = @convention(c) ( - _ publicKey: CCRSACryptorRef, - _ padding: CCAsymmetricPadding, - _ plainText: UnsafeRawPointer, - _ plainTextLen: Int, - _ cipherText: UnsafeMutableRawPointer, - _ cipherTextLen: UnsafeMutablePointer, - _ tagData: UnsafeRawPointer, - _ tagDataLen: Int, - _ digestType: CCDigestAlgorithm) -> CCCryptorStatus - fileprivate static let CCRSACryptorEncrypt: CCRSACryptorEncryptT? = - getFunc(dl!, f: "CCRSACryptorEncrypt") - - fileprivate typealias CCRSACryptorDecryptT = @convention (c) ( - _ privateKey: CCRSACryptorRef, - _ padding: CCAsymmetricPadding, - _ cipherText: UnsafeRawPointer, - _ cipherTextLen: Int, - _ plainText: UnsafeMutableRawPointer, - _ plainTextLen: UnsafeMutablePointer, - _ tagData: UnsafeRawPointer, - _ tagDataLen: Int, - _ digestType: CCDigestAlgorithm) -> CCCryptorStatus - fileprivate static let CCRSACryptorDecrypt: CCRSACryptorDecryptT? = - getFunc(dl!, f: "CCRSACryptorDecrypt") - - fileprivate typealias CCRSACryptorExportT = @convention(c) ( - _ key: CCRSACryptorRef, - _ out: UnsafeMutableRawPointer, - _ outLen: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCRSACryptorExport: CCRSACryptorExportT? = - getFunc(dl!, f: "CCRSACryptorExport") - - fileprivate typealias CCRSACryptorImportT = @convention(c) ( - _ keyPackage: UnsafeRawPointer, - _ keyPackageLen: Int, - _ key: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCRSACryptorImport: CCRSACryptorImportT? = - getFunc(dl!, f: "CCRSACryptorImport") - - fileprivate typealias CCRSACryptorSignT = @convention(c) ( - _ privateKey: CCRSACryptorRef, - _ padding: CCAsymmetricPadding, - _ hashToSign: UnsafeRawPointer, - _ hashSignLen: size_t, - _ digestType: CCDigestAlgorithm, - _ saltLen: size_t, - _ signedData: UnsafeMutableRawPointer, - _ signedDataLen: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCRSACryptorSign: CCRSACryptorSignT? = - getFunc(dl!, f: "CCRSACryptorSign") - - fileprivate typealias CCRSACryptorVerifyT = @convention(c) ( - _ publicKey: CCRSACryptorRef, - _ padding: CCAsymmetricPadding, - _ hash: UnsafeRawPointer, - _ hashLen: size_t, - _ digestType: CCDigestAlgorithm, - _ saltLen: size_t, - _ signedData: UnsafeRawPointer, - _ signedDataLen: size_t) -> CCCryptorStatus - fileprivate static let CCRSACryptorVerify: CCRSACryptorVerifyT? = - getFunc(dl!, f: "CCRSACryptorVerify") - - fileprivate typealias CCRSACryptorCryptT = @convention(c) ( - _ rsaKey: CCRSACryptorRef, - _ data: UnsafeRawPointer, _ dataLength: size_t, - _ out: UnsafeMutableRawPointer, - _ outLength: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCRSACryptorCrypt: CCRSACryptorCryptT? = - getFunc(dl!, f: "CCRSACryptorCrypt") - } - - open class DH { - - public enum DHParam { - case rfc3526Group5 - case rfc2409Group2 - } - - // this is stateful in CommonCrypto too, sry - open class DH { - fileprivate var ref: CCDHRef? = nil - - public init(dhParam: DHParam) throws { - if dhParam == .rfc3526Group5 { - ref = CCDHCreate!(kCCDHRFC3526Group5!) - } else { - ref = CCDHCreate!(kCCDHRFC2409Group2!) - } - guard ref != nil else { - throw CCError(.paramError) - } - } - - open func generateKey() throws -> Data { - var outputLength = 8192 - var output = Data(count: outputLength) - let status = output.withUnsafeMutableBytes { outputBytes in - return CCDHGenerateKey!(ref!, outputBytes, &outputLength) - } - output.count = outputLength - guard status != -1 else { - throw CCError(.paramError) - } - return output - } - - open func computeKey(_ peerKey: Data) throws -> Data { - var sharedKeyLength = 8192 - var sharedKey = Data(count: sharedKeyLength) - let status = withUnsafePointers(peerKey, &sharedKey, { - peerKeyBytes, sharedKeyBytes in - return CCDHComputeKey!( - sharedKeyBytes, &sharedKeyLength, - peerKeyBytes, peerKey.count, - ref!) - }) - sharedKey.count = sharedKeyLength - guard status == 0 else { - throw CCError(.paramError) - } - return sharedKey - } - - deinit { - if ref != nil { - CCDHRelease!(ref!) - } - } - } - - - public static func available() -> Bool { - return CCDHCreate != nil && - CCDHRelease != nil && - CCDHGenerateKey != nil && - CCDHComputeKey != nil && - CCDHParametersCreateFromData != nil && - CCDHParametersRelease != nil - } - - fileprivate typealias CCDHParameters = UnsafeRawPointer - fileprivate typealias CCDHRef = UnsafeRawPointer - - fileprivate typealias kCCDHRFC3526Group5TM = UnsafePointer - fileprivate static let kCCDHRFC3526Group5M: kCCDHRFC3526Group5TM? = - getFunc(dl!, f: "kCCDHRFC3526Group5") - fileprivate static let kCCDHRFC3526Group5 = kCCDHRFC3526Group5M?.pointee - - fileprivate typealias kCCDHRFC2409Group2TM = UnsafePointer - fileprivate static let kCCDHRFC2409Group2M: kCCDHRFC2409Group2TM? = - getFunc(dl!, f: "kCCDHRFC2409Group2") - fileprivate static let kCCDHRFC2409Group2 = kCCDHRFC2409Group2M?.pointee - - fileprivate typealias CCDHCreateT = @convention(c) ( - _ dhParameter: CCDHParameters) -> CCDHRef - fileprivate static let CCDHCreate: CCDHCreateT? = getFunc(dl!, f: "CCDHCreate") - - fileprivate typealias CCDHReleaseT = @convention(c) ( - _ ref: CCDHRef) -> Void - fileprivate static let CCDHRelease: CCDHReleaseT? = getFunc(dl!, f: "CCDHRelease") - - fileprivate typealias CCDHGenerateKeyT = @convention(c) ( - _ ref: CCDHRef, - _ output: UnsafeMutableRawPointer, _ outputLength: UnsafeMutablePointer) -> CInt - fileprivate static let CCDHGenerateKey: CCDHGenerateKeyT? = getFunc(dl!, f: "CCDHGenerateKey") - - fileprivate typealias CCDHComputeKeyT = @convention(c) ( - _ sharedKey: UnsafeMutableRawPointer, _ sharedKeyLen: UnsafeMutablePointer, - _ peerPubKey: UnsafeRawPointer, _ peerPubKeyLen: size_t, - _ ref: CCDHRef) -> CInt - fileprivate static let CCDHComputeKey: CCDHComputeKeyT? = getFunc(dl!, f: "CCDHComputeKey") - - fileprivate typealias CCDHParametersCreateFromDataT = @convention(c) ( - _ p: UnsafeRawPointer, _ pLen: Int, - _ g: UnsafeRawPointer, _ gLen: Int, - _ l: Int) -> CCDHParameters - fileprivate static let CCDHParametersCreateFromData: CCDHParametersCreateFromDataT? = getFunc(dl!, f: "CCDHParametersCreateFromData") - - fileprivate typealias CCDHParametersReleaseT = @convention(c) ( - _ parameters: CCDHParameters) -> Void - fileprivate static let CCDHParametersRelease: CCDHParametersReleaseT? = getFunc(dl!, f: "CCDHParametersRelease") - } - - open class EC { - - public static func generateKeyPair(_ keySize: Int) throws -> (Data, Data) { - var privKey: CCECCryptorRef? = nil - var pubKey: CCECCryptorRef? = nil - let status = CCECCryptorGeneratePair!( - keySize, - &pubKey, - &privKey) - guard status == noErr else { throw CCError(status) } - - defer { - CCECCryptorRelease!(privKey!) - CCECCryptorRelease!(pubKey!) - } - - let privKeyDER = try exportKey(privKey!, format: .binary, type: .keyPrivate) - let pubKeyDER = try exportKey(pubKey!, format: .binary, type: .keyPublic) - return (privKeyDER, pubKeyDER) - } - - public static func getPublicKeyFromPrivateKey(_ privateKey: Data) throws -> Data { - let privKey = try importKey(privateKey, format: .binary, keyType: .keyPrivate) - defer { CCECCryptorRelease!(privKey) } - - let pubKey = CCECCryptorGetPublicKeyFromPrivateKey!(privKey) - defer { CCECCryptorRelease!(pubKey) } - - let pubKeyDER = try exportKey(pubKey, format: .binary, type: .keyPublic) - return pubKeyDER - } - - public static func signHash(_ privateKey: Data, hash: Data) throws -> Data { - let privKey = try importKey(privateKey, format: .binary, keyType: .keyPrivate) - defer { CCECCryptorRelease!(privKey) } - - var signedDataLength = 4096 - var signedData = Data(count:signedDataLength) - let status = withUnsafePointers(hash, &signedData, { - hashBytes, signedDataBytes in - return CCECCryptorSignHash!( - privKey, - hashBytes, hash.count, - signedDataBytes, &signedDataLength) - }) - guard status == noErr else { throw CCError(status) } - - signedData.count = signedDataLength - return signedData - } - - public static func verifyHash(_ publicKey: Data, - hash: Data, - signedData: Data) throws -> Bool { - let pubKey = try importKey(publicKey, format: .binary, keyType: .keyPublic) - defer { CCECCryptorRelease!(pubKey) } - - var valid: UInt32 = 0 - let status = withUnsafePointers(hash, signedData, { hashBytes, signedDataBytes in - return CCECCryptorVerifyHash!( - pubKey, - hashBytes, hash.count, - signedDataBytes, signedData.count, - &valid) - }) - guard status == noErr else { throw CCError(status) } - - return valid != 0 - } - - public static func computeSharedSecret(_ privateKey: Data, - publicKey: Data) throws -> Data { - let privKey = try importKey(privateKey, format: .binary, keyType: .keyPrivate) - let pubKey = try importKey(publicKey, format: .binary, keyType: .keyPublic) - defer { - CCECCryptorRelease!(privKey) - CCECCryptorRelease!(pubKey) - } - - var outSize = 8192 - var result = Data(count:outSize) - let status = result.withUnsafeMutableBytes { resultBytes in - return CCECCryptorComputeSharedSecret!(privKey, pubKey, resultBytes, &outSize) - } - guard status == noErr else { throw CCError(status) } - - result.count = outSize - return result - } - - public struct KeyComponents { - public init(_ keySize: Int, _ x: Data, _ y: Data, _ d: Data) { - self.keySize = keySize - self.x = x - self.y = y - self.d = d - } - public var keySize: Int - public var x: Data - public var y: Data - public var d: Data - } - - public static func getPublicKeyComponents(_ keyData: Data) throws -> KeyComponents { - let key = try importKey(keyData, format: .binary, keyType: .keyPublic) - defer { CCECCryptorRelease!(key) } - return try getKeyComponents(key) - } - - public static func getPrivateKeyComponents(_ keyData: Data) throws -> KeyComponents { - let key = try importKey(keyData, format: .binary, keyType: .keyPrivate) - defer { CCECCryptorRelease!(key) } - return try getKeyComponents(key) - } - - fileprivate static func getKeyComponents(_ key: CCECCryptorRef) throws -> KeyComponents { - var keySize = 0, xSize = 8192, ySize = 8192, dSize = 8192 - var x = Data(count: xSize), y = Data(count: ySize), d = Data(count: dSize) - let status = withUnsafePointers(&x, &y, &d, { xBytes, yBytes, dBytes in - return CCECCryptorGetKeyComponents!(key, &keySize, - xBytes, &xSize, - yBytes, &ySize, - dBytes, &dSize) - }) - guard status == noErr else { throw CCError(status) } - - x.count = xSize - y.count = ySize - d.count = dSize - if getKeyType(key) == .keyPublic { - d.count = 0 - } - - return KeyComponents(keySize, x, y, d) - } - - public static func createFromData(_ keySize: size_t, _ x: Data, _ y: Data) throws -> Data { - var pubKey: CCECCryptorRef? = nil - - let status = withUnsafePointers(x, y, { xBytes, yBytes in - return CCECCryptorCreateFromData!(keySize, xBytes, x.count, - yBytes, y.count, &pubKey) - }) - guard status == noErr else { throw CCError(status) } - defer { CCECCryptorRelease!(pubKey!) } - - let pubKeyBin = try exportKey(pubKey!, format: .binary, type: .keyPublic) - return pubKeyBin - } - - fileprivate static func importKey(_ key: Data, format: KeyExternalFormat, - keyType: KeyType) throws -> CCECCryptorRef { - var impKey: CCECCryptorRef? = nil - let status = key.withUnsafeBytes { keyBytes in - return CCECCryptorImportKey!(format.rawValue, - keyBytes, key.count, - keyType.rawValue, &impKey) - } - guard status == noErr else { throw CCError(status) } - - return impKey! - } - - fileprivate static func exportKey(_ key: CCECCryptorRef, format: KeyExternalFormat, - type: KeyType) throws -> Data { - var expKeyLength = 8192 - var expKey = Data(count:expKeyLength) - let status = expKey.withUnsafeMutableBytes { expKeyBytes in - return CCECCryptorExportKey!( - format.rawValue, - expKeyBytes, - &expKeyLength, - type.rawValue, - key) - } - guard status == noErr else { throw CCError(status) } - - expKey.count = expKeyLength - return expKey - } - - fileprivate static func getKeyType(_ key: CCECCryptorRef) -> KeyType { - return KeyType(rawValue: CCECGetKeyType!(key))! - } - - public static func available() -> Bool { - return CCECCryptorGeneratePair != nil && - CCECCryptorImportKey != nil && - CCECCryptorExportKey != nil && - CCECCryptorRelease != nil && - CCECCryptorSignHash != nil && - CCECCryptorVerifyHash != nil && - CCECCryptorComputeSharedSecret != nil && - CCECCryptorGetKeyComponents != nil && - CCECCryptorCreateFromData != nil && - CCECGetKeyType != nil && - CCECCryptorGetPublicKeyFromPrivateKey != nil - } - - fileprivate enum KeyType: CCECKeyType { - case keyPublic = 0, keyPrivate - case blankPublicKey = 97, blankPrivateKey - case badKey = 99 - } - fileprivate typealias CCECKeyType = UInt32 - - fileprivate typealias CCECKeyExternalFormat = UInt32 - fileprivate enum KeyExternalFormat: CCECKeyExternalFormat { - case binary = 0, der - } - - fileprivate typealias CCECCryptorRef = UnsafeRawPointer - fileprivate typealias CCECCryptorGeneratePairT = @convention(c) ( - _ keySize: size_t , - _ publicKey: UnsafeMutablePointer, - _ privateKey: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCECCryptorGeneratePair: CCECCryptorGeneratePairT? = - getFunc(dl!, f: "CCECCryptorGeneratePair") - - fileprivate typealias CCECCryptorImportKeyT = @convention(c) ( - _ format: CCECKeyExternalFormat, - _ keyPackage: UnsafeRawPointer, _ keyPackageLen: size_t, - _ keyType: CCECKeyType, _ key: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCECCryptorImportKey: CCECCryptorImportKeyT? = - getFunc(dl!, f: "CCECCryptorImportKey") - - fileprivate typealias CCECCryptorExportKeyT = @convention(c) ( - _ format: CCECKeyExternalFormat, - _ keyPackage: UnsafeRawPointer, - _ keyPackageLen: UnsafePointer, - _ keyType: CCECKeyType, _ key: CCECCryptorRef) -> CCCryptorStatus - fileprivate static let CCECCryptorExportKey: CCECCryptorExportKeyT? = - getFunc(dl!, f: "CCECCryptorExportKey") - - fileprivate typealias CCECCryptorReleaseT = @convention(c) ( - _ key: CCECCryptorRef) -> Void - fileprivate static let CCECCryptorRelease: CCECCryptorReleaseT? = - getFunc(dl!, f: "CCECCryptorRelease") - - fileprivate typealias CCECCryptorSignHashT = @convention(c)( - _ privateKey: CCECCryptorRef, - _ hashToSign: UnsafeRawPointer, - _ hashSignLen: size_t, - _ signedData: UnsafeMutableRawPointer, - _ signedDataLen: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCECCryptorSignHash: CCECCryptorSignHashT? = - getFunc(dl!, f: "CCECCryptorSignHash") - - fileprivate typealias CCECCryptorVerifyHashT = @convention(c)( - _ publicKey: CCECCryptorRef, - _ hash: UnsafeRawPointer, _ hashLen: size_t, - _ signedData: UnsafeRawPointer, _ signedDataLen: size_t, - _ valid: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCECCryptorVerifyHash: CCECCryptorVerifyHashT? = - getFunc(dl!, f: "CCECCryptorVerifyHash") - - fileprivate typealias CCECCryptorComputeSharedSecretT = @convention(c)( - _ privateKey: CCECCryptorRef, - _ publicKey: CCECCryptorRef, - _ out: UnsafeMutableRawPointer, - _ outLen: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCECCryptorComputeSharedSecret: CCECCryptorComputeSharedSecretT? = - getFunc(dl!, f: "CCECCryptorComputeSharedSecret") - - fileprivate typealias CCECCryptorGetKeyComponentsT = @convention(c)( - _ ecKey: CCECCryptorRef, - _ keySize: UnsafeMutablePointer, - _ qX: UnsafeMutableRawPointer, - _ qXLength: UnsafeMutablePointer, - _ qY: UnsafeMutableRawPointer, - _ qYLength: UnsafeMutablePointer, - _ d: UnsafeMutableRawPointer?, - _ dLength: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCECCryptorGetKeyComponents: CCECCryptorGetKeyComponentsT? = - getFunc(dl!, f: "CCECCryptorGetKeyComponents") - - fileprivate typealias CCECCryptorCreateFromDataT = @convention(c)( - _ keySize: size_t, - _ qX: UnsafeRawPointer, - _ qXLength: size_t, - _ qY: UnsafeRawPointer, - _ qYLength: size_t, - _ publicKey: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CCECCryptorCreateFromData: CCECCryptorCreateFromDataT? = - getFunc(dl!, f: "CCECCryptorCreateFromData") - - fileprivate typealias CCECGetKeyTypeT = @convention(c) ( - _ key: CCECCryptorRef) -> CCECKeyType - fileprivate static let CCECGetKeyType: CCECGetKeyTypeT? = - getFunc(dl!, f: "CCECGetKeyType") - - fileprivate typealias CCECCryptorGetPublicKeyFromPrivateKeyT = @convention(c) ( - _ key: CCECCryptorRef) -> CCECCryptorRef - fileprivate static let CCECCryptorGetPublicKeyFromPrivateKey: CCECCryptorGetPublicKeyFromPrivateKeyT? = - getFunc(dl!, f: "CCECCryptorGetPublicKeyFromPrivateKey") - } - - open class CRC { - - public typealias CNcrc = UInt32 - public enum Mode: CNcrc { - case crc8 = 10, - crc8ICODE = 11, - crc8ITU = 12, - crc8ROHC = 13, - crc8WCDMA = 14, - crc16 = 20, - crc16CCITTTrue = 21, - crc16CCITTFalse = 22, - crc16USB = 23, - crc16XMODEM = 24, - crc16DECTR = 25, - crc16DECTX = 26, - crc16ICODE = 27, - crc16VERIFONE = 28, - crc16A = 29, - crc16B = 30, - crc16Fletcher = 31, - crc32Adler = 40, - crc32 = 41, - crc32CASTAGNOLI = 42, - crc32BZIP2 = 43, - crc32MPEG2 = 44, - crc32POSIX = 45, - crc32XFER = 46, - crc64ECMA182 = 60 - } - - public static func crc(_ input: Data, mode: Mode) throws -> UInt64 { - var result: UInt64 = 0 - let status = input.withUnsafeBytes { inputBytes in - return CNCRC!( - mode.rawValue, - inputBytes, input.count, - &result) - } - guard status == noErr else { - throw CCError(status) - } - return result - } - - public static func available() -> Bool { - return CNCRC != nil - } - - fileprivate typealias CNCRCT = @convention(c) ( - _ algorithm: CNcrc, - _ input: UnsafeRawPointer, _ inputLen: size_t, - _ result: UnsafeMutablePointer) -> CCCryptorStatus - fileprivate static let CNCRC: CNCRCT? = getFunc(dl!, f: "CNCRC") - } - - open class CMAC { - - public static func AESCMAC(_ data: Data, key: Data) -> Data { - var result = Data(count: 16) - withUnsafePointers(key, data, &result, { keyBytes, dataBytes, resultBytes in - CCAESCmac!(keyBytes, - dataBytes, data.count, - resultBytes) - }) - return result - } - - public static func available() -> Bool { - return CCAESCmac != nil - } - - fileprivate typealias CCAESCmacT = @convention(c) ( - _ key: UnsafeRawPointer, - _ data: UnsafeRawPointer, _ dataLen: size_t, - _ macOut: UnsafeMutableRawPointer) -> Void - fileprivate static let CCAESCmac: CCAESCmacT? = getFunc(dl!, f: "CCAESCmac") - } - - open class KeyDerivation { - - public typealias CCPseudoRandomAlgorithm = UInt32 - public enum PRFAlg: CCPseudoRandomAlgorithm { - case sha1 = 1, sha224, sha256, sha384, sha512 - var cc: CC.HMACAlg { - switch self { - case .sha1: return .sha1 - case .sha224: return .sha224 - case .sha256: return .sha256 - case .sha384: return .sha384 - case .sha512: return .sha512 - } - } - } - - public static func PBKDF2(_ password: String, salt: Data, - prf: PRFAlg, rounds: UInt32) throws -> Data { - - var result = Data(count:prf.cc.digestLength) - let rescount = result.count - let passwData = password.data(using: String.Encoding.utf8)! - let status = withUnsafePointers(passwData, salt, &result, { - passwDataBytes, saltBytes, resultBytes in - return CCKeyDerivationPBKDF!(PBKDFAlgorithm.pbkdf2.rawValue, - passwDataBytes, passwData.count, - saltBytes, salt.count, - prf.rawValue, rounds, - resultBytes, rescount) - }) - guard status == noErr else { throw CCError(status) } - - return result - } - - public static func available() -> Bool { - return CCKeyDerivationPBKDF != nil - } - - fileprivate typealias CCPBKDFAlgorithm = UInt32 - fileprivate enum PBKDFAlgorithm: CCPBKDFAlgorithm { - case pbkdf2 = 2 - } - - fileprivate typealias CCKeyDerivationPBKDFT = @convention(c) ( - _ algorithm: CCPBKDFAlgorithm, - _ password: UnsafeRawPointer, _ passwordLen: size_t, - _ salt: UnsafeRawPointer, _ saltLen: size_t, - _ prf: CCPseudoRandomAlgorithm, _ rounds: uint, - _ derivedKey: UnsafeMutableRawPointer, _ derivedKeyLen: size_t) -> CCCryptorStatus - fileprivate static let CCKeyDerivationPBKDF: CCKeyDerivationPBKDFT? = - getFunc(dl!, f: "CCKeyDerivationPBKDF") - } - - open class KeyWrap { - - fileprivate static let rfc3394IVData: [UInt8] = [0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6] - public static let rfc3394IV = Data(bytes: UnsafePointer(rfc3394IVData), count:rfc3394IVData.count) - - public static func SymmetricKeyWrap(_ iv: Data, - kek: Data, - rawKey: Data) throws -> Data { - let alg = WrapAlg.aes.rawValue - var wrappedKeyLength = CCSymmetricWrappedSize!(alg, rawKey.count) - var wrappedKey = Data(count:wrappedKeyLength) - let status = withUnsafePointers(iv, kek, rawKey, &wrappedKey, { - ivBytes, kekBytes, rawKeyBytes, wrappedKeyBytes in - return CCSymmetricKeyWrap!( - alg, - ivBytes, iv.count, - kekBytes, kek.count, - rawKeyBytes, rawKey.count, - wrappedKeyBytes, &wrappedKeyLength) - }) - guard status == noErr else { throw CCError(status) } - - wrappedKey.count = wrappedKeyLength - return wrappedKey - } - - public static func SymmetricKeyUnwrap(_ iv: Data, - kek: Data, - wrappedKey: Data) throws -> Data { - let alg = WrapAlg.aes.rawValue - var rawKeyLength = CCSymmetricUnwrappedSize!(alg, wrappedKey.count) - var rawKey = Data(count:rawKeyLength) - let status = withUnsafePointers(iv, kek, wrappedKey, &rawKey, { - ivBytes, kekBytes, wrappedKeyBytes, rawKeyBytes in - return CCSymmetricKeyUnwrap!( - alg, - ivBytes, iv.count, - kekBytes, kek.count, - wrappedKeyBytes, wrappedKey.count, - rawKeyBytes, &rawKeyLength) - }) - guard status == noErr else { throw CCError(status) } - - rawKey.count = rawKeyLength - return rawKey - } - - public static func available() -> Bool { - return CCSymmetricKeyWrap != nil && - CCSymmetricKeyUnwrap != nil && - CCSymmetricWrappedSize != nil && - CCSymmetricUnwrappedSize != nil - } - - fileprivate enum WrapAlg: CCWrappingAlgorithm { - case aes = 1 - } - fileprivate typealias CCWrappingAlgorithm = UInt32 - - fileprivate typealias CCSymmetricKeyWrapT = @convention(c) ( - _ algorithm: CCWrappingAlgorithm, - _ iv: UnsafeRawPointer, _ ivLen: size_t, - _ kek: UnsafeRawPointer, _ kekLen: size_t, - _ rawKey: UnsafeRawPointer, _ rawKeyLen: size_t, - _ wrappedKey: UnsafeMutableRawPointer, - _ wrappedKeyLen: UnsafePointer) -> CCCryptorStatus - fileprivate static let CCSymmetricKeyWrap: CCSymmetricKeyWrapT? = getFunc(dl!, f: "CCSymmetricKeyWrap") - - fileprivate typealias CCSymmetricKeyUnwrapT = @convention(c) ( - _ algorithm: CCWrappingAlgorithm, - _ iv: UnsafeRawPointer, _ ivLen: size_t, - _ kek: UnsafeRawPointer, _ kekLen: size_t, - _ wrappedKey: UnsafeRawPointer, _ wrappedKeyLen: size_t, - _ rawKey: UnsafeMutableRawPointer, - _ rawKeyLen: UnsafePointer) -> CCCryptorStatus - fileprivate static let CCSymmetricKeyUnwrap: CCSymmetricKeyUnwrapT? = - getFunc(dl!, f: "CCSymmetricKeyUnwrap") - - fileprivate typealias CCSymmetricWrappedSizeT = @convention(c) ( - _ algorithm: CCWrappingAlgorithm, - _ rawKeyLen: size_t) -> size_t - fileprivate static let CCSymmetricWrappedSize: CCSymmetricWrappedSizeT? = - getFunc(dl!, f: "CCSymmetricWrappedSize") - - fileprivate typealias CCSymmetricUnwrappedSizeT = @convention(c) ( - _ algorithm: CCWrappingAlgorithm, - _ wrappedKeyLen: size_t) -> size_t - fileprivate static let CCSymmetricUnwrappedSize: CCSymmetricUnwrappedSizeT? = - getFunc(dl!, f: "CCSymmetricUnwrappedSize") - - } - -} - -private func getFunc(_ from: UnsafeMutableRawPointer, f: String) -> T? { - let sym = dlsym(from, f) - guard sym != nil else { - return nil - } - return unsafeBitCast(sym, to: T.self) -} - -extension Data { - /// Create hexadecimal string representation of Data object. - /// - /// - returns: String representation of this Data object. - - public func hexadecimalString() -> String { - var hexstr = String() - self.withUnsafeBytes {(data: UnsafePointer) in - for i in UnsafeBufferPointer(start: data, count: count) { - hexstr += String(format: "%02X", i) - } - } - return hexstr - } - - public func arrayOfBytes() -> [UInt8] { - let count = self.count / MemoryLayout.size - var bytesArray = [UInt8](repeating: 0, count: count) - self.copyBytes(to: &bytesArray, count: count * MemoryLayout.size) - return bytesArray - } - - fileprivate var bytesView: BytesView { return BytesView(self) } - - fileprivate func bytesViewRange(_ range: NSRange) -> BytesView { - return BytesView(self, range: range) - } - - fileprivate struct BytesView: Collection { - // The view retains the Data. That's on purpose. - // Data doesn't retain the view, so there's no loop. - let data: Data - init(_ data: Data) { - self.data = data - self.startIndex = 0 - self.endIndex = data.count - } - - init(_ data: Data, range: NSRange ) { - self.data = data - self.startIndex = range.location - self.endIndex = range.location + range.length - } - - subscript (position: Int) -> UInt8 { - var value: UInt8 = 0 - data.withUnsafeBytes { dataBytes in - value = UnsafeBufferPointer(start: dataBytes, count: data.count)[position] - } - return value - } - subscript (bounds: Range) -> Data { - return data.subdata(in: bounds) - } - fileprivate func formIndex(after i: inout Int) { - i += 1 - } - fileprivate func index(after i: Int) -> Int { - return i + 1 - } - var startIndex: Int - var endIndex: Int - var length: Int { return endIndex - startIndex } - } -} - -extension String { - - /// Create Data from hexadecimal string representation - /// - /// This takes a hexadecimal representation and creates a Data object. Note, if the string has - /// any spaces, those are removed. Also if the string started with a '<' or ended with a '>', - /// those are removed, too. This does no validation of the string to ensure it's a valid - /// hexadecimal string - /// - /// The use of `strtoul` inspired by Martin R at http://stackoverflow.com/a/26284562/1271826 - /// - /// - returns: Data represented by this hexadecimal string. - /// Returns nil if string contains characters outside the 0-9 and a-f range. - - public func dataFromHexadecimalString() -> Data? { - let trimmedString = self.trimmingCharacters( - in: CharacterSet(charactersIn: "<> ")).replacingOccurrences( - of: " ", with: "") - - // make sure the cleaned up string consists solely of hex digits, - // and that we have even number of them - - let regex = try! NSRegularExpression(pattern: "^[0-9a-f]*$", options: .caseInsensitive) - - let found = regex.firstMatch(in: trimmedString, options: [], - range: NSRange(location: 0, - length: trimmedString.count)) - guard found != nil && - found?.range.location != NSNotFound && - trimmedString.count % 2 == 0 else { - return nil - } - - // everything ok, so now let's build Data - - var data = Data(capacity: trimmedString.count / 2) - var index: String.Index? = trimmedString.startIndex - - while let i = index { - let byteString = String(trimmedString[i ..< trimmedString.index(i, offsetBy: 2)]) - let num = UInt8(byteString.withCString { strtoul($0, nil, 16) }) - data.append([num] as [UInt8], count: 1) - - index = trimmedString.index(i, offsetBy: 2, limitedBy: trimmedString.endIndex) - if index == trimmedString.endIndex { break } - } - - return data - } -} - -fileprivate func withUnsafePointers( - _ arg0: Data, - _ arg1: Data, - _ body: ( - UnsafePointer, UnsafePointer) throws -> Result - ) rethrows -> Result { - return try arg0.withUnsafeBytes { p0 in - return try arg1.withUnsafeBytes { p1 in - return try body(p0, p1) - } - } -} - -fileprivate func withUnsafePointers( - _ arg0: Data, - _ arg1: inout Data, - _ body: ( - UnsafePointer, - UnsafeMutablePointer) throws -> Result - ) rethrows -> Result { - return try arg0.withUnsafeBytes { p0 in - return try arg1.withUnsafeMutableBytes { p1 in - return try body(p0, p1) - } - } -} - -fileprivate func withUnsafePointers( - _ arg0: Data, - _ arg1: Data, - _ arg2: inout Data, - _ body: ( - UnsafePointer, - UnsafePointer, - UnsafeMutablePointer) throws -> Result - ) rethrows -> Result { - return try arg0.withUnsafeBytes { p0 in - return try arg1.withUnsafeBytes { p1 in - return try arg2.withUnsafeMutableBytes { p2 in - return try body(p0, p1, p2) - } - } - } -} - -fileprivate func withUnsafePointers( - _ arg0: inout Data, - _ arg1: inout Data, - _ arg2: inout Data, - _ body: ( - UnsafeMutablePointer, - UnsafeMutablePointer, - UnsafeMutablePointer) throws -> Result - ) rethrows -> Result { - return try arg0.withUnsafeMutableBytes { p0 in - return try arg1.withUnsafeMutableBytes { p1 in - return try arg2.withUnsafeMutableBytes { p2 in - return try body(p0, p1, p2) - } - } - } -} - -fileprivate func withUnsafePointers( - _ arg0: Data, - _ arg1: Data, - _ arg2: Data, - _ arg3: inout Data, - _ body: ( - UnsafePointer, - UnsafePointer, - UnsafePointer, - UnsafeMutablePointer) throws -> Result - ) rethrows -> Result { - return try arg0.withUnsafeBytes { p0 in - return try arg1.withUnsafeBytes { p1 in - return try arg2.withUnsafeBytes { p2 in - return try arg3.withUnsafeMutableBytes { p3 in - return try body(p0, p1, p2, p3) - } - } - } - } -} - -fileprivate func withUnsafePointers( - _ arg0: Data, - _ arg1: Data, - _ arg2: Data, - _ arg3: Data, - _ arg4: inout Data, - _ arg5: inout Data, - _ body: ( - UnsafePointer, - UnsafePointer, - UnsafePointer, - UnsafePointer, - UnsafeMutablePointer, - UnsafeMutablePointer) throws -> Result - ) rethrows -> Result { - return try arg0.withUnsafeBytes { p0 in - return try arg1.withUnsafeBytes { p1 in - return try arg2.withUnsafeBytes { p2 in - return try arg3.withUnsafeBytes { p3 in - return try arg4.withUnsafeMutableBytes { p4 in - return try arg5.withUnsafeMutableBytes { p5 in - return try body(p0, p1, p2, p3, p4, p5) - } - } - } - } - } - } -} diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/SwCryptTests/Info.plist b/SetupConfiguration/Sources/SwCrypt/Sources/SwCryptTests/Info.plist deleted file mode 100755 index aec95491..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/SwCryptTests/Info.plist +++ /dev/null @@ -1,153 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - testPrivPEM - -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC8JyGJuwH8j2nY -tNTIHawVEXHrFogYLbBzCLEG80dD3Jp1zudqqwdbArytGKIwKMJUfmTa+n54L5vb -z/EwqsWxc/Wct8RUSN5tpkQvK4TjWgFJzsWRLv0rv+e1gTfQn4e/Q+JXWubsFBKl -ZFMXGRznnbNgKT9TGpKuGuO6ukrY0WXbeRX4Rd6NDbhzoexA1C8WltYccij5+tGf -zyTA1B+60EgJkF6gV5FtoYNEZAQKPtswGSSmAaZLzioVUeQTt2ICFJw4lZfc0dTG -HUQIvvc2UwXn2A3mC6/rwi4Q67U+AVUQKpu+Am8NXKjcy/0wV/3WjBriLrBAXcv2 -va/lFmKLAgMBAAECggEAMmQIh2qeTZXbMz66/h10SPAzIlMWf+M8rpJVVxcwruwW -MhcHw3mqrqU9At7mER/Za+et+ze7R1T42RYH8pDKAYyc6ywMWMZrS9KL0FZHcNxa -G/pUz11WULFEzUeeOzF+masEo4Ck9/UoSUNlPXpsU1vY/pgNbaRgRGDPPONHyGlW -2eJDuajtEtPrEB2MqdKYG3yk8LXiMIS2SQZtHpWAsAhvp1s4whLroQBxyhEwwuNw -CwoI6knc1rcfrxspkaW5q2eZCMF0fWK84PdZ9rDcaSZwUJfMPCETW33C9NXVCLdD -Yw0xihRUxyXcS4tqU+DZk3X0UfuTIdMEnPS+OpfMAQKBgQDft8ZElLjHWyF9M2dv -ywvaICmRmPF32sW5eEfaR/J8bR1ZOAUI5/dZv/rpm7X8I2dWn5qQLB+ka//AkHia -KXRYRGsdWk8YIZI/1VFxpXkzK/f+mtM7kv2KJVBhhgI0siMT4miNirlQHzcbmouJ -/xwXuyCsg1rNDtflqJ8FK2DR6wKBgQDXTZIuj3jsUWmUGogCiWVbhlfKvITZokHU -gw4V5Gx//B833UmGTJ/1lEV671h2OShzyNJMxTgDu5O+mxfv4hq8A6cY4hbu1Fii -p7EPF0V8t+/GyjeB/XMzl/0jyGRXQxzaWSe8Lv/cfM9j7tQVY/G58EEULR9sN0R2 -wfcQtw3p4QKBgGHmIt5KEp4ys/H896vFN/eJEYfEXQ6s7s+d4huUVnm6qhgr2pAu -KmDdESj/WeDvgT4388RZerNSC4Yx8oTL1Tz3G8Spi2ks77n9WHmaBvKssAZ7rCoq -xcaZU5aJtRdoSM9fyY7/AN8d+dibhaqqt5lu6vpzNN39O98lLgluFR1nAoGAGAV/ -mdJIG5W5wdxz8FSECoIiqWv/JokD70HwAGFL+buXgBQgb+t8rVmtptmtdQNLkB+H -1yjp5wC2qz2CnjEL6o49xnjzNhJbEUrEZnqiNhgPmI5XQxmUEN2UULm6+EF0pqfr -1wMnaOJEAVJUN06/WY+Es0uVhe1kphteBW9nDgECgYBp9auG5WYcjkt43KCBZxSn -PIEo0wnUVl0rQaMt69/bfulwX/zN4M4tdhqjY//LsNMWc2e8F/OJtghRmGzHkCYL -ILd1QNqqi0waaNvC8kdnUssO3jStEm1+6wzfyVoVB5cl8ob36vEzwwC8lLtyUjFt -rYl/vFV+gqGGJPzR7EqiGw== ------END PRIVATE KEY----- - testPubPEM - -----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvCchibsB/I9p2LTUyB2s -FRFx6xaIGC2wcwixBvNHQ9yadc7naqsHWwK8rRiiMCjCVH5k2vp+eC+b28/xMKrF -sXP1nLfEVEjebaZELyuE41oBSc7FkS79K7/ntYE30J+Hv0PiV1rm7BQSpWRTFxkc -552zYCk/UxqSrhrjurpK2NFl23kV+EXejQ24c6HsQNQvFpbWHHIo+frRn88kwNQf -utBICZBeoFeRbaGDRGQECj7bMBkkpgGmS84qFVHkE7diAhScOJWX3NHUxh1ECL73 -NlMF59gN5guv68IuEOu1PgFVECqbvgJvDVyo3Mv9MFf91owa4i6wQF3L9r2v5RZi -iwIDAQAB ------END PUBLIC KEY----- - testPrivEncryptedPEMAES128 - -----BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: AES-128-CBC,905D8CE3C9878467D460F9C0F2B5FEF3 - -vNM1pO9DlnfOEtHgeNZkLAydL1UnU2Q5tnq/x8uEovaJZCEwWOaUe+p9A2w4E/fl -57xzgwofj7jZcDIc2eAkAzwQju9RdhctO8d5CMHCfqAf7uKqeTLG1f4y2eWYvvYM -/a5ZZZ5RFfJ/yDUf2LE301L0lLCoNwZ1o3cLou+TUeC3Z4ClxL16lIyy5E+Gi4W4 -NNtNZlj2jfBIY/zlwcAO7BvQysUhJgXHTUEwzJW0cOVmow8vqBy7oijtYqkVnqHZ -g2SnL0w6pUe9gAfO869rUOdUcStOBdbnkmDV16iVglb8fE5VXCtnBQ9nN3tXpKum -n3hTEd6qyYINhKnGKd+E+1eWEHF2cfEBoN3rHe8FKrsFF3dd9R0Q3UqOQppt4lF+ -M8Gjd+GJbypAaBOrnRcIXfnVZNUYLDZ4O68qvc3ewsF/A3T7drA9riBxPUxDN41x -TtluCO7azZqn8FaY/Rfj6it3NcDW5UrM2TJPT3Gb/LtTaSqu4lD8p8VtfHxbOTyn -3tWRBFYRA86JSp7WsCQJEVgyOrTPeJgSZwUUwaSROFNWv2In3gmAX5l8wPGzwBOw -EOQLf8qT5gyt34fuc0IawkLKfGsG6lenS9NRorVjWzkdh8Aw4ooRfM67omglPtN7 -VFj2Z6mhPaVHUBYKfrnSQMhGmPQxueQhlDBPyo74SinbJ1xFD9xjvM1bT8jlfVdF -VGu0fBV1r2oY+Q3dn0z0sxVbUOJv9SlATj6kQmfShlw9cbpuUYWjCnPrM2hN37Q4 -7P0nXRSy3+N6RpGX/uAyK9yTM4R8uD7f2WeDSVBzoDd9gUeNk/5UGd++X7DYdaFK -dzi2KMOhoKioIoj1pey+dybcL60nq+92MG9OyIjW6syLRsW0oZByMZVDBAnv5tVu -RpcM4jiHWCmosguBA2t0YaeXSaEsJI7jHJU/fG1NUK6eHPO3gTaLC6B0Ru3okW+W -fgqT7VM81SzuJo1xHKoZ756cetSEzHi2IN4xQjdJ9EZQoQhBzqlcQyW5eYT+t8FA -I67alFYVzsUNYOy8fCqPvganzOESX75Zc6gOdgHb4ti9o2B0lnFjd0rkcZvfqqM4 -t/HkrJWPY5CjI/yaF/lgM1bNcRL84I8rScMePfPJPByaB+rIs6LYv2LFvyBQoWMx -oOh8fRQ0zqrgqQBtEwFNvv8xL5voAxDrtH9Tg25/BsPeulx+5HyeQFBVoEq90Tws -qa8/immZQZOqazrgGopA7vL1JWN00vzfXWdUZfXrO1PlhM7v/ploOtTRHTlUH0wO -P0mVZCUugxfuG2jgZGUB2Ckl8Wkm91S68EBesAsk9urWjxusSDTDMfkevoUCBBwB -A3X42p14L02F4mLIINUvKUb5OrcQMEABI/dgXlESA+Q3kA5o10Us/Mfogtq6JPyh -VtTciLSWf9h54ndY0pxpL0Gzhx14ptqVB9gI9vQIrdh2ArjclV7Pr2lFUt6onYEa -sfptyO+nuDF7Q2m09P6X/W9xo+R8UuGOaNYsaJzcymERkHfJx2BAbcO/NSn+cha2 -To40Cs1EUiXmX4WmONhdAEZprPF1ZWFEaZjyQ0kY7Ys9HHzEYfXOu9+7boNJ1rJG ------END RSA PRIVATE KEY----- - testPrivDecryptedPEM - -----BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEAvCchibsB/I9p2LTUyB2sFRFx6xaIGC2wcwixBvNHQ9yadc7n -aqsHWwK8rRiiMCjCVH5k2vp+eC+b28/xMKrFsXP1nLfEVEjebaZELyuE41oBSc7F -kS79K7/ntYE30J+Hv0PiV1rm7BQSpWRTFxkc552zYCk/UxqSrhrjurpK2NFl23kV -+EXejQ24c6HsQNQvFpbWHHIo+frRn88kwNQfutBICZBeoFeRbaGDRGQECj7bMBkk -pgGmS84qFVHkE7diAhScOJWX3NHUxh1ECL73NlMF59gN5guv68IuEOu1PgFVECqb -vgJvDVyo3Mv9MFf91owa4i6wQF3L9r2v5RZiiwIDAQABAoIBADJkCIdqnk2V2zM+ -uv4ddEjwMyJTFn/jPK6SVVcXMK7sFjIXB8N5qq6lPQLe5hEf2Wvnrfs3u0dU+NkW -B/KQygGMnOssDFjGa0vSi9BWR3DcWhv6VM9dVlCxRM1HnjsxfpmrBKOApPf1KElD -ZT16bFNb2P6YDW2kYERgzzzjR8hpVtniQ7mo7RLT6xAdjKnSmBt8pPC14jCEtkkG -bR6VgLAIb6dbOMIS66EAccoRMMLjcAsKCOpJ3Na3H68bKZGluatnmQjBdH1ivOD3 -Wfaw3GkmcFCXzDwhE1t9wvTV1Qi3Q2MNMYoUVMcl3EuLalPg2ZN19FH7kyHTBJz0 -vjqXzAECgYEA37fGRJS4x1shfTNnb8sL2iApkZjxd9rFuXhH2kfyfG0dWTgFCOf3 -Wb/66Zu1/CNnVp+akCwfpGv/wJB4mil0WERrHVpPGCGSP9VRcaV5Myv3/prTO5L9 -iiVQYYYCNLIjE+JojYq5UB83G5qLif8cF7sgrINazQ7X5aifBStg0esCgYEA102S -Lo947FFplBqIAollW4ZXyryE2aJB1IMOFeRsf/wfN91Jhkyf9ZRFeu9Ydjkoc8jS -TMU4A7uTvpsX7+IavAOnGOIW7tRYoqexDxdFfLfvxso3gf1zM5f9I8hkV0Mc2lkn -vC7/3HzPY+7UFWPxufBBFC0fbDdEdsH3ELcN6eECgYBh5iLeShKeMrPx/PerxTf3 -iRGHxF0OrO7PneIblFZ5uqoYK9qQLipg3REo/1ng74E+N/PEWXqzUguGMfKEy9U8 -9xvEqYtpLO+5/Vh5mgbyrLAGe6wqKsXGmVOWibUXaEjPX8mO/wDfHfnYm4WqqreZ -bur6czTd/TvfJS4JbhUdZwKBgBgFf5nSSBuVucHcc/BUhAqCIqlr/yaJA+9B8ABh -S/m7l4AUIG/rfK1ZrabZrXUDS5Afh9co6ecAtqs9gp4xC+qOPcZ48zYSWxFKxGZ6 -ojYYD5iOV0MZlBDdlFC5uvhBdKan69cDJ2jiRAFSVDdOv1mPhLNLlYXtZKYbXgVv -Zw4BAoGAafWrhuVmHI5LeNyggWcUpzyBKNMJ1FZdK0GjLevf237pcF/8zeDOLXYa -o2P/y7DTFnNnvBfzibYIUZhsx5AmCyC3dUDaqotMGmjbwvJHZ1LLDt40rRJtfusM -38laFQeXJfKG9+rxM8MAvJS7clIxba2Jf7xVfoKhhiT80exKohs= ------END RSA PRIVATE KEY----- - testPrivEncryptedPEMAES256 - -----BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: AES-256-CBC,CBB159E4726DD83B543567ABDA2D2FAF - -CNLqaMdh140G6f8ifml1F14JCg7rupUABXFwT/A4LSImZ77exUu7qjf36zBOZeaJ -A3vIeucb7xC1X9Hp8VWaQRAniDMBJEERf0GRoA2/o8PMz9bSAN/KLhONTpdrtBoy -af1L6xaOxzIUFJCS53jXQnWnf8dDFQYHSzIeaV6K6yQG2qB5ouJ3iguAlc2AzjSz -wLskOs2HIy0iIBaQC5pXR1UdagsXEm776ksEUNa5wd0++eXhorDJtOYQK5I8PUXs -ndAVwAd5f4pXL7CYfputPjEHOFXLcL1En5VGGlKcA9k+qEUmCJeuTQmOZM0giJOF -8lODv4qZRn4TPm1UJlvXTgl6QVRaoDnuNf++XwVIFgPEWfpr2iBJ0hBeurfJxSjB -wRBKao6MSrkb5KnZE+9Ccx+8E/qkfn/Lkw9A3UnPjS8pyGoh6SycvP5mJfC6WuXh -8O4ETgBF595RF/GreAHIK31YmUjVIebxPguYXxNcqTFPu0UMSN/QMhe6qg8kLkZ0 -ZJjVuMJ4EyAaLW9xUQi7k5ynTGvQN0uZwdndrLZPXxgMJR4kM0kN06ex6um2Wvww -fpRDANG8x9Jpp+c3dqDWVIH8afUI3T4dUGnu2wNpaxJsJGhZqu3wXMPk/23IezTX -81EONi8hEnWS9iXRGYF8bjZhPwQD8kU7Bw++VbhlW3DydifLpfoap48+nXN/vmlQ -jODNPR4E47jXPMC+t+6R5esYMaSVj0s5C/WnRrz3sjh/Py01WsenPeSnvyivrl5I -3JGMH4VJd58Ygy33gmnJ3wLfcMLinPMYq8XMqvhJMDQY/oAZo6a6EZTZNr6zdwQU -gkv13AK1jPZFczydzfGel8Ru+FD4mARQzjlBwA4akAJgaoQk4NFrOzXZyboFToK2 -4ulGCpKe3U+BZAZUotV3wXbi9bOoa6l/fH+tmribbOv51pSs+aiH60s4BAoqGA+v -41pwwROsdy/TNX1JqMeYNMRkFvFLNBQFlrwSJuwvPqeJyaV6KHzPQ3TnwuboHowk -Vw5NxhNHgjNRxzH909uJjzGiZ1EpFh2rbWlMg1QlZg5Dqhzye9k3VxmPwmKeRqPH -9TRKiKGprOzR11Ontns6y6OTxOsPMwwRUeu3KOuv4b5ZsjrSS5/6nbKBqscX83zL -DJthtC55XrENOAetatZBSzKwPd0ZeANQcoetZaV3DEm1+YVHlN+NUzLZzgqT33sC -Nt91zpJn5F8qhyw/jxpAAeyByBjL1s8+jRsRbNiybKiQOP5XO5MTxDiiSGLkzfqk -LpuF2k2fHRMJdO2YfHT1wurAlMlkVDYiv1Z5zBgTkTc0Kgryc5apAf18uSzxV70d -AlcCCHqJ7X72L6Cd0fQ80nAT+hHzs3djN3+AQrdj3hNVsO8bcELe4WlZq58WVdmJ -5sntXhLWqUAHV+ybSVb0XbDbESvw9ugydDmJgJda1eHTPfekEl1tekU63W2EDbr3 -virNS3vBL6AUZsDARR5bV3Koie1zuFuouG0IMoHC3dPkxK/lovokEr69qj37BFOF -PiMuzVzGugcz4JHCirzbpQOn1mL51FqBj7hVTdMA8u6IqN0OzESM95U6ZZTuwNgP ------END RSA PRIVATE KEY----- - CFBundleVersion - 1 - - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/SwCryptTests/SwCryptTests.swift b/SetupConfiguration/Sources/SwCrypt/Sources/SwCryptTests/SwCryptTests.swift deleted file mode 100755 index fa33b834..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/SwCryptTests/SwCryptTests.swift +++ /dev/null @@ -1,382 +0,0 @@ -import XCTest -import SwCrypt - -let keyPair = try? SwCryptTest.createKeyPair(2048) - -class SwCryptTest: XCTestCase { - - override func setUp() { - super.setUp() - self.continueAfterFailure = false - } - - override func tearDown() { - super.tearDown() - } - - static func createKeyPair(_ size: Int) throws -> (Data, Data) { - return try CC.RSA.generateKeyPair(size) - } - - func testAvailable() { - XCTAssert(CC.digestAvailable()) - XCTAssert(CC.randomAvailable()) - XCTAssert(CC.hmacAvailable()) - XCTAssert(CC.cryptorAvailable()) - XCTAssert(CC.KeyDerivation.available()) - XCTAssert(CC.KeyWrap.available()) - XCTAssert(CC.RSA.available()) - XCTAssert(CC.DH.available()) - XCTAssert(CC.EC.available()) - XCTAssert(CC.CRC.available()) - XCTAssert(CC.CMAC.available()) - XCTAssert(CC.GCM.available()) - XCTAssert(CC.CCM.available()) - XCTAssert(CC.available()) - } - - func testDigest() { - XCTAssert(CC.digestAvailable()) - let testData = "rokafogtacsuka".data(using: String.Encoding.utf8)! - let sha1 = "9e421ffa8b2c83ac23e96bc9f9302f4a16311037".dataFromHexadecimalString()! - let sha256 = "ae6ab1cf65971f88b9cd92c2f334d6a99beaf5b40240d4b440fdb4a1231db0f0" - .dataFromHexadecimalString()! - let sha384 = ("acf011a346e96364091bd21415a2437273c7f3c84060b21ac19f2eafa1c6cde76467b0b0" + - "aba99626b18aa3da83e442db").dataFromHexadecimalString()! - let sha512 = ("016748fad47ddfba4fcd19aacc67ee031dfef40f5e9692c84f8846e520f2a827a4ea5035" + - "af8a66686c60796a362c30e6c473cfdbb9d86f43312001fc0b660734").dataFromHexadecimalString()! - let sha224 = "ec92519bb9e82a79097b0dd0618927b3262a70d6f02bd667c413009e" - .dataFromHexadecimalString()! - let md5 = "9b43f853613732cfc8531ed6bcbf6d68".dataFromHexadecimalString()! - XCTAssert(CC.digest(testData, alg: .sha1) == sha1) - XCTAssert(CC.digest(testData, alg: .sha256) == sha256) - XCTAssert(CC.digest(testData, alg: .sha384) == sha384) - XCTAssert(CC.digest(testData, alg: .sha512) == sha512) - XCTAssert(CC.digest(testData, alg: .sha224) == sha224) - XCTAssert(CC.digest(testData, alg: .md5) == md5) - } - - func testRandom() { - XCTAssert(CC.randomAvailable()) - _ = CC.generateRandom(10) - } - - func testCreateKeyPair() { - XCTAssert(keyPair != nil) - } - - func testUpsert() { - let (priv, _) = keyPair! - let privKey = SwKeyConvert.PrivateKey.derToPKCS1PEM(priv) - XCTAssertNotNil(try? SwKeyStore.upsertKey(privKey, keyTag: "priv", - options: [kSecAttrAccessible:kSecAttrAccessibleWhenUnlockedThisDeviceOnly])) - XCTAssertNotNil(try? SwKeyStore.upsertKey(privKey, keyTag: "priv")) - XCTAssert(try SwKeyStore.getKey("priv") == privKey) - } - - func testDel() throws { - let tag = "priv" - let (priv, _) = keyPair! - let privKey = SwKeyConvert.PrivateKey.derToPKCS1PEM(priv) - XCTAssertNotNil(try? SwKeyStore.upsertKey(privKey, keyTag: tag)) - XCTAssertNotNil(try? SwKeyStore.getKey(tag)) - XCTAssertNotNil(try? SwKeyStore.delKey(tag)) - XCTAssertNil(try? SwKeyStore.getKey(tag)) - } - - func encryptKey(_ enc: SwKeyConvert.PrivateKey.EncMode) { - let pass = "hello" - let (priv, _) = keyPair! - let privKey = SwKeyConvert.PrivateKey.derToPKCS1PEM(priv) - - let privEncrypted = try? SwKeyConvert.PrivateKey.encryptPEM(privKey, passphrase: pass, mode: enc) - XCTAssert(privEncrypted != nil) - let privDecrypted = try? SwKeyConvert.PrivateKey.decryptPEM(privEncrypted!, passphrase: pass) - XCTAssert(privDecrypted != nil) - XCTAssert(privDecrypted == privKey) - } - - func testEncryptKey() { - encryptKey(.aes128CBC) - encryptKey(.aes256CBC) - } - - func testKeyNotEncrypted() { - let bundle = Bundle(for: type(of: self)) - let decPEM = bundle.object(forInfoDictionaryKey: "testPrivDecryptedPEM") as! String - XCTAssertThrowsError(try SwKeyConvert.PrivateKey.decryptPEM(decPEM, passphrase: "hello")) { - XCTAssert($0 as? SwKeyConvert.SwError == SwKeyConvert.SwError.keyNotEncrypted) - } - } - - func testKeyInvalid() { - let bundle = Bundle(for: type(of: self)) - var decPEM = bundle.object(forInfoDictionaryKey: "testPrivDecryptedPEM") as! String - decPEM = "a" + decPEM - XCTAssertThrowsError(try SwKeyConvert.PrivateKey.decryptPEM(decPEM, passphrase: "hello")) { - XCTAssert($0 as? SwKeyConvert.SwError == SwKeyConvert.SwError.invalidKey) - } - } - - func decryptOpenSSLKeys(_ type: String) { - let bundle = Bundle(for: Swift.type(of: self)) - let encPEM = bundle.object(forInfoDictionaryKey: "testPrivEncryptedPEMAES" + type) as! String - let decPEM = bundle.object(forInfoDictionaryKey: "testPrivDecryptedPEM") as! String - let d = try? SwKeyConvert.PrivateKey.decryptPEM(encPEM, passphrase: "hello") - XCTAssert(d != nil) - XCTAssert(d! == decPEM) - } - - func decryptOpenSSLKeysBadPassphrase(_ type: String) { - let bundle = Bundle(for: Swift.type(of: self)) - let encPEM = bundle.object(forInfoDictionaryKey: "testPrivEncryptedPEMAES" + type) as! String - - XCTAssertThrowsError(try SwKeyConvert.PrivateKey.decryptPEM(encPEM, passphrase: "nohello")) { - XCTAssert($0 as? SwKeyConvert.SwError == SwKeyConvert.SwError.badPassphrase) - } - } - - func testOpenSSLKeyPair() { - let bundle = Bundle(for: type(of: self)) - let priv = bundle.object(forInfoDictionaryKey: "testPrivPEM") as! String - let pub = bundle.object(forInfoDictionaryKey: "testPubPEM") as! String - let privKey = try? SwKeyConvert.PrivateKey.pemToPKCS1DER(priv) - XCTAssert(privKey != nil) - let pubKey = try? SwKeyConvert.PublicKey.pemToPKCS1DER(pub) - XCTAssert(pubKey != nil) - } - - func testOpenSSLKeys() { - decryptOpenSSLKeys("128") - decryptOpenSSLKeys("256") - decryptOpenSSLKeysBadPassphrase("128") - decryptOpenSSLKeysBadPassphrase("256") - } - - func testGetPublicKeyFromPrivateKey() { - let bundle = Bundle(for: type(of: self)) - let priv = bundle.object(forInfoDictionaryKey: "testPrivPEM") as! String - let pub = bundle.object(forInfoDictionaryKey: "testPubPEM") as! String - let privKey = try? SwKeyConvert.PrivateKey.pemToPKCS1DER(priv) - let pubKey = try? SwKeyConvert.PublicKey.pemToPKCS1DER(pub) - let genPubKey = try? CC.RSA.getPublicKeyFromPrivateKey(privKey!) - XCTAssert(pubKey == genPubKey) - } - - func testEncryptDecryptPKCS1() { - let (priv, pub) = keyPair! - - let testData = "This is a test string".data(using: String.Encoding.utf8)! - - let e = try? CC.RSA.encrypt(testData, derKey: pub, tag: Data(), padding: .pkcs1, digest: .none) - XCTAssert(e != nil) - let d = try? CC.RSA.decrypt(e!, derKey: priv, tag: Data(), padding: .pkcs1, digest: .none) - XCTAssert(d != nil) - XCTAssert(testData == d!.0) - } - - func testEncryptDecryptOAEPSHA256() { - let (priv, pub) = keyPair! - let testData = "This is a test string".data(using: String.Encoding.utf8)! - - let e = try? CC.RSA.encrypt(testData, derKey: pub, tag: Data(), padding: .oaep, digest: .sha256) - XCTAssert(e != nil) - let d = try? CC.RSA.decrypt(e!, derKey: priv, tag: Data(), padding: .oaep, digest: .sha256) - XCTAssert(d != nil) - XCTAssert(testData == d!.0) - } - - func testEncryptDecryptGCM() { - let aesKey = CC.generateRandom(32) - let iv = CC.generateRandom(12) - let testData = "This is a test string".data(using: String.Encoding.utf8)! - - let e = try? CC.cryptAuth(.encrypt, blockMode: .gcm, algorithm: .aes, data: testData, aData: Data(), key: aesKey, iv: iv, tagLength: 8) - XCTAssert(e != nil) - let d = try? CC.cryptAuth(.decrypt, blockMode: .gcm, algorithm: .aes, data: e!, aData: Data(), key: aesKey, iv: iv, tagLength: 8) - XCTAssert(d != nil) - XCTAssert(testData == d!) - } - - func signVerify(_ privKey: Data, pubKey:Data, padding: CC.RSA.AsymmetricSAPadding) { - let testMessage = "rirararom_vagy_rararirom".data(using: String.Encoding.utf8)! - let sign = try? CC.RSA.sign(testMessage, derKey: privKey, padding: padding, - digest: .sha256, saltLen: 16) - XCTAssert(sign != nil) - let verified = try? CC.RSA.verify(testMessage, derKey: pubKey, padding: padding, - digest: .sha256, saltLen: 16, signedData: sign!) - XCTAssert(verified != nil && verified! == true) - } - - func testSignVerify() { - let (priv, pub) = keyPair! - signVerify(priv, pubKey: pub, padding: .pkcs15) - signVerify(priv, pubKey: pub, padding: .pss) - } - - func testCCM() { - let data = "hello".data(using: String.Encoding.utf8)! - let key = "8B142BB0FA0043C32821BB90A3453884".dataFromHexadecimalString()! - let iv = "B5863BD2ABBED31DC26C4EDB5A".dataFromHexadecimalString()! - let aData = "hello".data(using: String.Encoding.utf8)! - let tagLength = 16 - XCTAssert(CC.CCM.available()) - - let enc = try? CC.CCM.crypt(.encrypt, algorithm: .aes, data: data, key: key, iv: iv, - aData: aData, tagLength: tagLength) - XCTAssert(enc != nil) - let dec = try? CC.CCM.crypt(.decrypt, algorithm: .aes, data: enc!.0, key: key, iv: iv, - aData: aData, tagLength: tagLength) - XCTAssert(dec != nil) - XCTAssert(enc!.1 == dec!.1) - XCTAssert(dec!.0 == data) - } - - func testCCMSJCL() { - let data = "hello".data(using: String.Encoding.utf8)! - let key = "8B142BB0FA0043C32821BB90A3453884".dataFromHexadecimalString()! - let iv = "B5863BD2ABBED31DC26C4EDB5A".dataFromHexadecimalString()! - let aData = "hello".data(using: String.Encoding.utf8)! - let tagLength = 16 - let sjclCipher = Data(base64Encoded: "VqAna25S22M+yOZz57wCllx7Itql", options: [])! - XCTAssert(CC.CCM.available()) - - let enc = try? CC.cryptAuth(.encrypt, blockMode: .ccm, algorithm: .aes, data: data, - aData: aData, key: key, iv: iv, tagLength: tagLength) - XCTAssert(enc != nil) - XCTAssert(enc! == sjclCipher) - - let dec = try? CC.cryptAuth(.decrypt, blockMode: .ccm, algorithm: .aes, data: sjclCipher, - aData: aData, key: key, iv: iv, tagLength: tagLength) - XCTAssert(dec != nil) - XCTAssert(dec! == data) - } - - func testPBKDF2() { - let password = "password" - let salt = "salt".data(using: String.Encoding.utf8)! - - XCTAssert(CC.KeyDerivation.available()) - let stretched = try? CC.KeyDerivation.PBKDF2(password, salt: salt, prf: .sha256, rounds: 4096) - XCTAssert(stretched != nil) - let t = "c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a" - .dataFromHexadecimalString() - XCTAssert(t == stretched!) - } - - func testKeyWrap() { - let kek = "000102030405060708090A0B0C0D0E0F".dataFromHexadecimalString()! - let tkey = "00112233445566778899AABBCCDDEEFF".dataFromHexadecimalString()! - let wrappedKey = "1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5" - .dataFromHexadecimalString()! - - XCTAssert(CC.KeyWrap.available()) - let cipher = try? CC.KeyWrap.SymmetricKeyWrap(CC.KeyWrap.rfc3394IV, kek: kek, rawKey: tkey) - XCTAssert(cipher != nil) - XCTAssert(cipher! == wrappedKey) - - let key = try? CC.KeyWrap.SymmetricKeyUnwrap(CC.KeyWrap.rfc3394IV, kek: kek, wrappedKey: cipher!) - XCTAssert(key != nil) - XCTAssert(key! == tkey) - } - - func testECGenkey() { - XCTAssert(CC.EC.available()) - - let keys = try? CC.EC.generateKeyPair(384) - XCTAssert(keys != nil) - let keysTooLittle = try? CC.EC.generateKeyPair(128) - XCTAssert(keysTooLittle == nil) - } - - func testECSignVerify() { - XCTAssert(CC.EC.available()) - - let keys = try? CC.EC.generateKeyPair(256) - XCTAssert(keys != nil) - let hash = "c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a" - .dataFromHexadecimalString()! - - let signed = try? CC.EC.signHash(keys!.0, hash: hash) - XCTAssert(signed != nil) - let verified = try? CC.EC.verifyHash(keys!.1, hash: hash, signedData: signed!) - XCTAssert(verified == true) - } - - func testECSharedSecret() { - XCTAssert(CC.EC.available()) - - let keys1 = try? CC.EC.generateKeyPair(384) - XCTAssert(keys1 != nil) - let keys2 = try? CC.EC.generateKeyPair(384) - XCTAssert(keys2 != nil) - - let shared1 = try? CC.EC.computeSharedSecret(keys1!.0, publicKey: keys2!.1) - XCTAssert(shared1 != nil) - let shared2 = try? CC.EC.computeSharedSecret(keys2!.0, publicKey: keys1!.1) - XCTAssert(shared2 != nil) - XCTAssert(shared1! == shared2!) - } - - func testECComponents() { - XCTAssert(CC.EC.available()) - - let keys = try? CC.EC.generateKeyPair(384) - XCTAssert(keys != nil) - let cPriv = try? CC.EC.getPrivateKeyComponents(keys!.0) - XCTAssert(cPriv != nil) - let cPub = try? CC.EC.getPublicKeyComponents(keys!.1) - XCTAssert(cPub != nil) - let keys2 = try? CC.EC.createFromData(cPub!.keySize, cPub!.x, cPub!.y) - XCTAssert(keys2 != nil) - XCTAssert(keys!.1 == keys2!) - } - - func testECGetPublicFromPrivate() { - XCTAssert(CC.EC.available()) - - let keys = try? CC.EC.generateKeyPair(384) - XCTAssert(keys != nil) - - let pub = try? CC.EC.getPublicKeyFromPrivateKey(keys!.0) - XCTAssert(pub != nil) - XCTAssert(pub == keys!.1) - } - - func testDH() { - XCTAssert(CC.DH.available()) - let dh1 = try? CC.DH.DH(dhParam: .rfc3526Group5) - XCTAssert(dh1 != nil) - let dh2 = try? CC.DH.DH(dhParam: .rfc3526Group5) - XCTAssert(dh2 != nil) - - let pub1 = try? dh1!.generateKey() - XCTAssert(pub1 != nil) - let pub2 = try? dh2!.generateKey() - XCTAssert(pub2 != nil) - - let common1 = try? dh1!.computeKey(pub2!) - XCTAssert(common1 != nil) - let common2 = try? dh2!.computeKey(pub1!) - XCTAssert(common2 != nil) - XCTAssert(common1 == common2) - } - - func testCRC() { - XCTAssert(CC.CRC.available()) - let input = "abcdefg".data(using: String.Encoding.utf8)! - let expectedOutput: UInt64 = 0x312A6AA6 - let output = try? CC.CRC.crc(input, mode: .crc32) - XCTAssert(output != nil) - XCTAssert(output == expectedOutput) - } - - func testCMAC() { - XCTAssert(CC.CMAC.available()) - let input = "abcdefg".data(using: String.Encoding.utf8)! - let key = "8B142BB0FA0043C32821BB90A3453884".dataFromHexadecimalString()! - let expectedOutput = "a7903c21aaa33db4c8ad7b23a947e0bd".dataFromHexadecimalString()! - let cmac = CC.CMAC.AESCMAC(input, key: key) - XCTAssert(cmac == expectedOutput) - } -} diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/AppDelegate.swift b/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/AppDelegate.swift deleted file mode 100755 index 356764c6..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/AppDelegate.swift +++ /dev/null @@ -1,38 +0,0 @@ -import UIKit - -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - - var window: UIWindow? - - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - return true - } - - func applicationWillResignActive(_ application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(_ application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(_ application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(_ application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - -} - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100755 index d8db8d65..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - }, - { - "idiom" : "ios-marketing", - "size" : "1024x1024", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Base.lproj/LaunchScreen.storyboard b/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Base.lproj/LaunchScreen.storyboard deleted file mode 100755 index fdf3f97d..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Base.lproj/Main.storyboard b/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Base.lproj/Main.storyboard deleted file mode 100755 index 273375fc..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Base.lproj/Main.storyboard +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Info.plist b/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Info.plist deleted file mode 100755 index d0524738..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/Info.plist +++ /dev/null @@ -1,45 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/ViewController.swift b/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/ViewController.swift deleted file mode 100755 index c2f73ba5..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/ViewController.swift +++ /dev/null @@ -1,17 +0,0 @@ -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - -} - diff --git a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/dummyTestApp.entitlements b/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/dummyTestApp.entitlements deleted file mode 100755 index a451ca31..00000000 --- a/SetupConfiguration/Sources/SwCrypt/Sources/dummyTestApp/dummyTestApp.entitlements +++ /dev/null @@ -1,10 +0,0 @@ - - - - - keychain-access-groups - - $(AppIdentifierPrefix)hu.irl.dummyTestAppa - - - diff --git a/SetupConfiguration/Sources/main.swift b/SetupConfiguration/Sources/main.swift deleted file mode 100644 index 94ffdc9f..00000000 --- a/SetupConfiguration/Sources/main.swift +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/swift sh - -/* - * Copyright 2017 - 2025 Riigi Infosüsteemi Amet - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -import Foundation -import CryptoKit - -// MARK: - Settings Configuration - -class SettingsConfiguration { - private let configBaseUrl: String - private let configUpdateInterval: Int - private let configTslUrl: String - - private let configurationDateFormatter: DateFormatter = { - let formatter = DateFormatter() - formatter.locale = Locale(identifier: "en_US_POSIX") - formatter.timeZone = TimeZone(secondsFromGMT: 0) - formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" - return formatter - }() - - init() { - let args = CommandLine.arguments - self.configBaseUrl = args.indices.contains(1) ? args[1] : "https://id.eesti.ee" - self.configUpdateInterval = args.indices.contains(2) ? Int(args[2]) ?? 4 : 4 - self.configTslUrl = args.indices.contains(3) ? args[3] : "https://ec.europa.eu/tools/lotl/eu-lotl.xml" - } - - func setupConfiguration() async throws { - log("Starting configuration setup...") - - log("Config Base URL: \(configBaseUrl)") - log("Update Interval: \(configUpdateInterval) hours") - log("Config TSL URL: \(configTslUrl)") - - log("1 / 4 - Downloading configuration data...") - let configData = try await fetchData(from: "\(configBaseUrl)/config.json") - let publicKey = try await fetchData(from: "\(configBaseUrl)/config.ecpub") - let signature = try await fetchData(from: "\(configBaseUrl)/config.ecc") - - log("2 / 4 - Verifying signature...") - try verifySignature(configData: configData, publicKey: publicKey, signature: signature) - - log("3 / 4 - Creating default configuration file...") - let decodedData = try decodeMoppConfiguration(configData: configData) - let defaultConfiguration = createDefaultConfiguration(versionSerial: decodedData.METAINF.SERIAL) - - log("4 / 4 - Saving and moving files...") - try saveAndMoveConfigurationFiles(configData: configData, publicKey: publicKey, signature: signature, defaultConfiguration: defaultConfiguration) - - log("Default configuration initialized successfully!") - } -} - -// MARK: - Network Functions - -extension SettingsConfiguration { - private func fetchData(from urlString: String) async throws -> String { - guard let url = URL(string: urlString) else { throw ConfigurationError.invalidURL } - - let (data, _) = try await URLSession.shared.data(from: url) - guard let stringData = String(data: data, encoding: .utf8) else { throw ConfigurationError.invalidData } - - return stringData - } -} - -// MARK: - Signature Verification - -extension SettingsConfiguration { - private func verifySignature(configData: String, publicKey: String, signature: String) throws { - // Placeholder for actual verification logic - guard !configData.isEmpty, !publicKey.isEmpty, !signature.isEmpty else { - throw ConfigurationError.signatureVerificationFailed - } - guard let pubKey = Data(base64Encoded: publicKey - .replacing("-----BEGIN PUBLIC KEY-----", with: "") - .replacing("-----END PUBLIC KEY-----", with: ""), options: .ignoreUnknownCharacters) else { - log("Failed to parse key") - throw ConfigurationError.signatureVerificationFailed - } - guard let sigData = Data(base64Encoded: signature, options: .ignoreUnknownCharacters) else { - throw ConfigurationError.signatureVerificationFailed - } - - let result: Bool - switch pubKey.count { - case 80...100: - let key = try P256.Signing.PublicKey(derRepresentation: pubKey) - let sig = try P256.Signing.ECDSASignature(derRepresentation: sigData) - result = key.isValidSignature(sig, for: Data(configData.utf8)) - case 110...130: - let key = try P384.Signing.PublicKey(derRepresentation: pubKey) - let sig = try P384.Signing.ECDSASignature(derRepresentation: sigData) - result = key.isValidSignature(sig, for: Data(configData.utf8)) - case 150...170: - let key = try P521.Signing.PublicKey(derRepresentation: pubKey) - let sig = try P521.Signing.ECDSASignature(derRepresentation: sigData) - result = key.isValidSignature(sig, for: Data(configData.utf8)) - default: - log("Unknown key size") - throw ConfigurationError.signatureVerificationFailed - } - if !result { - log("Signature verifying failed") - throw ConfigurationError.signatureVerificationFailed - } - log("Signature verified successfully!") - } -} - -// MARK: - Configuration File Management - -extension SettingsConfiguration { - private func createDefaultConfiguration(versionSerial: Int) -> String { - return """ - central-configuration-service.url=\(configBaseUrl) - configuration.update-interval=\(configUpdateInterval) - configuration.version-serial=\(versionSerial) - configuration.download-date=\(configurationDateFormatter.string(from: Date())) - """ - } - - private func saveAndMoveConfigurationFiles(configData: String, publicKey: String, signature: String, defaultConfiguration: String) throws { - let files = [ - ("default-config.json", configData), - ("default-config.ecpub", publicKey), - ("default-config.ecc", signature), - ("configuration.properties", defaultConfiguration) - ] - - for (fileName, content) in files { - try saveFile(named: fileName, content: content) - } - } - - private func saveFile(named fileName: String, content: String) throws { - let components = ["Modules", "ConfigLib", "Sources", "ConfigLib", "Resources", "config"] - let baseURL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath) - let directory = components.reduce(baseURL) { $0.appendingPathComponent($1) } - let fileURL = directory.appendingPathComponent(fileName) - - try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) - - try content.write(to: fileURL, atomically: true, encoding: .utf8) - log("File saved: \(fileURL.path)") - } -} - -extension SettingsConfiguration { - func decodeMoppConfiguration(configData: String) throws -> MOPPConfiguration { - do { - return try JSONDecoder().decode(MOPPConfiguration.self, from: configData.data(using: .utf8)!) - } catch { - fatalError("Error decoding data: \(error.localizedDescription)") - } - } - - struct MOPPConfiguration: Codable { - let METAINF: MOPPMetaInf - - private enum MOPPConfigurationType: String, CodingKey { - case METAINF = "META-INF" - } - - init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: MOPPConfigurationType.self) - METAINF = try container.decode(MOPPMetaInf.self, forKey: .METAINF) - } - } - - struct MOPPMetaInf: Codable { - let URL: String - let DATE: String - let SERIAL: Int - let VER: Int - } -} - -// MARK: - Error Handling - -enum ConfigurationError: Error { - case invalidURL - case invalidData - case signatureVerificationFailed -} - -// MARK: - Logger - -func log(_ message: String) { - NSLog("[\(DateFormatter.localizedString(from: Date(), dateStyle: .none, timeStyle: .medium))] \(message)") -} - -// MARK: - Run Script - -try await SettingsConfiguration().setupConfiguration() diff --git a/WidgetExtension/WidgetExtensionAttributes.swift b/WidgetExtension/WidgetExtensionAttributes.swift index ec75ca48..c54c823c 100644 --- a/WidgetExtension/WidgetExtensionAttributes.swift +++ b/WidgetExtension/WidgetExtensionAttributes.swift @@ -19,8 +19,10 @@ import ActivityKit -public struct WidgetExtensionAttributes: ActivityAttributes { - public struct ContentState: Codable, Hashable { +// A Live Activity is updated by the system in the background, not on the app's main screen. +// `nonisolated` marks this data as safe to use away from the main screen +public nonisolated struct WidgetExtensionAttributes: ActivityAttributes { + public nonisolated struct ContentState: Codable, Hashable { var title: String var compactTitle: String var controlCode: String diff --git a/codemagic.yaml b/codemagic.yaml index b282a7ab..7ac3f9f8 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -69,7 +69,7 @@ workflows: echo Run tests?: ${{ inputs.enableTests_input }} - name: Setup dependencies script: | - brew install swift-sh mockolo + brew install mockolo - *get_google_services_plist - name: "Setup config and TSL files" script: | @@ -114,15 +114,15 @@ workflows: echo "Getting TSL (local LOTL)" # Repo.ria TSL files already in assets folder, doesn't need to download separately anymore if [[ "${{ inputs.defaultCentralConfigurationTslUrl_input }}" == *"10.1.24.31"* ]]; then - python3 scripts/TSLXMLDownloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True" + python3 scripts/tsl_xml_downloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True" else - python3 scripts/TSLXMLDownloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --tslTestFile="$TSL_FILES_DIRECTORY/$(basename ${{ inputs.defaultCentralConfigurationTslUrl_input }})" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True" + python3 scripts/tsl_xml_downloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --tslTestFile="$TSL_FILES_DIRECTORY/$(basename ${{ inputs.defaultCentralConfigurationTslUrl_input }})" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True" fi echo "Finished downloading TSL" else echo "Getting TSL (remote LOTL)" - python3 scripts/TSLXMLDownloader.py --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True" + python3 scripts/tsl_xml_downloader.py --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="${{ inputs.memberTsl_input }}" --isDevBuild="True" echo "Finished downloading TSL" fi @@ -134,10 +134,8 @@ workflows: script: | # Not running 'SetupConfiguration' for repo.ria as necessary files are already setup if [[ ! "${{ inputs.defaultCentralConfigurationTslUrl_input }}" == *"10.1.24.31"* ]]; then - echo "Cleaning swift-sh cache" - swift-sh --clean-cache echo "Fetching default configuration" - swift-sh SetupConfiguration/Sources/main.swift ${{ inputs.defaultCentralConfigurationUrl_input }} ${{ inputs.defaultCentralConfigurationUpdateInterval_input }} ${{ inputs.defaultCentralConfigurationTslUrl_input }} + python3 scripts/setup_configuration.py ${{ inputs.defaultCentralConfigurationUrl_input }} ${{ inputs.defaultCentralConfigurationUpdateInterval_input }} ${{ inputs.defaultCentralConfigurationTslUrl_input }} else echo "Skipping default configuration fetching for repo.ria" fi @@ -168,7 +166,7 @@ workflows: LOGGING_FLAGS="OTHER_SWIFT_FLAGS=\"\$(inherited) -DENABLE_LOGGING\"" # Add logging flag to conf flags - ARCHIVE_FLAGS="$REPO_RIA_CONF_FLAGS $LOGGING_FLAGS" + ARCHIVE_FLAGS="$REPO_RIA_CONF_FLAGS $LOGGING_FLAGS -skipPackagePluginValidation" xcode-project build-ipa \ --clean \ @@ -230,7 +228,7 @@ workflows: scripts: - name: Setup dependencies script: | - brew install swift-sh mockolo + brew install mockolo - *get_google_services_plist - name: "Setup config and TSL files" script: | @@ -257,12 +255,12 @@ workflows: if [ -f "$TSL_FILES_DIRECTORY/eu-lotl.xml" ]; then echo "Getting TSL (local LOTL)" - python3 scripts/TSLXMLDownloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False" + python3 scripts/tsl_xml_downloader.py --tslFile="$TSL_FILES_DIRECTORY/eu-lotl.xml" --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False" echo "Finished downloading TSL" else echo "Getting TSL (remote LOTL)" - python3 scripts/TSLXMLDownloader.py --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False" + python3 scripts/tsl_xml_downloader.py --tslTestFile="$TSL_FILES_DIRECTORY/$(basename 'https://ec.europa.eu/tools/lotl/eu-lotl.xml')" --countries="EE" --isDevBuild="False" echo "Finished downloading TSL" fi @@ -271,10 +269,8 @@ workflows: echo "Done moving TSLs" - name: Fetch default configuration script: | - echo "Cleaning swift-sh cache" - swift-sh --clean-cache echo "Fetching default configuration" - swift-sh SetupConfiguration/Sources/main.swift "https://id.eesti.ee" 4 "https://ec.europa.eu/tools/lotl/eu-lotl.xml" + python3 scripts/setup_configuration.py "https://id.eesti.ee" 4 "https://ec.europa.eu/tools/lotl/eu-lotl.xml" - name: Set up provisioning profiles settings on Xcode project script: xcode-project use-profiles - name: Run tests diff --git a/scripts/build-libcdoc-sim.sh b/scripts/build-libcdoc-sim.sh index f0010b81..401f8ad7 100755 --- a/scripts/build-libcdoc-sim.sh +++ b/scripts/build-libcdoc-sim.sh @@ -12,7 +12,7 @@ BUILD_DIR="$(pwd)/build/libcdoc-sim" INSTALL_DIR="$(pwd)/output/libcdoc-sim" OPENSSL_DIR="$(pwd)/../Downloads/libdigidocppFiles_1910/libdigidocpp.iphonesimulator" -DEPLOYMENT_TARGET="17.0" +DEPLOYMENT_TARGET="18.0" # ====== Clone repo if missing ====== if [ ! -d "${SOURCE_DIR}" ]; then diff --git a/scripts/build-openldap-iphoneos.sh b/scripts/build-openldap-iphoneos.sh index f3205e70..be16fa62 100755 --- a/scripts/build-openldap-iphoneos.sh +++ b/scripts/build-openldap-iphoneos.sh @@ -5,8 +5,8 @@ set -e # stop on any unhandled error cd "$(dirname "$0")/.." # ====== Configurable parameters ====== -: ${OPENLDAP:=openldap-2.6.10} -: ${IPHONEOS_DEPLOYMENT_TARGET:="17.0"} +: ${OPENLDAP:=openldap-2.6.13} +: ${IPHONEOS_DEPLOYMENT_TARGET:="18.0"} : ${PLATFORM_NAME:="iphoneos"} # Final merged output diff --git a/scripts/build-openldap-iphonesimulator.sh b/scripts/build-openldap-iphonesimulator.sh index f4f324da..facd2556 100755 --- a/scripts/build-openldap-iphonesimulator.sh +++ b/scripts/build-openldap-iphonesimulator.sh @@ -5,8 +5,8 @@ set -e # stop on any unhandled error cd "$(dirname "$0")/.." # ====== Configurable parameters ====== -: ${OPENLDAP:=openldap-2.6.10} -: ${IPHONEOS_DEPLOYMENT_TARGET:="17.0"} +: ${OPENLDAP:=openldap-2.6.13} +: ${IPHONEOS_DEPLOYMENT_TARGET:="18.0"} : ${PLATFORM_NAME:="iphonesimulator"} # Final merged output diff --git a/scripts/run-ci-tests.sh b/scripts/run-ci-tests.sh index 5fe7a8b1..0417ca66 100644 --- a/scripts/run-ci-tests.sh +++ b/scripts/run-ci-tests.sh @@ -71,7 +71,7 @@ for GROUP in "${MODULE_GROUPS[@]}"; do echo "Running test group: $GROUP" echo "----------------------------------------" - TEST_XCARGS="$COMMON_XCARGS" + TEST_XCARGS="$COMMON_XCARGS -skipPackagePluginValidation" for MODULE in $GROUP; do TEST_XCARGS+=" -only-testing:${MODULE}" done diff --git a/scripts/setup_configuration.py b/scripts/setup_configuration.py new file mode 100644 index 00000000..2c3d70c9 --- /dev/null +++ b/scripts/setup_configuration.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python3 + +# Copyright 2017 - 2026 Riigi Infosüsteemi Amet +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +# Download and verify the app's default central configuration. + +import base64 +import datetime +import json +import os +import subprocess +import sys +import tempfile +import urllib.request + +DEFAULT_CONFIG_BASE_URL = "https://id.eesti.ee" +DEFAULT_UPDATE_INTERVAL = 4 +DEFAULT_TSL_URL = "https://ec.europa.eu/tools/lotl/eu-lotl.xml" + +CONFIG_DIRECTORY = os.path.join( + "Modules", "ConfigLib", "Sources", "ConfigLib", "Resources", "config" +) + + +def log(message): + timestamp = datetime.datetime.now().strftime("%H:%M:%S") + print(f"[{timestamp}] {message}", flush=True) + + +def fetch_data(url): + with urllib.request.urlopen(url) as response: + return response.read().decode("utf-8") + + +def digest_for_public_key(public_key_pem): + der_body = "".join( + line for line in public_key_pem.splitlines() if "-----" not in line + ) + der = base64.b64decode(der_body) + length = len(der) + if 80 <= length <= 100: + return "sha256" + if 110 <= length <= 130: + return "sha384" + if 150 <= length <= 170: + return "sha512" + raise ValueError(f"Unknown public key size: {length} bytes") + + +def verify_signature(config_data, public_key_pem, signature_base64): + if not config_data or not public_key_pem or not signature_base64: + raise ValueError("Missing data for signature verification") + + digest = digest_for_public_key(public_key_pem) + signature_der = base64.b64decode(signature_base64) + + with tempfile.TemporaryDirectory() as tmp: + pub_path = os.path.join(tmp, "config.ecpub") + sig_path = os.path.join(tmp, "config.ecc") + data_path = os.path.join(tmp, "config.json") + + with open(pub_path, "w", encoding="utf-8") as pub_file: + pub_file.write(public_key_pem) + with open(sig_path, "wb") as sig_file: + sig_file.write(signature_der) + with open(data_path, "wb") as data_file: + data_file.write(config_data.encode("utf-8")) + + result = subprocess.run( + [ + "openssl", "dgst", f"-{digest}", + "-verify", pub_path, + "-signature", sig_path, + data_path, + ], + capture_output=True, + text=True, + ) + + if result.returncode != 0 or "Verified OK" not in result.stdout: + raise ValueError( + f"Signature verifying failed: {result.stdout.strip()} {result.stderr.strip()}" + ) + log("Signature verified successfully!") + + +def create_default_configuration(config_base_url, update_interval, version_serial): + download_date = datetime.datetime.now(datetime.timezone.utc).strftime( + "%Y-%m-%d %H:%M:%S" + ) + return ( + f"central-configuration-service.url={config_base_url}\n" + f"configuration.update-interval={update_interval}\n" + f"configuration.version-serial={version_serial}\n" + f"configuration.download-date={download_date}" + ) + + +def save_file(file_name, content): + os.makedirs(CONFIG_DIRECTORY, exist_ok=True) + file_path = os.path.join(CONFIG_DIRECTORY, file_name) + with open(file_path, "w", encoding="utf-8") as output_file: + output_file.write(content) + log(f"File saved: {os.path.abspath(file_path)}") + + +def setup_configuration(config_base_url, update_interval, config_tsl_url): + log("Starting configuration setup...") + log(f"Config Base URL: {config_base_url}") + log(f"Update Interval: {update_interval} hours") + log(f"Config TSL URL: {config_tsl_url}") + + log("1 / 4 - Downloading configuration data...") + config_data = fetch_data(f"{config_base_url}/config.json") + public_key = fetch_data(f"{config_base_url}/config.ecpub") + signature = fetch_data(f"{config_base_url}/config.ecc") + + log("2 / 4 - Verifying signature...") + verify_signature(config_data, public_key, signature) + + log("3 / 4 - Creating default configuration file...") + version_serial = json.loads(config_data)["META-INF"]["SERIAL"] + default_configuration = create_default_configuration( + config_base_url, update_interval, version_serial + ) + + log("4 / 4 - Saving and moving files...") + save_file("default-config.json", config_data) + save_file("default-config.ecpub", public_key) + save_file("default-config.ecc", signature) + save_file("configuration.properties", default_configuration) + + log("Default configuration initialized successfully!") + + +def main(): + args = sys.argv + config_base_url = args[1] if len(args) > 1 else DEFAULT_CONFIG_BASE_URL + update_interval = args[2] if len(args) > 2 else DEFAULT_UPDATE_INTERVAL + config_tsl_url = args[3] if len(args) > 3 else DEFAULT_TSL_URL + + try: + setup_configuration(config_base_url, update_interval, config_tsl_url) + except Exception as error: + log(f"Error: {error}") + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/scripts/TSLXMLDownloader.py b/scripts/tsl_xml_downloader.py similarity index 99% rename from scripts/TSLXMLDownloader.py rename to scripts/tsl_xml_downloader.py index 0c95f73d..3792f9c8 100644 --- a/scripts/TSLXMLDownloader.py +++ b/scripts/tsl_xml_downloader.py @@ -128,4 +128,4 @@ def main(self): if __name__ == "__main__": downloader = TSLDownloader() - downloader.main() \ No newline at end of file + downloader.main()