Skip to content

Commit

Permalink
Fix string encoding. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen authored May 7, 2021
1 parent 6ce792d commit 916b722
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DGCAWallet/Services/GatewayConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ struct GatewayConnection {
let set = CharacterSet(charactersIn: "0123456789").union(.capitalizedLetters)
tan = tan.uppercased().components(separatedBy: set.inverted).joined()

let tanHash = SHA256.stringDigest(input: Data(tan.encode()))
let tanHash = SHA256.stringDigest(input: Data(tan.data(using: .utf8) ?? .init()))
let certHash = cert.certHash
let pubKey = (X509.derPubKey(for: cert.keyPair) ?? Data()).base64EncodedString()

let toBeSigned = tanHash + certHash + pubKey
let toBeSignedData = Data(toBeSigned.encode())
let toBeSignedData = Data(toBeSigned.data(using: .utf8) ?? .init())
Enclave.sign(data: toBeSignedData, with: cert.keyPair, using: .ecdsaSignatureMessageX962SHA256) { sign, err in
guard let sign = sign, err == nil else {
return
Expand Down

0 comments on commit 916b722

Please sign in to comment.