Skip to content

Commit

Permalink
Remove hashable extension on CFString. Fixes #107 (#125)
Browse files Browse the repository at this point in the history
* Remove hashable extension on CFString. Fixes #107

* Enable SwiftyRSATests support to tvos
  • Loading branch information
ldiqual authored Aug 8, 2018
1 parent 8118109 commit 8242afd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ SwiftyRSA Changelog
===================

# [master]
- Made compatible with Swift 4.2 and Xcode 10

- Made compatible with Swift 4.2 and Xcode 10
- Fixed a potential crash when building dictionaries with `CFString` values
[#107](https://github.com/TakeScoop/SwiftyRSA/issues/107)

# [1.4.0]

Expand Down
2 changes: 2 additions & 0 deletions SwiftyRSA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.takescoop.SwiftyRSATests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvsimulator appletvos watchos watchsimulator";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
Expand All @@ -799,6 +800,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.takescoop.SwiftyRSATests;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvsimulator appletvos watchos watchsimulator";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
};
Expand Down
20 changes: 2 additions & 18 deletions SwiftyRSA/SwiftyRSA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ import Security

public typealias Padding = SecPadding

extension CFString: Hashable {
public var hashValue: Int {
return (self as String).hashValue
}

static public func == (lhs: CFString, rhs: CFString) -> Bool {
return lhs as String == rhs as String
}
}

extension Data {
var hex: String {
return map { String(format: "%02hhx", $0) }.joined(separator: " ")
}
}

public enum SwiftyRSA {

static func base64String(pemEncoded pemString: String) throws -> String {
Expand Down Expand Up @@ -128,12 +112,12 @@ public enum SwiftyRSA {
/// - size: Indicates the total number of bits in this cryptographic key
/// - Returns: A touple of a private and public key
/// - Throws: Throws and error if the tag cant be parsed or if keygeneration fails
@available(iOS 10.0, *) @available(watchOS 3.0, *) @available(tvOS 10.0, *)
@available(iOS 10.0, watchOS 3.0, tvOS 10.0, *)
public static func generateRSAKeyPair(sizeInBits size: Int) throws -> (privateKey: PrivateKey, publicKey: PublicKey) {
return try generateRSAKeyPair(sizeInBits: size, applyUnitTestWorkaround: false)
}

@available(iOS 10.0, *) @available(watchOS 3.0, *) @available(tvOS 10.0, *)
@available(iOS 10.0, watchOS 3.0, tvOS 10.0, *)
static func generateRSAKeyPair(sizeInBits size: Int, applyUnitTestWorkaround: Bool = false) throws -> (privateKey: PrivateKey, publicKey: PublicKey) {

guard let tagData = UUID().uuidString.data(using: .utf8) else {
Expand Down
5 changes: 4 additions & 1 deletion SwiftyRSATests/KeyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,12 @@ class PrivateKeyTests: XCTestCase {
_ = try PrivateKey(pemNamed: "swiftyrsa-private-header-octetstring", in: bundle)
}

@available(iOS 10.0, *) @available(watchOS 3.0, *) @available(tvOS 10.0, *)
func test_generateKeyPair() throws {

guard #available(iOS 10.0, watchOS 3.0, tvOS 10.0, *) else {
return
}

let keyPair = try SwiftyRSA.generateRSAKeyPair(sizeInBits: 2048, applyUnitTestWorkaround: true)

let algorithm: SecKeyAlgorithm = .rsaEncryptionOAEPSHA512
Expand Down

0 comments on commit 8242afd

Please sign in to comment.