Giter Site home page Giter Site logo

Import Private Keys about heimdall HOT 5 CLOSED

henrinormak avatar henrinormak commented on August 16, 2024
Import Private Keys

from heimdall.

Comments (5)

henrinormak avatar henrinormak commented on August 16, 2024

Currently there is no way to import a private key, but public one works fine via the appropriate initialisers, is that what you have in mind?

from heimdall.

chrstnwhlrt avatar chrstnwhlrt commented on August 16, 2024

No, I'm afraid I need to handle private keys as well as public keys. In my application the keys are (encrypted) stored on the server to allow key synchronization between devices. The android part works fine but with iOS I'm kind of stuck trying to use an key received by the server.

from heimdall.

henrinormak avatar henrinormak commented on August 16, 2024

And the private-public key-pair we are talking about is an RSA pair? It might be possible to create an initialiser to take not only public key data, but also that of the private key. I suppose if that's the case, there's should also be a way to export the private key from an instance. I might look at this later this week/month.

As a side note, are you stuck importing the key into Keychain? The number one issue there is the difference in format, iOS is very picky about the different headers/metadata in the data, for example it doesn't like the X.509 headers for public keys when importing.

from heimdall.

chrstnwhlrt avatar chrstnwhlrt commented on August 16, 2024

I think that would be a great method to allow an self-handled set of keys.
The format is a real headache using swift/ios, I'm still not sure how to
convert an existing modulus/exponent key in string/decimal format to a SecKeyRef.
Happy for any advise..

Also reported here:
http://stackoverflow.com/questions/30759803/get-seckeyref-from-modulus-exponent

from heimdall.

henrinormak avatar henrinormak commented on August 16, 2024

From what I gather, there are more components to a private key than just the exponent and modulus (which are components of the public key):
http://stackoverflow.com/questions/25066752/how-do-i-extract-the-private-key-components-n-and-d-from-a-private-rsa-key
http://www.herongyang.com/Cryptography/OpenSSL-RSA-Viewing-Components-of-RSA-Keys.html

Assuming one had all of the required components of the private key, on iOS they would then need to convert them into PKCS#12 blob (.p12), which could then be imported into the keychain via SecPKCS12Import function resulting in types that the keychain understands and that can be used.

This, however, currently seems like too much work for Heimdall to do, it is meant to be as lightweight as possible and support the most common cases of having access to either locally generated keypair or a stored public key. If a key was somehow imported to a specific tag in the Keychain, Heimdall would be able to search for it, meaning that if you were able to import the private key, Heimdall might be able to work with it. For the time being I think this will be the extent of supporting imported private keys in Heimdall.

If you manage to import a private key to the Keychain, feel free to submit a pull request. Even if this functionality should be kept clear of Heimdall (for now, anyway), it could serve as a good category/extension/utility.

from heimdall.

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.