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

[86] Ignore [String] JWK parameters #116

Merged
6 commits merged into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 12 additions & 8 deletions JOSESwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
4E712FE52170A86300BA845E /* JWKx5cTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E712FE42170A86300BA845E /* JWKx5cTests.swift */; };
6505236E1FB4940100E0B1B1 /* AESEncrypter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6505236D1FB4940100E0B1B1 /* AESEncrypter.swift */; };
650523701FB494BE00E0B1B1 /* AESDecrypter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6505236F1FB494BE00E0B1B1 /* AESDecrypter.swift */; };
6506D9E920F4CA2000F34DD8 /* SymmetricKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6506D9E820F4CA2000F34DD8 /* SymmetricKeyTests.swift */; };
Expand Down Expand Up @@ -105,6 +106,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
4E712FE42170A86300BA845E /* JWKx5cTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWKx5cTests.swift; sourceTree = "<group>"; };
6505236D1FB4940100E0B1B1 /* AESEncrypter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AESEncrypter.swift; sourceTree = "<group>"; };
6505236F1FB494BE00E0B1B1 /* AESDecrypter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AESDecrypter.swift; sourceTree = "<group>"; };
6506D9E820F4CA2000F34DD8 /* SymmetricKeyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymmetricKeyTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -329,18 +331,19 @@
65E733CD1FEBE9670009EAC6 /* JWK */ = {
isa = PBXGroup;
children = (
65E733D21FEBFDB30009EAC6 /* JWKtoJSONTests.swift */,
65E733D41FEC031B0009EAC6 /* JWKRSAKeysTests.swift */,
65826AB320286B3A00AFFC46 /* JWKRSAEncodingTests.swift */,
65A103A0202B03BB00D22BF5 /* ASN1DERParsingTests.swift */,
6514ADCA2031DD27008A4DD3 /* ASN1DEREncodingTests.swift */,
6546D605203580C6007217FB /* JWKRSADecodingTests.swift */,
65A103A0202B03BB00D22BF5 /* ASN1DERParsingTests.swift */,
65A103A2202B0CDF00D22BF5 /* DataRSAPublicKeyTests.swift */,
658261482029E2D200B594ED /* SecKeyRSAPublicKeyTests.swift */,
6546D605203580C6007217FB /* JWKRSADecodingTests.swift */,
65826AB320286B3A00AFFC46 /* JWKRSAEncodingTests.swift */,
65E733D41FEC031B0009EAC6 /* JWKRSAKeysTests.swift */,
6536560A2035DC3900A3AC3B /* JWKSetCodingTests.swift */,
653656062035D6C700A3AC3B /* JWKSetCollectionTests.swift */,
65E733D21FEBFDB30009EAC6 /* JWKtoJSONTests.swift */,
4E712FE42170A86300BA845E /* JWKx5cTests.swift */,
65684A4C2031935200E56C68 /* RSAPublicKeyToDataTests.swift */,
65684A4E2031971A00E56C68 /* RSAPublicKeyToSecKeyTests.swift */,
653656062035D6C700A3AC3B /* JWKSetCollectionTests.swift */,
6536560A2035DC3900A3AC3B /* JWKSetCodingTests.swift */,
658261482029E2D200B594ED /* SecKeyRSAPublicKeyTests.swift */,
6506D9E820F4CA2000F34DD8 /* SymmetricKeyTests.swift */,
);
name = JWK;
Expand Down Expand Up @@ -634,6 +637,7 @@
C81DD9261FD6F07F00026024 /* (null) in Sources */,
C84BDE171FAB1CB60002B5D0 /* RSASignerTests.swift in Sources */,
C8EE14541FAC797500A616E4 /* RSAVerifierTests.swift in Sources */,
4E712FE52170A86300BA845E /* JWKx5cTests.swift in Sources */,
658261492029E2D200B594ED /* SecKeyRSAPublicKeyTests.swift in Sources */,
C86AC8CB1FCEC20F0007E611 /* AESEncrypterTests.swift in Sources */,
);
Expand Down
2 changes: 1 addition & 1 deletion JOSESwift/Sources/RSAKeyCodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension RSAPublicKey: Decodable {

// Other common parameters are optional.
var parameters: [String: String] = [:]
for key in commonParameters.allKeys {
for key in commonParameters.allKeys where key != .X509CertificateChain {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also ignore the keyOperations parameter, it is an array of strings as well.

Suggested change
for key in commonParameters.allKeys where key != .X509CertificateChain {
for key in commonParameters.allKeys where key != .X509CertificateChain && key != .keyOperations {

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be awesome if you could also add the workaround to the decoding of RSAPrivateKey here.

xavierLowmiller marked this conversation as resolved.
Show resolved Hide resolved
parameters[key.rawValue] = try commonParameters.decode(String.self, forKey: key)
}

Expand Down
37 changes: 37 additions & 0 deletions Tests/JWKx5cTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// JWKx5cTests.swift
// Tests
//
// Created by Xaver Lohmüller on 12.10.18.
//

import XCTest
@testable import JOSESwift

class JWKx5cTests: XCTestCase {
func testBuildingJWKSetShouldNotFailIfCertificatesArePresent() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test would probably fit nicely into JWKRSADecodingTests.swift.

XCTAssertNoThrow(try JWKSet(data: json))
}
}

private let json = """
{
"keys": [{
"kty": "RSA",
"e": "AQAB",
"use": "enc",
"x5t": "eGydA5CgawshHa8ULkMyn5gl9eI",
"kid": "kid-12345",
"x5c": ["Y2VydGlmaWNhdGUxMjM0NWRhdGEx"],
"n": "4r7_nnmRn9hppkfxt8p"
}, {
"kty": "RSA",
"e": "AQAB",
"use": "sig",
"x5t": "gpYbURn6jaHwNX9xhE2MGCIXPd0",
"kid": "kid-12346",
"x5c": ["Y2VydGlmaWNhdGUxMjM0NWRhdGEy"],
"n": "rTZj4tESZaNMpwsj"
}]
}
""".data(using: .utf8)!