Code Monkey home page Code Monkey logo

Comments (17)

ma-pe avatar ma-pe commented on June 30, 2024 1

After studying your README again, I could resolve it:
I forgot to replace the token to token: .secureEnclaveIfAvailable.

Thanks for your support!

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

Hey. Thanks for the kind words. ❤️

Can you try latest code from master? Seems like you are using release. Which simulator are you using?

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

I’m guessing you are using iOS 9 or something? I think your issue has been corrected in master. Sorry about the breaking api changes.

from ellipticcurvekeypair.

ma-pe avatar ma-pe commented on June 30, 2024

@hfossli
thank you very much for the fast response.

You were right, I was using release. I just updated to master and did the corresponding api-changes.

Testing on device (secure enclave) is still successful. Testing on simulator (keychain) still responds with an error, but now it is another one:

underlying(message: "Could not generate keypair.", error: Error Domain=NSOSStatusErrorDomain Code=-26276 "Could not generate keypair." UserInfo={NSLocalizedRecoverySuggestion=See https://www.osstatus.com/search/results?platform=all&framework=all&search=-26276, NSLocalizedDescription=Could not generate keypair.})

OSStatus.com sais: An internal error occured in the Security framework.

I tried different iPhone simulators featuring iOS 11.2.

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

Are you on main thread/queue? Try to be on another queue. Can you paste the code?

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

Also, make sure you delete and recreate the keys.

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

And try with these access flags

let publicAccessControl = EllipticCurveKeyPair.AccessControl(protection: kSecAttrAccessibleAlwaysThisDeviceOnly, flags: [])
            let privateAccessControl = EllipticCurveKeyPair.AccessControl(protection: kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly, flags: {
                return EllipticCurveKeyPair.Device.hasSecureEnclave ? [.userPresence, .privateKeyUsage] : [.userPresence]
            }())

from ellipticcurvekeypair.

ma-pe avatar ma-pe commented on June 30, 2024

The code I am using is:

struct KeyPair {
  static let manager: EllipticCurveKeyPair.Manager = {
    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: "n.sign.public",
      privateLabel: "n.sign.private",
      operationPrompt: "n Ident",
      publicKeyAccessControl: publicAccessControl,
      privateKeyAccessControl: privateAccessControl,
      token: .secureEnclave)
    return EllipticCurveKeyPair.Manager(config: config)
  }()
}

No difference for me on different queues :(

How do I remove keys?

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024
do {
      try KeyPair.manager.deleteKeypair()
} catch {
...
}

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

Or just delete the app before you install

from ellipticcurvekeypair.

ma-pe avatar ma-pe commented on June 30, 2024

Thank you.

I am now deleting the keypair before creating a new one. On device everything works fine, on simulator still the -26276-error.

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

I will try to recreate the bug on my end. I need xcode version, mac version, simulator version etc.

from ellipticcurvekeypair.

ma-pe avatar ma-pe commented on June 30, 2024

That would be great!

macOS High Sierra 10.13.3
XCode Version 9.2
iPhone simulators iOS 11.2
Deployment Target 10.0

do you need anything else?

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

Xcode build version and swift version would also be useful.

from ellipticcurvekeypair.

ma-pe avatar ma-pe commented on June 30, 2024

XCode Version 9.2 (9C40b)
Swift 3.2

from ellipticcurvekeypair.

hfossli avatar hfossli commented on June 30, 2024

Ah! That makes sense! Maybe a better error message could be nice in that case. Keeping it open until I fix that. Thanks!

from ellipticcurvekeypair.

Venkatasatishb avatar Venkatasatishb commented on June 30, 2024

why can I generate key pair from login screen?

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.