-
Notifications
You must be signed in to change notification settings - Fork 351
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
Added support to read multiple public keys from a PEM file #22
Merged
ldiqual
merged 1 commit into
TakeScoop:master
from
greenantdotcom:convenience-pub-key-reading
Jul 21, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,5 @@ Carthage | |
Carthage/Checkouts | ||
|
||
Carthage/Build | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,4 +192,29 @@ class SwiftyRSATests: XCTestCase { | |
|
||
} | ||
|
||
/// See also: multiple-keys-testcase.sh for the generation of this file | ||
func testReadingPublicKeysFromComplexPEMFileWorksCorrectly(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lots of spaces in those test methods. Can you compact all these? |
||
let input = TestUtils.pemKeyString(name: "multiple-keys-testcase") | ||
|
||
XCTAssertEqual( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a one liner. |
||
SwiftyRSA().publicKeysFromString(input).count, | ||
9 | ||
) | ||
} | ||
|
||
func testReadingPublicKeysFromEmptyPEMFileReturnsEmptyArray(){ | ||
XCTAssertEqual( | ||
SwiftyRSA().publicKeysFromString("").count, | ||
0 | ||
) | ||
} | ||
|
||
func testReadingPublicKeysFromPrivateKeyPEMFileReturnsEmptyArray(){ | ||
let input = TestUtils.pemKeyString(name: "swiftyrsa-private") | ||
|
||
XCTAssertEqual( | ||
SwiftyRSA().publicKeysFromString(input).count, | ||
0 | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// | ||
// Wildfire.swift | ||
// SwiftyRSA | ||
// | ||
// Created by Mark Hughes on 7/15/16. | ||
// Copyright © 2016 Scoop. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import SwiftyRSA | ||
import Security | ||
|
||
public protocol SwiftyRSABackendProtocol { | ||
func generateHash(input: String, hashType: DigestType) -> String; | ||
} | ||
|
||
public class SecTransformBackend : NSObject, SwiftyRSABackendProtocol { | ||
public func generateHash(input: String, hashType: DigestType) -> String { | ||
// Total sham mock | ||
|
||
let response = ""; | ||
|
||
return response; | ||
} | ||
} | ||
|
||
public class MockBackend : NSObject, SwiftyRSABackendProtocol { | ||
public func generateHash(input: String, hashType: DigestType) -> String { | ||
return ""; | ||
} | ||
} | ||
|
||
protocol ConcreteBackendTests { | ||
func testSHA256Reference(); | ||
} | ||
|
||
class ComposableTester { | ||
|
||
} | ||
|
||
class SecTransformBackendTest : XCTestCase, ConcreteBackendTests { | ||
func getInstance(){ | ||
return SecTransformBackend() | ||
} | ||
|
||
func testSHA256Reference() { | ||
XCTAssert( | ||
|
||
) | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
class Wildfire: XCTestCase { | ||
|
||
override func setUp() { | ||
super.setUp() | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
override func tearDown() { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
super.tearDown() | ||
} | ||
|
||
func testExample() { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
} | ||
|
||
func testPerformanceExample() { | ||
// This is an example of a performance test case. | ||
self.measureBlock { | ||
// Put the code you want to measure the time of here. | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for making this unavailable from objc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[SecKeyRef]
cannot be translated to Objective-C because NSArray doesn't supportNSArray<SecKeyRef>
- the@nonobjc
is there to be sure that anyone reading the code sees that. I'll add a note as to why.I added it because when I went to test this from ObjC I couldn't see the method, and couldn't figure out why for a while.