Generate key pair and signing (NIST P-256 EC key pair using ECDSA) using Local Authentication for iOS.
https://github.com/prongbang/SignatureBiometricSwift
pod 'SignatureBiometricSwift'
In your Package.swift
file, add SignatureBiometricSwift
dependency to corresponding targets:
let package = Package(
dependencies: [
.package(url: "https://github.com/prongbang/SignatureBiometricSwift.git", from: "1.0.10"),
],
)
<dict>
<key>NSFaceIDUsageDescription</key>
<string>This application wants to access your TouchID or FaceID</string>
</dict>
import SignatureBiometricSwift
let keyConfig = KeyConfig(name: "com.prongbang.signx.kSecAccKey")
let signatureBiometricManager = LocalSignatureBiometricManager.newInstance(
keyConfig: keyConfig
)
import SignatureBiometricSwift
let reason = "Please scan your fingerprint (or face) to authenticate"
signatureBiometricManager.createKeyPair(reason: reason) { result in
if result.status == SignatureBiometricStatus.success {
let publicKey = result.publicKey ?? ""
print("publicKey: \(publicKey)")
} else {
print("Error: \(result.status)")
}
}
import SignatureBiometricSwift
let clearText = "Hello"
signatureBiometricManager.sign(payload: clearText) { result in
if result.status == SignatureBiometricStatus.success {
print("signature: \(result.signature)")
} else {
print("Error: \(result.status)")
}
}
import SignatureBiometricSwift
let clearText = "Hello"
let reason = "Please scan your fingerprint (or face) to authenticate"
signatureBiometricManager.verify(reason: reason, payload: clearText, signature: signed) { result in
if result.status == SignatureBiometricStatus.success {
print("verified: \(result.verified)")
} else {
print("Error: \(result.status)")
}
}
import SignatureBiometricSwift
let changed = signatureBiometricManager.biometricsChanged()
signatureBiometricManager.biometricsPolicyStateReset()
https://developer.apple.com/documentation/security/seckeyalgorithm/