Skip to content

Commit

Permalink
Support Swift Package Manager (Merge conflicts resolved) (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrownToys authored Nov 11, 2022
1 parent bd094a3 commit a047a71
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ Carthage/Checkouts
Carthage/Build

.DS_Store
.swiftpm
20 changes: 20 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// swift-tools-version:5.2
import PackageDescription

let package = Package(
name: "SwiftyRSA",
products: [
.library(
name: "SwiftyRSA",
type: .dynamic,
targets: ["SwiftyRSA"]),
],
dependencies: [
],
targets: [
.target(
name: "SwiftyRSA",
dependencies: [],
path: "Source")
]
)
10 changes: 5 additions & 5 deletions Source/ClearMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ public class ClearMessage: Message {

switch digestType {
case .sha1:
digest = (data as NSData).swiftyRSASHA1()
digest = data.swiftyRSASHA1()
case .sha224:
digest = (data as NSData).swiftyRSASHA224()
digest = data.swiftyRSASHA224()
case .sha256:
digest = (data as NSData).swiftyRSASHA256()
digest = data.swiftyRSASHA256()
case .sha384:
digest = (data as NSData).swiftyRSASHA384()
digest = data.swiftyRSASHA384()
case .sha512:
digest = (data as NSData).swiftyRSASHA512()
digest = data.swiftyRSASHA512()
}

return digest
Expand Down
53 changes: 53 additions & 0 deletions Source/Data+SHA.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Data+SHA.swift
//
//
// Created by Joanna Bednarz on 02/10/2020.
//

import Foundation
import CommonCrypto

extension Data {

func swiftyRSASHA1() -> Data {
var digest = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH))
withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
_ = CC_SHA1(buffer.baseAddress, CC_LONG(count), &digest)
}
return Data(digest)
}

func swiftyRSASHA224() -> Data {
var digest = [UInt8](repeating: 0, count: Int(CC_SHA224_DIGEST_LENGTH))
withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
_ = CC_SHA224(buffer.baseAddress, CC_LONG(count), &digest)
}
return Data(digest)
}

func swiftyRSASHA256() -> Data {
var digest = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
_ = CC_SHA256(buffer.baseAddress, CC_LONG(count), &digest)
}
return Data(digest)
}

func swiftyRSASHA384() -> Data {
var digest = [UInt8](repeating: 0, count: Int(CC_SHA384_DIGEST_LENGTH))
withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
_ = CC_SHA384(buffer.baseAddress, CC_LONG(count), &digest)
}
return Data(digest)
}

func swiftyRSASHA512() -> Data {
var digest = [UInt8](repeating: 0, count: Int(CC_SHA512_DIGEST_LENGTH))
withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
_ = CC_SHA512(buffer.baseAddress, CC_LONG(count), &digest)
}
return Data(digest)
}

}
19 changes: 0 additions & 19 deletions Source/NSData+SHA.h

This file was deleted.

54 changes: 0 additions & 54 deletions Source/NSData+SHA.m

This file was deleted.

19 changes: 0 additions & 19 deletions Source/SwiftyRSA.h

This file was deleted.

25 changes: 8 additions & 17 deletions SwiftyRSA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
2C9144BB1528A03A53582ADA158D7F71 /* NSData+SHA.m in Sources */ = {isa = PBXBuildFile; fileRef = D77B6899031A54A9F698D3430A599421 /* NSData+SHA.m */; };
47C6D29039697B1E71B856F957188617 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CEBB75D7D70F1A095D22C1D7BFD8773 /* Security.framework */; };
61C3EEC5859298BF282B0BA572B8FCAC /* NSData+SHA.h in Headers */ = {isa = PBXBuildFile; fileRef = 5AAC360BC9A1D1773D59C8E91186044E /* NSData+SHA.h */; settings = {ATTRIBUTES = (Private, ); }; };
902623FE2687278D00489B07 /* X509Certificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902623FD2687278D00489B07 /* X509Certificate.swift */; };
902623FF2687278D00489B07 /* X509Certificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902623FD2687278D00489B07 /* X509Certificate.swift */; };
902624002687278D00489B07 /* X509Certificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902623FD2687278D00489B07 /* X509Certificate.swift */; };
Expand All @@ -18,6 +16,9 @@
90EBFC8926AC32B3002B30E9 /* swiftyrsa-public-base64-X509-format.txt in Resources */ = {isa = PBXBuildFile; fileRef = 90EBFC8726AC32B2002B30E9 /* swiftyrsa-public-base64-X509-format.txt */; };
90EBFC8A26AC32B3002B30E9 /* swiftyrsa-public-base64-X509-format.txt in Resources */ = {isa = PBXBuildFile; fileRef = 90EBFC8726AC32B2002B30E9 /* swiftyrsa-public-base64-X509-format.txt */; };
B0981AE770653C8FE25311592E2BCE5E /* SwiftyRSA.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB44E2E8BE22C702325440A0F96410A /* SwiftyRSA.h */; settings = {ATTRIBUTES = (Private, ); }; };
9B4E2EB8252D8A0B0085F2B9 /* Data+SHA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B4E2EB7252D8A0B0085F2B9 /* Data+SHA.swift */; };
9B4E2EB9252D8A0B0085F2B9 /* Data+SHA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B4E2EB7252D8A0B0085F2B9 /* Data+SHA.swift */; };
9B4E2EBA252D8A0B0085F2B9 /* Data+SHA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B4E2EB7252D8A0B0085F2B9 /* Data+SHA.swift */; };
BF52D5FDEDA5DFCA62ECD03992601E82 /* SwiftyRSA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E84F551B29670A456D12366AA4C8E5 /* SwiftyRSA.swift */; };
C034317B1EC2D7E30019B7E8 /* Asn1Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034317A1EC2D7E30019B7E8 /* Asn1Parser.swift */; };
C03AF73A1EC7031900DE8166 /* SwiftyRSA+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06A33DA1E6E815A000EE6DC /* SwiftyRSA+ObjC.swift */; };
Expand All @@ -28,28 +29,24 @@
C057922521545CB00057F401 /* EncryptedMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E83E0C1ECD7F4200E9D63C /* EncryptedMessage.swift */; };
C057922621545CB00057F401 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0969FFB1D906B5C00E285C2 /* Key.swift */; };
C057922721545CB00057F401 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = C096A0071D9071CA00E285C2 /* Message.swift */; };
C057922921545CB00057F401 /* NSData+SHA.m in Sources */ = {isa = PBXBuildFile; fileRef = D77B6899031A54A9F698D3430A599421 /* NSData+SHA.m */; };
C057922A21545CB00057F401 /* PrivateKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E83E041ECD7DC400E9D63C /* PrivateKey.swift */; };
C057922B21545CB00057F401 /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E83DFC1ECD7DA300E9D63C /* PublicKey.swift */; };
C057922C21545CB00057F401 /* Signature.swift in Sources */ = {isa = PBXBuildFile; fileRef = C096A00B1D90754E00E285C2 /* Signature.swift */; };
C057922D21545CB00057F401 /* SwiftyRSA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E84F551B29670A456D12366AA4C8E5 /* SwiftyRSA.swift */; };
C057922E21545CB00057F401 /* SwiftyRSA+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06A33DA1E6E815A000EE6DC /* SwiftyRSA+ObjC.swift */; };
C057922F21545CB00057F401 /* SwiftyRSAError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03AF73D1ECAB2FC00DE8166 /* SwiftyRSAError.swift */; };
C057923021545CD00057F401 /* NSData+SHA.h in Headers */ = {isa = PBXBuildFile; fileRef = 5AAC360BC9A1D1773D59C8E91186044E /* NSData+SHA.h */; settings = {ATTRIBUTES = (Private, ); }; };
C0579231215464470057F401 /* SwiftyRSA.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB44E2E8BE22C702325440A0F96410A /* SwiftyRSA.h */; settings = {ATTRIBUTES = (Private, ); }; };
C0579240215465350057F401 /* ClearMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E83E081ECD7F3000E9D63C /* ClearMessage.swift */; };
C0579241215465350057F401 /* Asn1Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = C034317A1EC2D7E30019B7E8 /* Asn1Parser.swift */; };
C0579242215465350057F401 /* EncryptedMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E83E0C1ECD7F4200E9D63C /* EncryptedMessage.swift */; };
C0579243215465350057F401 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0969FFB1D906B5C00E285C2 /* Key.swift */; };
C0579244215465350057F401 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = C096A0071D9071CA00E285C2 /* Message.swift */; };
C0579245215465350057F401 /* NSData+SHA.m in Sources */ = {isa = PBXBuildFile; fileRef = D77B6899031A54A9F698D3430A599421 /* NSData+SHA.m */; };
C0579246215465350057F401 /* PrivateKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E83E041ECD7DC400E9D63C /* PrivateKey.swift */; };
C0579247215465350057F401 /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E83DFC1ECD7DA300E9D63C /* PublicKey.swift */; };
C0579248215465350057F401 /* Signature.swift in Sources */ = {isa = PBXBuildFile; fileRef = C096A00B1D90754E00E285C2 /* Signature.swift */; };
C0579249215465350057F401 /* SwiftyRSA.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E84F551B29670A456D12366AA4C8E5 /* SwiftyRSA.swift */; };
C057924A215465350057F401 /* SwiftyRSA+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06A33DA1E6E815A000EE6DC /* SwiftyRSA+ObjC.swift */; };
C057924B215465350057F401 /* SwiftyRSAError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03AF73D1ECAB2FC00DE8166 /* SwiftyRSAError.swift */; };
C057924C215465390057F401 /* NSData+SHA.h in Headers */ = {isa = PBXBuildFile; fileRef = 5AAC360BC9A1D1773D59C8E91186044E /* NSData+SHA.h */; settings = {ATTRIBUTES = (Private, ); }; };
C057924D2154653F0057F401 /* SwiftyRSA.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CB44E2E8BE22C702325440A0F96410A /* SwiftyRSA.h */; settings = {ATTRIBUTES = (Private, ); }; };
C0579257215465750057F401 /* SwiftyRSA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0579238215465040057F401 /* SwiftyRSA.framework */; };
C057925D2154659B0057F401 /* KeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C096A00F1D9083D000E285C2 /* KeyTests.swift */; };
Expand Down Expand Up @@ -117,13 +114,13 @@
3831A3C8228AFD8B386036394F642FB0 /* swiftyrsa-public.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "swiftyrsa-public.pem"; sourceTree = "<group>"; };
38E84F551B29670A456D12366AA4C8E5 /* SwiftyRSA.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyRSA.swift; sourceTree = "<group>"; };
47807FD4AF81104758D4EA9B778F5186 /* multiple-keys-testcase.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "multiple-keys-testcase.sh"; sourceTree = "<group>"; };
5AAC360BC9A1D1773D59C8E91186044E /* NSData+SHA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+SHA.h"; sourceTree = "<group>"; };
6E2D7A1B9C4D58D0887FB023C0E15594 /* swiftyrsa-private-headerless.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "swiftyrsa-private-headerless.pem"; sourceTree = "<group>"; };
7DF0A3222330CDFCF12918ED08519EB9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
902623FD2687278D00489B07 /* X509Certificate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = X509Certificate.swift; sourceTree = "<group>"; };
90EBFC8326AB08DF002B30E9 /* X509Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = X509Tests.swift; sourceTree = "<group>"; };
90EBFC8726AC32B2002B30E9 /* swiftyrsa-public-base64-X509-format.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "swiftyrsa-public-base64-X509-format.txt"; sourceTree = "<group>"; };
986B7C763D1B85C628621E89E7071B06 /* swiftyrsa-public.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "swiftyrsa-public.der"; sourceTree = "<group>"; };
9B4E2EB7252D8A0B0085F2B9 /* Data+SHA.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Data+SHA.swift"; sourceTree = "<group>"; };
9E21744A2073DB8AC7BAEB324D36D4DB /* TestUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = "<group>"; };
AC84097FE3BCDEAEE6370ADD41E9AE68 /* swiftyrsa-public-headerless.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "swiftyrsa-public-headerless.pem"; sourceTree = "<group>"; };
AD7F28E3936301CA24DF13E22196C73B /* multiple-keys-testcase.pem */ = {isa = PBXFileReference; lastKnownFileType = text; path = "multiple-keys-testcase.pem"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,7 +150,6 @@
C0E83E041ECD7DC400E9D63C /* PrivateKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivateKey.swift; sourceTree = "<group>"; };
C0E83E081ECD7F3000E9D63C /* ClearMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClearMessage.swift; sourceTree = "<group>"; };
C0E83E0C1ECD7F4200E9D63C /* EncryptedMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EncryptedMessage.swift; sourceTree = "<group>"; };
D77B6899031A54A9F698D3430A599421 /* NSData+SHA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+SHA.m"; sourceTree = "<group>"; };
EF193719CB8D4DDE8D347FF699311D1D /* swiftyrsa-private.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "swiftyrsa-private.pem"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -224,11 +220,10 @@
96EA18F422C03E377636BC2399DDD2C7 /* Supporting Files */,
C0E83E081ECD7F3000E9D63C /* ClearMessage.swift */,
C034317A1EC2D7E30019B7E8 /* Asn1Parser.swift */,
9B4E2EB7252D8A0B0085F2B9 /* Data+SHA.swift */,
C0E83E0C1ECD7F4200E9D63C /* EncryptedMessage.swift */,
C0969FFB1D906B5C00E285C2 /* Key.swift */,
C096A0071D9071CA00E285C2 /* Message.swift */,
5AAC360BC9A1D1773D59C8E91186044E /* NSData+SHA.h */,
D77B6899031A54A9F698D3430A599421 /* NSData+SHA.m */,
C0E83E041ECD7DC400E9D63C /* PrivateKey.swift */,
C0E83DFC1ECD7DA300E9D63C /* PublicKey.swift */,
902623FD2687278D00489B07 /* X509Certificate.swift */,
Expand Down Expand Up @@ -302,8 +297,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
61C3EEC5859298BF282B0BA572B8FCAC /* NSData+SHA.h in Headers */,
B0981AE770653C8FE25311592E2BCE5E /* SwiftyRSA.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -312,15 +305,13 @@
buildActionMask = 2147483647;
files = (
C0579231215464470057F401 /* SwiftyRSA.h in Headers */,
C057923021545CD00057F401 /* NSData+SHA.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C0579233215465040057F401 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
C057924C215465390057F401 /* NSData+SHA.h in Headers */,
C057924D2154653F0057F401 /* SwiftyRSA.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -561,7 +552,7 @@
C0E83E0D1ECD7F4200E9D63C /* EncryptedMessage.swift in Sources */,
902623FE2687278D00489B07 /* X509Certificate.swift in Sources */,
C096A00C1D90754E00E285C2 /* Signature.swift in Sources */,
2C9144BB1528A03A53582ADA158D7F71 /* NSData+SHA.m in Sources */,
9B4E2EB8252D8A0B0085F2B9 /* Data+SHA.swift in Sources */,
C096A0081D9071CA00E285C2 /* Message.swift in Sources */,
C0969FFC1D906B5C00E285C2 /* Key.swift in Sources */,
BF52D5FDEDA5DFCA62ECD03992601E82 /* SwiftyRSA.swift in Sources */,
Expand All @@ -581,10 +572,10 @@
C057922321545CB00057F401 /* ClearMessage.swift in Sources */,
902624002687278D00489B07 /* X509Certificate.swift in Sources */,
C057922421545CB00057F401 /* Asn1Parser.swift in Sources */,
9B4E2EBA252D8A0B0085F2B9 /* Data+SHA.swift in Sources */,
C057922521545CB00057F401 /* EncryptedMessage.swift in Sources */,
C057922621545CB00057F401 /* Key.swift in Sources */,
C057922721545CB00057F401 /* Message.swift in Sources */,
C057922921545CB00057F401 /* NSData+SHA.m in Sources */,
C057922A21545CB00057F401 /* PrivateKey.swift in Sources */,
C057922B21545CB00057F401 /* PublicKey.swift in Sources */,
C057922C21545CB00057F401 /* Signature.swift in Sources */,
Expand All @@ -601,6 +592,7 @@
C0579242215465350057F401 /* EncryptedMessage.swift in Sources */,
902623FF2687278D00489B07 /* X509Certificate.swift in Sources */,
C057924A215465350057F401 /* SwiftyRSA+ObjC.swift in Sources */,
9B4E2EB9252D8A0B0085F2B9 /* Data+SHA.swift in Sources */,
C0579243215465350057F401 /* Key.swift in Sources */,
C0579249215465350057F401 /* SwiftyRSA.swift in Sources */,
C0579247215465350057F401 /* PublicKey.swift in Sources */,
Expand All @@ -609,7 +601,6 @@
C0579244215465350057F401 /* Message.swift in Sources */,
C0579240215465350057F401 /* ClearMessage.swift in Sources */,
C0579241215465350057F401 /* Asn1Parser.swift in Sources */,
C0579245215465350057F401 /* NSData+SHA.m in Sources */,
C0579246215465350057F401 /* PrivateKey.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

0 comments on commit a047a71

Please sign in to comment.