agens-no / EllipticCurveKeyPair

Sign, verify, encrypt and decrypt using the Secure Enclave
Other
709 stars 115 forks source link

LAContext passed when decrypting will not be respected #23

Closed ma-pe closed 6 years ago

ma-pe commented 6 years ago

I'd like to decrypt multiple things in a short amount of time. I don't want to prompt the user for authentication every time.

I am aware of the bug concerning touchIDAuthenticationAllowableReuseDuration (https://github.com/agens-no/EllipticCurveKeyPair/issues/9). Though I'd like to use the default time-limit (10 minutest) when passing an already authentified LAContext.

When passing the LAContext I am still prompted for authentication. I guess that's because the context is not regarded by the library:

@available(iOS 10.3, *) // API available at 10.0, but bugs made it unusable on versions lower than 10.3
public func decrypt(_ encrypted: Data, hash: Hash = .sha256, context: LAContext? = nil) throws -> Data {
  return try helper.decrypt(encrypted, privateKey: privateKey(), hash: hash)
}
hfossli commented 6 years ago

That’s a typo. The context should be forwarded. If you have time for a PR that would be 😍

hfossli commented 6 years ago

The private key should be resolved in same way as sign method is resolving the private key

ma-pe commented 6 years ago

Sure. I'll do it now :-)

ma-pe commented 6 years ago

I was fighting with my auto-code-cleanup-thingy. PR should be clean. :-)

I tested it. It works as expected for me now. Therefore I close the issue.