Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update iOS available version to 10.3 #48

Merged
merged 4 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
billabt marked this conversation as resolved.
Show resolved Hide resolved
if #available(macOS 10.14, iOS 12.0, watchOS 5.0, *) {

key = SecCertificateCopyKey(certData)

}
#endif
if key == nil {
billabt marked this conversation as resolved.
Show resolved Hide resolved

#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 {
billabt marked this conversation as resolved.
Show resolved Hide resolved
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