Skip to content

Commit

Permalink
Fix: Update in creating hash for transaction data in key binding JWT
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan committed Jan 10, 2025
1 parent 81f05b9 commit d7b6ad3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/eudiWalletOidcIos/Service/VerificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit d7b6ad3

Please sign in to comment.