From d7b6ad34448b5a8d878463406352589346c79faf Mon Sep 17 00:00:00 2001 From: "Joseph Milan K.A" Date: Fri, 20 Dec 2024 01:28:51 +0530 Subject: [PATCH] Fix: Update in creating hash for transaction data in key binding JWT --- .../eudiWalletOidcIos/Service/VerificationService.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/eudiWalletOidcIos/Service/VerificationService.swift b/Sources/eudiWalletOidcIos/Service/VerificationService.swift index 880fb0e..480811a 100644 --- a/Sources/eudiWalletOidcIos/Service/VerificationService.swift +++ b/Sources/eudiWalletOidcIos/Service/VerificationService.swift @@ -509,7 +509,7 @@ public class VerificationService: NSObject, VerificationServiceProtocol { for item in credentialsList { var claims: [String: Any] = [:] if let transactionData = transactionData, !transactionData.isEmpty { - claims["transaction_data_hashes"] = [SDJWTService.shared.calculateSHA256Hash(inputString: transactionData)] + claims["transaction_data_hashes"] = [self.generateHash(input: transactionData)] claims["transaction_data_hashes_alg"] = "sha-256" } claims["aud"] = clientID @@ -1288,6 +1288,13 @@ public class VerificationService: NSObject, VerificationServiceProtocol { return processedCredentials } + func generateHash(input: String) -> String? { + guard let data = input.data(using: .utf8) else { return nil } + + let hash = Data(SHA256.hash(data: data)) + + return hash.map { String(format: "%02x", $0) }.joined() + } func updatePath(in descriptor: InputDescriptor) -> InputDescriptor { var updatedDescriptor = descriptor guard var constraints = updatedDescriptor.constraints else { return updatedDescriptor }