Skip to content

Commit

Permalink
Remove DataKit dependency (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigabrtz authored Mar 7, 2024
1 parent 914f4c2 commit b163eec
Show file tree
Hide file tree
Showing 16 changed files with 955 additions and 212 deletions.
975 changes: 869 additions & 106 deletions OpenSSL-Swift.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

This file was deleted.

34 changes: 13 additions & 21 deletions OpenSSL-Swift.xcodeproj/xcshareddata/xcschemes/OpenSSL_iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
version = "1.7">
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
runPostActionsOnFailure = "NO">
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -27,9 +26,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "NO"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1FC1BE045B25FD2D54212E1"
BuildableName = "OpenSSL.framework"
BlueprintName = "OpenSSL_iOS"
ReferencedContainer = "container:OpenSSL-Swift.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -42,17 +49,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1FC1BE045B25FD2D54212E1"
BuildableName = "OpenSSL.framework"
BlueprintName = "OpenSSL_iOS"
ReferencedContainer = "container:OpenSSL-Swift.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -73,8 +69,6 @@
ReferencedContainer = "container:OpenSSL-Swift.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -92,8 +86,6 @@
ReferencedContainer = "container:OpenSSL-Swift.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
version = "1.7">
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
runPostActionsOnFailure = "NO">
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -27,9 +26,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "NO"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F70379BF82A1509A762AD7F5"
BuildableName = "OpenSSL.framework"
BlueprintName = "OpenSSL_macOS"
ReferencedContainer = "container:OpenSSL-Swift.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -42,17 +49,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F70379BF82A1509A762AD7F5"
BuildableName = "OpenSSL.framework"
BlueprintName = "OpenSSL_macOS"
ReferencedContainer = "container:OpenSSL-Swift.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -73,8 +69,6 @@
ReferencedContainer = "container:OpenSSL-Swift.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -92,8 +86,6 @@
ReferencedContainer = "container:OpenSSL-Swift.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
6 changes: 2 additions & 4 deletions Tests/OpenSSLTests/CMS/CMSContentInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// See the Licence for the specific language governing permissions and limitations under the Licence.
//

import DataKit
import Foundation
@testable import OpenSSL
import XCTest
Expand All @@ -27,7 +26,7 @@ final class CMSContentInfoTests: XCTestCase {
func testEncryptRSAOnly() throws {
// given
let x509rsa1 = try X509(pem: x509rsa1.data(using: .utf8)!)
let x509rsa2 = try X509(der: Base64.decode(string: x509rsa2))
let x509rsa2 = try X509(der: Data(base64Encoded: x509rsa2)!)
let recipients = [x509rsa1, x509rsa2]
let data = message.data(using: .utf8)!

Expand All @@ -48,8 +47,7 @@ final class CMSContentInfoTests: XCTestCase {
// OBJECT IDENTIFIER 1.2.840.113549.1.1.8 pkcs1-MGF (PKCS #1)
// SEQUENCE (1 elem)
// OBJECT IDENTIFIER 2.16.840.1.101.3.4.2.1 sha-256 (NIST Algorithm)
XCTAssertTrue(cms.derBytes?.hexString()
.contains(
XCTAssertTrue(cms.derBytes?.hexString().uppercased().contains(
"303806092A864886F70D010107302BA00D300B0609608648016503040201A11A301806092A864886F70D010108300B0609608648016503040201"
) ??
false)
Expand Down
5 changes: 2 additions & 3 deletions Tests/OpenSSLTests/Certificate/OCSPResponseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// See the Licence for the specific language governing permissions and limitations under the Licence.
//

import DataKit
import Foundation
@testable import OpenSSL
import XCTest
Expand All @@ -28,13 +27,13 @@ final class OCSPResponseTests: XCTestCase {
lazy var vauOcspResponse: OCSPResponse = {
let fileName = "OCSP/vau-oscp-response.der.base64"
let base64 = try! ResourceFileReader.readFileInResourceBundle(filePath: fileName, for: bundle)
return try! OCSPResponse(der: Base64.decode(data: base64))
return try! OCSPResponse(der: Data(base64Encoded: base64)!)
}()

lazy var vauOcspResponseNoKnownSignerCa: OCSPResponse = {
let fileName = "OCSP/vau-ocsp-response-no-signing-ca.der.base64"
let base64 = try! ResourceFileReader.readFileInResourceBundle(filePath: fileName, for: bundle)
return try! OCSPResponse(der: Base64.decode(data: base64))
return try! OCSPResponse(der: Data(base64Encoded: base64)!)
}()

func testOCSPResponseStatus() {
Expand Down
4 changes: 2 additions & 2 deletions Tests/OpenSSLTests/Certificate/X509Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ final class X509Tests: XCTestCase {

// then
XCTAssertEqual(
issuerData?.hexString(),
issuerData?.hexString().uppercased(),
"308184310B3009060355040613024445311F301D060355040A0C1667656D6174696B20476D6248204E4F542D56414C494431323030060355040B0C294B6F6D706F6E656E74656E2D4341206465722054656C656D6174696B696E667261737472756B7475723120301E06035504030C1747454D2E4B4F4D502D4341313020544553542D4F4E4C59"
)
XCTAssertTrue(String(data: issuerData!, encoding: .ascii)!.contains("GEM.KOMP-CA10 TEST-ONLY"))
Expand All @@ -92,7 +92,7 @@ final class X509Tests: XCTestCase {

// then
XCTAssertEqual(
subjectData?.hexString(),
subjectData?.hexString().uppercased(),
"3049310B300906035504061302444531263024060355040A0C1D67656D6174696B20544553542D4F4E4C59202D204E4F542D56414C49443112301006035504030C09494450205369672031"
)
XCTAssertTrue(String(data: subjectData!, encoding: .ascii)!.contains("IDP Sig 1"))
Expand Down
51 changes: 51 additions & 0 deletions Tests/OpenSSLTests/Data+Hex.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Copyright (c) 2024 gematik GmbH
//
// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an 'AS IS' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

extension DataProtocol {
var data: Data { .init(self) }
var hexa: String { map { .init(format: "%02x", $0) }.joined() }
}

struct HexaError: Error {}

extension StringProtocol {
func hexa() throws -> [UInt8] {
var startIndex = startIndex
return try (0 ..< count / 2).map { _ in
let endIndex = index(after: startIndex)
defer { startIndex = index(after: endIndex) }
guard let byte = UInt8(self[startIndex ... endIndex], radix: 16)
else { throw HexaError() }
return byte
}
}
}

extension Data {
/// Helping function to init Data from `hex` String
public init(hex hexString: String) throws {
try self.init(hexString.hexa().data)
}
}

extension Data {
/// Helping function to output a hexadecimal representation of `self`
public func hexString() -> String {
hexa
}
}
1 change: 0 additions & 1 deletion Tests/OpenSSLTests/EC/EllipticCurvePointTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
//

@_implementationOnly import COpenSSL
import DataKit
@testable import OpenSSL
import XCTest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// See the Licence for the specific language governing permissions and limitations under the Licence.
//

import DataKit
@testable import OpenSSL
import XCTest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// See the Licence for the specific language governing permissions and limitations under the Licence.
//

import DataKit
@testable import OpenSSL
import XCTest

Expand Down
1 change: 0 additions & 1 deletion Tests/OpenSSLTests/Mac/CMACTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// See the Licence for the specific language governing permissions and limitations under the Licence.
//

import DataKit
@testable import OpenSSL
import XCTest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// See the Licence for the specific language governing permissions and limitations under the Licence.
//

import DataKit
import Foundation
@testable import OpenSSL
import XCTest
Expand Down
1 change: 0 additions & 1 deletion Tests/OpenSSLTests/Signature/ECDSASignatureTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// See the Licence for the specific language governing permissions and limitations under the Licence.
//

import DataKit
import Foundation
@testable import OpenSSL
import XCTest
Expand Down
5 changes: 0 additions & 5 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ options:
deploymentTarget:
macOS: 10.15
iOS: 13.0
packages:
DataKit:
url: https://github.com/SwiftCommon/DataKit
version: 1.1.0
settings:
base:
CURRENT_PROJECT_VERSION: -1
Expand Down Expand Up @@ -56,5 +52,4 @@ targets:
- Tests/OpenSSLTests
dependencies:
- target: OpenSSL_${platform}
- package: DataKit
buildImplicitDependencies: true
6 changes: 3 additions & 3 deletions scripts/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ date "+%H:%M:%S"
# Setup project
scripts/setup

rm -f lib/*.a
scripts/build

# Lint
echo "Linting"
date "+%H:%M:%S"
scripts/lint

rm -f lib/*.a
scripts/build

# run tests
echo "Running tests…"
date "+%H:%M:%S"
Expand Down

0 comments on commit b163eec

Please sign in to comment.