Hi
Here is my code:
Singing data:
Code Block private func Signing(dataToBeSigned: String) -> String {| do { |
| let digest = dataToBeSigned.data(using: .utf8)! |
| let singedData = try Shared.keypair.sign(digest, hash: .sha256) |
| let signature = singedData.base64EncodedString() |
| return signature |
| } catch { |
| return "Cannot sign data" |
| } |
| } |
I call it from this code:
Code Block | if(call.method == "Register") { |
| guard let args = call.arguments else { |
| |
| return |
| } |
| if let myArgs = args as? [String: Any], |
| let bla1 = myArgs["bla1"] as? String, |
| let bla2 = myArgs["bla2"] as? String { |
| let signatureBla1 = self?.Signing(dataToBeSigned: bla1) |
| let signatureBla2 = self?.Signing(dataToBeSigned: bla2) |
| let publicKey = self?.getPublicKey() |
| var list = [String]() |
| list.append(publicKey!) |
| list.append(signatureBla1!) |
| list.append(signatureBla2!) |
| result(list) |
| } else { |
| result("iOS could not extract flutter arguments in method: (sendParams)") |
| } |
| self?.Register(result: result) |
| } |
Code Block | call.method == "Register" |
is use to call Register Function from Flutter using MethodChannel.
Here is Shared:
Code Block | struct Shared { |
| static let keypair: EllipticCurveKeyPair.Manager = { |
| EllipticCurveKeyPair.logger = { print($0) } |
| let publicAccessControl = EllipticCurveKeyPair.AccessControl(protection: kSecAttrAccessibleAlwaysThisDeviceOnly, flags: []) |
| let privateAccessControl = EllipticCurveKeyPair.AccessControl(protection: kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly, flags: { |
| return EllipticCurveKeyPair.Device.hasSecureEnclave ? [.userPresence, .privateKeyUsage] : [.userPresence] |
| }()) |
| let config = EllipticCurveKeyPair.Config( |
| publicLabel: "no.agens.sign.public", |
| privateLabel: "no.agens.sign.private", |
| operationPrompt: "Sign transact ion", |
| publicKeyAccessControl: publicAccessControl, |
| privateKeyAccessControl: privateAccessControl, |
| token: .secureEnclaveIfAvailable) |
| return EllipticCurveKeyPair.Manager(config: config) |
| }() |
| } |
The sign the data and show the Face ID prompt I use this source code:
agens-no/EllipticCurveKeyPairThe issue happen exactly in the shared source code of EllipticCurveKeyPair.swift line 366
Code Block | let status = SecItemCopyMatching(query as CFDictionary, &raw) |
if other iphone the status 0 but in iphone 12 pro and pro max status -25300.
the query always passed in all iPhone like this
Code Block | SecItemCopyMatching: ["kcls": 1, "u_AuthCtx": LAContext[2264:5], "u_OpPrompt": "Sign User", "class": keys, "labl": "no.agens.sign.private", "r_Ref": true] |
I hope this will help you to understand the problem.