Skip to content

Commit

Permalink
[fix] sdjwtvc verifier protovol, added x509 package
Browse files Browse the repository at this point in the history
  • Loading branch information
dtsiflit committed Sep 30, 2024
1 parent 7715625 commit fd0581e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 11 deletions.
27 changes: 27 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@
"version" : "0.15.0"
}
},
{
"identity" : "swift-asn1",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-asn1.git",
"state" : {
"revision" : "df5d2fcd22e3f480e3ef85bf23e277a4a0ef524d",
"version" : "1.2.0"
}
},
{
"identity" : "swift-certificates",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-certificates.git",
"state" : {
"revision" : "2f797305c1b5b982acaa6005d8a9f970cc4e97ff",
"version" : "1.5.0"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "81bee98e706aee68d39ed5996db069ef2b313d62",
"version" : "3.7.1"
}
},
{
"identity" : "swiftyjson",
"kind" : "remoteSourceControl",
Expand Down
7 changes: 6 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ let package = Package(
.package(
url: "https://github.com/beatt83/jose-swift.git",
from: "3.1.0"
),
.package(
url: "https://github.com/apple/swift-certificates.git",
from: "1.0.0"
)
],
targets: [
.target(
name: "eudi-lib-sdjwt-swift",
dependencies: [
"jose-swift",
.product(name: "SwiftyJSON", package: "swiftyjson")
.product(name: "SwiftyJSON", package: "swiftyjson"),
.product(name: "X509", package: "swift-certificates"),
],
path: "Sources",
plugins: [
Expand Down
29 changes: 19 additions & 10 deletions Sources/Verifier/SDJWTVerifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ public class SDJWTVerifier {
/// - claimVerifier: An optional closure to verify claims.
/// - Returns: A `Result` containing the verified `SignedSDJWT` or an error.
///
public func verifyIssuance(issuersSignatureVerifier: (JWS) throws -> SignatureVerifier,
claimVerifier: ((_ nbf: Int?, _ exp: Int?) throws -> ClaimsVerifier)? = nil) rethrows -> Result<SignedSDJWT, Error> {
public func verifyIssuance(
issuersSignatureVerifier: (JWS) throws -> SignatureVerifier,
claimVerifier: ((_ nbf: Int?, _ exp: Int?) throws -> ClaimsVerifier)? = nil
) rethrows -> Result<SignedSDJWT, Error> {
Result {
try self.verify(issuersSignatureVerifier: issuersSignatureVerifier, claimVerifier: claimVerifier).get()
try self.verify(
issuersSignatureVerifier: issuersSignatureVerifier,
claimVerifier: claimVerifier
).get()
}
}

Expand All @@ -95,9 +100,11 @@ public class SDJWTVerifier {
/// - keyBindingVerifier: An optional closure to verify key binding.
/// - Returns: A `Result` containing the verified `SignedSDJWT` or an error.
///
public func verifyPresentation(issuersSignatureVerifier: (JWS) throws -> SignatureVerifier,
claimVerifier: ((_ nbf: Int?, _ exp: Int?) throws -> ClaimsVerifier)? = nil,
keyBindingVerifier: ((JWS, JWK) throws -> KeyBindingVerifier)? = nil) -> Result<SignedSDJWT, Error> {
public func verifyPresentation(
issuersSignatureVerifier: (JWS) throws -> SignatureVerifier,
claimVerifier: ((_ nbf: Int?, _ exp: Int?) throws -> ClaimsVerifier)? = nil,
keyBindingVerifier: ((JWS, JWK) throws -> KeyBindingVerifier)? = nil
) -> Result<SignedSDJWT, Error> {
Result {
let commonVerifyResult = self.verify(issuersSignatureVerifier: issuersSignatureVerifier, claimVerifier: claimVerifier)
let sdjwt = try commonVerifyResult.get()
Expand All @@ -121,10 +128,12 @@ public class SDJWTVerifier {
}
}

public func verifyEnvelope(envelope: JWS,
issuersSignatureVerifier: (JWS) throws -> SignatureVerifier,
holdersSignatureVerifier: () throws -> SignatureVerifier,
claimVerifier: (_ audClaim: String, _ iat: Int) -> ClaimsVerifier) -> Result<JWS, Error> {
public func verifyEnvelope(
envelope: JWS,
issuersSignatureVerifier: (JWS) throws -> SignatureVerifier,
holdersSignatureVerifier: () throws -> SignatureVerifier,
claimVerifier: (_ audClaim: String, _ iat: Int) -> ClaimsVerifier
) -> Result<JWS, Error> {
Result {
try issuersSignatureVerifier(sdJwt.jwt).verify()
try holdersSignatureVerifier().verify()
Expand Down
22 changes: 22 additions & 0 deletions Sources/Verifier/SdJwtVcVerifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2023 European Commission
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
protocol SdJwtVcVerifierType {

}

class SdJwtVcVerifier {

}

0 comments on commit fd0581e

Please sign in to comment.