Skip to content

Commit

Permalink
Remove remaining whitespace changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Lees11 committed Feb 26, 2019
1 parent 7248cd9 commit fd6adcd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Sources/CryptorRSA/CryptorRSADigest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ extension Data {
case .sha512:
return CC_LONG(CC_SHA512_DIGEST_LENGTH)

case .gcm:
return CC_LONG(CC_SHA1_DIGEST_LENGTH)
case .gcm:
return CC_LONG(CC_SHA1_DIGEST_LENGTH)
}

#endif
Expand Down
58 changes: 29 additions & 29 deletions Sources/CryptorRSA/CryptorRSAKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ extension CryptorRSA {
public typealias NativeKey = OpaquePointer?

#else

public typealias NativeKey = SecKey

#endif

// MARK: Class Functions
Expand Down Expand Up @@ -400,7 +400,7 @@ extension CryptorRSA {

return PublicKey(with: key!)

#endif
#endif
}

// MARK: -- Private Key Creation
Expand Down Expand Up @@ -515,7 +515,7 @@ extension CryptorRSA {
let data = dataIn

#endif
return try PrivateKey(with: data)
}

Expand Down Expand Up @@ -558,15 +558,15 @@ extension CryptorRSA {

let dataIn = try Data(contentsOf: URL(fileURLWithPath: path))

#if os(Linux)
#if os(Linux)

let data = CryptorRSA.convertDerToPem(from: dataIn, type: .privateType)

#else
let data = dataIn
#endif
#else
let data = dataIn
#endif

return try PrivateKey(with: data)
}
Expand Down Expand Up @@ -668,10 +668,10 @@ extension CryptorRSA {
/// Create a key using a native key.
///
/// - Parameters:
/// - nativeKey: Pointer to RSA key structure.
/// - type: Type of key.
/// - nativeKey: Pointer to RSA key structure.
/// - type: Type of key.
///
/// - Returns: New `RSAKey` instance.
/// - Returns: New `RSAKey` instance.
///
internal init(with nativeKey: UnsafeMutablePointer<EVP_PKEY>, type: KeyType) {

Expand Down Expand Up @@ -791,22 +791,22 @@ extension CryptorRSA {
super.init(with: nativeKey, type: .publicType)
}

#if os(Linux) && !swift(>=4.1)
///
/// Create a key using a native key.
///
/// - Parameters:
/// - nativeKey: Pointer to RSA key structure.
///
/// - Returns: New `RSAKey` instance.
///
public init(with nativeKey: UnsafeMutablePointer<EVP_PKEY>) {
super.init(with: nativeKey, type: .publicType)
}
#endif
#if os(Linux) && !swift(>=4.1)
///
/// Create a key using a native key.
///
/// - Parameters:
/// - nativeKey: Pointer to RSA key structure.
///
/// - Returns: New `RSAKey` instance.
///
public init(with nativeKey: UnsafeMutablePointer<EVP_PKEY>) {
super.init(with: nativeKey, type: .publicType)
}
#endif
}

// MARK: -
Expand Down
13 changes: 7 additions & 6 deletions Sources/CryptorRSA/CryptorRSAUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
import CommonCrypto
import CommonCrypto
#elseif os(Linux)
import OpenSSL
#endif
Expand Down Expand Up @@ -49,6 +49,7 @@ public extension CryptorRSA {
static func createKey(from keyData: Data, type: CryptorRSA.RSAKey.KeyType) throws -> NativeKey {

let keyData = keyData

// Create a memory BIO...
let bio = BIO_new(BIO_s_mem())

Expand Down Expand Up @@ -151,15 +152,15 @@ public extension CryptorRSA {
/// Create a key from key data.
///
/// - Parameters:
/// - keyData: `Data` representation of the key.
/// - type: Type of key data.
/// - keyData: `Data` representation of the key.
/// - type: Type of key data.
///
/// - Returns: `SecKey` representation of the key.
/// - Returns: `SecKey` representation of the key.
///
static func createKey(from keyData: Data, type: CryptorRSA.RSAKey.KeyType) throws -> NativeKey {

var keyData = keyData
let keyClass = type == .publicType ? kSecAttrKeyClassPublic : kSecAttrKeyClassPrivate

let sizeInBits = keyData.count * MemoryLayout<UInt8>.size
Expand All @@ -173,7 +174,7 @@ public extension CryptorRSA {

throw Error(code: ERR_ADD_KEY, reason: "Couldn't create key reference from key data")
}
return key

}
Expand Down
6 changes: 3 additions & 3 deletions Tests/CryptorRSATests/CryptorRSATests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CryptorRSATests: XCTestCase {
let data = try Data(contentsOf: filePath)
let publicKey = try? CryptorRSA.createPublicKey(extractingFrom: data)
XCTAssertNotNil(publicKey)
XCTAssertTrue(publicKey?.type == .publicType)
XCTAssertTrue(publicKey!.type == .publicType)
}
}

Expand All @@ -113,7 +113,7 @@ class CryptorRSATests: XCTestCase {
let data = try Data(contentsOf: filePath)
let publicKey = try? CryptorRSA.createPublicKey(extractingFrom: data)
XCTAssertNotNil(publicKey)
XCTAssertTrue(publicKey?.type == .publicType)
XCTAssertTrue(publicKey!.type == .publicType)
}
}

Expand Down Expand Up @@ -207,7 +207,7 @@ class CryptorRSATests: XCTestCase {
XCTFail()
return
}

let keys = CryptorRSA.PublicKey.publicKeys(withPEM: input)
XCTAssertEqual(keys.count, 9)

Expand Down

0 comments on commit fd6adcd

Please sign in to comment.