diff --git a/Package.resolved b/Package.resolved index d75f407..e446ecd 100644 --- a/Package.resolved +++ b/Package.resolved @@ -39,10 +39,10 @@ { "identity" : "joseswift", "kind" : "remoteSourceControl", - "location" : "https://github.com/niscy-eudiw/JOSESwift.git", + "location" : "https://github.com/airsidemobile/JOSESwift.git", "state" : { - "revision" : "518cedba79ef18867191811b161471298b6cb7c8", - "version" : "2.4.1-gcm" + "revision" : "c2664a902e75c0426a1d43132bd4babc6fd173d3", + "version" : "3.0.0" } }, { diff --git a/Package.swift b/Package.swift index 916fecf..78cebef 100644 --- a/Package.swift +++ b/Package.swift @@ -13,8 +13,8 @@ let package = Package( ], dependencies: [ .package( - url: "https://github.com/niscy-eudiw/JOSESwift.git", - exact: "2.4.1-gcm" + url: "https://github.com/airsidemobile/JOSESwift.git", + from: "3.0.0" ), .package( url: "https://github.com/birdrides/mockingbird.git", diff --git a/Sources/Main/Attestation/VerifierAttestationIssuer.swift b/Sources/Main/Attestation/VerifierAttestationIssuer.swift index ee54509..0b0543b 100644 --- a/Sources/Main/Attestation/VerifierAttestationIssuer.swift +++ b/Sources/Main/Attestation/VerifierAttestationIssuer.swift @@ -31,7 +31,7 @@ actor VerifierAttestationIssuer { let publicKey: SecKey = try! KeyController.generateECDHPublicKey(from: self.algAndKey.key) let verifier: Verifier? = .init( - verifyingAlgorithm: .ES256, + signatureAlgorithm: .ES256, key: publicKey ) return verifier @@ -85,7 +85,7 @@ actor VerifierAttestationIssuer { payload.toThrowingJSONData() ), signer: .init( - signingAlgorithm: algAndKey.algorithm, + signatureAlgorithm: algAndKey.algorithm, key: algAndKey.key )! ) diff --git a/Sources/Main/Encryption/ResponseSignerEncryptor.swift b/Sources/Main/Encryption/ResponseSignerEncryptor.swift index bca2252..9975b53 100644 --- a/Sources/Main/Encryption/ResponseSignerEncryptor.swift +++ b/Sources/Main/Encryption/ResponseSignerEncryptor.swift @@ -210,7 +210,7 @@ private extension ResponseSignerEncryptor { jwsAlgorithm: SignatureAlgorithm, keySet: WebKeySet, signingKey: SecKey - ) throws -> (key: WebKeySet.Key, signer: Signer) { + ) throws -> (key: WebKeySet.Key, signer: Signer) { let key = try keySet.keys.first { key in key.alg == jwsAlgorithm.rawValue } ?? { throw ValidatedAuthorizationError.invalidJWTWebKeySet }() @@ -220,7 +220,7 @@ private extension ResponseSignerEncryptor { } guard let signer = Signer( - signingAlgorithm: signatureAlgorithm, + signatureAlgorithm: signatureAlgorithm, key: signingKey ) else { throw ValidatedAuthorizationError.invalidSigningKey diff --git a/Sources/Main/Validators/AccessValidator.swift b/Sources/Main/Validators/AccessValidator.swift index ef36a24..c2d38db 100644 --- a/Sources/Main/Validators/AccessValidator.swift +++ b/Sources/Main/Validators/AccessValidator.swift @@ -212,7 +212,10 @@ public actor AccessValidator { let publicKey = try RSAPublicKey(data: key.toDictionary().toThrowingJSONData()) let secKey = try publicKey.converted(to: SecKey.self) - if let verifier = Verifier(verifyingAlgorithm: algorithm, key: secKey) { + if let verifier = Verifier( + signatureAlgorithm: algorithm, + key: secKey + ) { let isValid = jws.isValid(for: verifier) if !isValid { throw ValidatedAuthorizationError.validationError("Unable to verify signature") @@ -236,11 +239,17 @@ public extension AccessValidator { let keyType = keyAttributes?[kSecAttrKeyType as CFString] as? String if keyType == (kSecAttrKeyTypeRSA as String) { - if let verifier = Verifier(verifyingAlgorithm: .RS256, key: publicKey) { + if let verifier = Verifier( + signatureAlgorithm: .RS256, + key: publicKey + ) { _ = try jws.validate(using: verifier) } } else if keyType == (kSecAttrKeyTypeEC as String) { - if let verifier = Verifier(verifyingAlgorithm: .ES256, key: publicKey) { + if let verifier = Verifier( + signatureAlgorithm: .ES256, + key: publicKey + ) { _ = try jws.validate(using: verifier) } } diff --git a/Sources/Utilities/JOSE/JOSEController.swift b/Sources/Utilities/JOSE/JOSEController.swift index b61972c..2e75433 100644 --- a/Sources/Utilities/JOSE/JOSEController.swift +++ b/Sources/Utilities/JOSE/JOSEController.swift @@ -96,14 +96,20 @@ public class JOSEController { private extension JOSEController { func verifier(algorithhm: SignatureAlgorithm, publicKey: SecKey) throws -> Verifier { - guard let verifier = Verifier(verifyingAlgorithm: algorithhm, key: publicKey) else { + guard let verifier = Verifier( + signatureAlgorithm: algorithhm, + key: publicKey + ) else { throw JOSEError.invalidVerifier } return verifier } - func signer(algorithhm: SignatureAlgorithm, privateKey: SecKey) throws -> Signer { - guard let signer = Signer(signingAlgorithm: algorithhm, key: privateKey) else { + func signer(algorithhm: SignatureAlgorithm, privateKey: SecKey) throws -> Signer { + guard let signer = Signer( + signatureAlgorithm: algorithhm, + key: privateKey + ) else { throw JOSEError.invalidSigner } return signer diff --git a/Tests/Utilities/ResponseSignerEncryptorTests.swift b/Tests/Utilities/ResponseSignerEncryptorTests.swift index 4d5976b..e3cb370 100644 --- a/Tests/Utilities/ResponseSignerEncryptorTests.swift +++ b/Tests/Utilities/ResponseSignerEncryptorTests.swift @@ -73,7 +73,10 @@ final class ResponseSignerEncryptorTests: DiXCTest { // Verify signature let jws = try JWS(compactSerialization: response) - guard let verifier: Verifier = Verifier(verifyingAlgorithm: .RS256, key: publicKey) else { + guard let verifier: Verifier = Verifier( + signatureAlgorithm: .RS256, + key: publicKey + ) else { XCTAssert(false, "Invalid Verifier") return } diff --git a/Tests/Validators/JarJwtSignatureValidatorTests.swift b/Tests/Validators/JarJwtSignatureValidatorTests.swift index 3eb08ef..637a254 100644 --- a/Tests/Validators/JarJwtSignatureValidatorTests.swift +++ b/Tests/Validators/JarJwtSignatureValidatorTests.swift @@ -58,7 +58,7 @@ final class JarJwtSignatureValidatorTests: XCTestCase { "client_id_scheme": scheme ].toThrowingJSONData()), signer: Signer( - signingAlgorithm: algorithm, + signatureAlgorithm: algorithm, key: walletConfig.signingKey )! ) @@ -91,7 +91,7 @@ final class JarJwtSignatureValidatorTests: XCTestCase { "client_id_scheme": scheme ].toThrowingJSONData()), signer: Signer( - signingAlgorithm: algorithm, + signatureAlgorithm: algorithm, key: walletConfig.signingKey )! ) @@ -130,7 +130,7 @@ final class JarJwtSignatureValidatorTests: XCTestCase { "client_id_scheme": scheme ].toThrowingJSONData()), signer: Signer( - signingAlgorithm: algorithm, + signatureAlgorithm: algorithm, key: walletConfig.signingKey )! )