Skip to content

Commit

Permalink
Merge pull request #48 from IBM-Swift/ios10.3
Browse files Browse the repository at this point in the history
Update iOS available version to 10.3
  • Loading branch information
billabt authored Jun 28, 2019
2 parents 241ea93 + f27ffb8 commit 97485e4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Sources/CryptorRSA/CryptorRSA.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import Foundation
///
/// RSA Encryption/Decryption, Signing/Verification
///
@available(macOS 10.12, iOS 10.0, *)
@available(macOS 10.12, iOS 10.3, watchOS 3.3, tvOS 12.0, *)
public class CryptorRSA {

// MARK: Class Functions
Expand Down
2 changes: 1 addition & 1 deletion Sources/CryptorRSA/CryptorRSAConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Foundation

// MARK: -

@available(macOS 10.12, iOS 10.0, *)
@available(macOS 10.12, iOS 10.3, watchOS 3.3, tvOS 12.0, *)
public extension CryptorRSA {

// MARK: Constants
Expand Down
4 changes: 2 additions & 2 deletions Sources/CryptorRSA/CryptorRSADigest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extension Data {

#else

@available(macOS 10.12, iOS 10.0, *)
@available(macOS 10.12, iOS 10.0, watchOS 3.3, tvOS 12.0, *)
public var algorithmForSignature: SecKeyAlgorithm {

switch self {
Expand Down Expand Up @@ -218,7 +218,7 @@ extension Data {
}
}

@available(macOS 10.12, iOS 10.0, *)
@available(macOS 10.12, iOS 10.0, watchOS 3.3, tvOS 12.0, *)
public var alogrithmForEncryption: SecKeyAlgorithm {

switch self {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CryptorRSA/CryptorRSAErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Foundation

// MARK: -

@available(macOS 10.12, iOS 10.0, *)
@available(macOS 10.12, iOS 10.3, watchOS 3.3, tvOS 12.0, *)
extension CryptorRSA {

// MARK: Constants
Expand Down
23 changes: 18 additions & 5 deletions Sources/CryptorRSA/CryptorRSAKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Foundation

// MARK: -

@available(macOS 10.12, iOS 10.0, *)
@available(macOS 10.12, iOS 10.3, watchOS 3.3, tvOS 12.0, *)
extension CryptorRSA {

// MARK: Type Aliases
Expand Down Expand Up @@ -318,28 +318,41 @@ extension CryptorRSA {

throw Error(code: ERR_CREATE_CERT_FAILED, reason: "Unable to create certificate from certificate data.")
}

var key: SecKey? = nil
#if swift(>=4.2)
if #available(macOS 10.14, iOS 12.0, watchOS 5.0, *) {

key = SecCertificateCopyKey(certData)

}
#endif
if key == nil {

#if os(macOS)

// Now extract the public key from it...
var key: SecKey? = nil
let status: OSStatus = withUnsafeMutablePointer(to: &key) { ptr in

// Retrieves the public key from a certificate...
SecCertificateCopyPublicKey(certData, UnsafeMutablePointer(ptr))
}
if status != errSecSuccess || key == nil {
if status != errSecSuccess {

throw Error(code: ERR_EXTRACT_PUBLIC_KEY_FAILED, reason: "Unable to extract public key from data.")
}

#else

let key = SecCertificateCopyPublicKey(certData)
key = SecCertificateCopyPublicKey(certData)

#endif
}

return PublicKey(with: key!)
guard let createdKey = key else {
throw Error(code: ERR_EXTRACT_PUBLIC_KEY_FAILED, reason: "Unable to extract public key from data.")
}
return PublicKey(with: createdKey)

#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CryptorRSA/CryptorRSAUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import Foundation
///
/// Various RSA Related Utility Functions
///
@available(macOS 10.12, iOS 10.0, *)
@available(macOS 10.12, iOS 10.3, watchOS 3.3, tvOS 12.0, *)
public extension CryptorRSA {

#if os(Linux)
Expand Down
2 changes: 1 addition & 1 deletion Tests/CryptorRSATests/CryptorRSATests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import XCTest

@testable import CryptorRSA

@available(macOS 10.12, iOS 10.0, *)
@available(macOS 10.12, iOS 10.3, watchOS 3.3, tvOS 12.0, *)
class CryptorRSATests: XCTestCase {

/// Test for bundle usage.
Expand Down

0 comments on commit 97485e4

Please sign in to comment.