File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed
Tests/PackageCollectionsSigningTests Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,10 @@ class RSAKeyTests: XCTestCase {
27
27
}
28
28
29
29
func testPublicKeyFromPEM( ) throws {
30
- XCTAssertNoThrow ( try RSAPublicKey ( pem: rsaPublicKey. bytes ) )
30
+ XCTAssertNoThrow ( try RSAPublicKey ( pem: rsaPublicKey. data ) )
31
31
}
32
32
33
33
func testPrivateKeyFromPEM( ) throws {
34
- XCTAssertNoThrow ( try RSAPrivateKey ( pem: rsaPrivateKey. bytes ) )
34
+ XCTAssertNoThrow ( try RSAPrivateKey ( pem: rsaPrivateKey. data ) )
35
35
}
36
36
}
Original file line number Diff line number Diff line change @@ -15,17 +15,17 @@ import XCTest
15
15
16
16
class RSAKeySigningTests : XCTestCase {
17
17
func test_signAndValidate_happyCase( ) throws {
18
- let privateKey = try RSAPrivateKey ( pem: rsaPrivateKey. bytes )
19
- let publicKey = try RSAPublicKey ( pem: rsaPublicKey. bytes )
18
+ let privateKey = try RSAPrivateKey ( pem: rsaPrivateKey. data )
19
+ let publicKey = try RSAPublicKey ( pem: rsaPublicKey. data )
20
20
21
21
let message = try JSONEncoder ( ) . encode ( [ " foo " : " bar " ] )
22
22
let signature = try privateKey. sign ( message: message)
23
23
XCTAssertTrue ( try publicKey. isValidSignature ( signature, for: message) )
24
24
}
25
25
26
26
func test_signAndValidate_mismatch( ) throws {
27
- let privateKey = try RSAPrivateKey ( pem: rsaPrivateKey. bytes )
28
- let publicKey = try RSAPublicKey ( pem: rsaPublicKey. bytes )
27
+ let privateKey = try RSAPrivateKey ( pem: rsaPrivateKey. data )
28
+ let publicKey = try RSAPublicKey ( pem: rsaPublicKey. data )
29
29
30
30
let jsonEncoder = JSONEncoder ( )
31
31
let message = try jsonEncoder. encode ( [ " foo " : " bar " ] )
Original file line number Diff line number Diff line change 8
8
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9
9
*/
10
10
11
+ import struct Foundation. Data
12
+
13
+ @testable import PackageCollectionsSigning
14
+
11
15
let ecPrivateKey = """
12
16
-----BEGIN EC PRIVATE KEY-----
13
17
MHcCAQEEIMFnwA1gjIFnFZim4B2QvoXJIG2L4B8nH1BBZFlotA24oAoGCCqGSM49
@@ -69,4 +73,8 @@ extension String {
69
73
var bytes : [ UInt8 ] {
70
74
[ UInt8] ( self . utf8)
71
75
}
76
+
77
+ var data : Data {
78
+ Data ( self . bytes)
79
+ }
72
80
}
You can’t perform that action at this time.
0 commit comments