Code Monkey home page Code Monkey logo

Comments (13)

hfossli avatar hfossli commented on July 17, 2024

I’m really not sure. https://youtu.be/fpaQpyU_QiM

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

Why do you want to cancel? What is the use case?

from ellipticcurvekeypair.

Vabs28 avatar Vabs28 commented on July 17, 2024

e.g. We prompt the user to authenticate using TouchID as soon as the app is opened. The app may also receive some authentication messages that he needs to action (select Accept/Reject on 2FA messages).

If the app receives an Authentication messages then we cancel the TouchID operation and show the authentication message.

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

I have rewritten some of the code so I'm now able to pass a LAContext to sign and decrypt. Sad thing is that I don't get to dismiss the LAContext once it is showing the fingerprint dialog. Do you know how?

Example

import UIKit
import LocalAuthentication

class ViewController: UIViewController {

    var context: LAContext! = LAContext()
    
    func createAccessControl(protection: CFString = kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, flags: SecAccessControlCreateFlags = [.userPresence, .privateKeyUsage]) -> SecAccessControl {
        var error: Unmanaged<CFError>?
        let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, protection, flags, &error)
        return accessControl!
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        delay(1.0, queue: .main) {
            self.decrypt()
        }
    }
    
    func decrypt() {
        
        let accessControl = createAccessControl()
        context.evaluateAccessControl(accessControl, operation: .useKeySign, localizedReason: "Sign") { (success, error) in
            DispatchQueue.main.async {
                if success {
                    let alert = UIAlertController(title: "Authenticated", message: "Ready to sign/decrypt", preferredStyle: .alert)
                    alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
                    self.show(alert, sender: nil)
                } else {
                    let alert = UIAlertController(title: "Failed to authenticate", message: "Error: \(error!)", preferredStyle: .alert)
                    alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
                    self.show(alert, sender: nil)
                }
            }
        }
        
        delay(3.0, queue: .main) {
            self.context.invalidate()
        }
    }
}

func delay( _ delay: Double, queue: DispatchQueue, completion: @escaping () -> () ) {
    queue.asyncAfter(deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) { () -> Void in
        completion()
    }
}

It doesn't seem promising.

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

If you are able to remove the dialog then I'll be happy to finish the rewrite to support LAContext.

from ellipticcurvekeypair.

Vabs28 avatar Vabs28 commented on July 17, 2024

Hi
I am new to Swift development.
I also tried similar thing, it doesn't close TouchID dialog.
Rather calling invalidate method doesn't do anything, you can still authenticate yourself with correct fingerprint.

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

So then I guess this is not possible... sadly. If you find a way to close it I’ll be more than happy to change the library

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

I have pushed my code to master. Whenever you sign or decrypt you will have the possibility of passing a LAContext.

Like this

let signature = try manager.sign(digest, authenticationContext: context)

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

In this archive you'll find two files and you'll see there's a bug with LAContext

Bug.zip

from ellipticcurvekeypair.

Vabs28 avatar Vabs28 commented on July 17, 2024

Thanks a lot

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

http://www.openradar.me/35069937

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

Apple thinks this is fixed in latest GM. Are you, @Vabs28, able to check this?
img_0331

from ellipticcurvekeypair.

hfossli avatar hfossli commented on July 17, 2024

It seems apple solved this when working with the LAContext directly. It doesn't work for me when the LAContext is presented by Security framework for some reason.

from ellipticcurvekeypair.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.