Added support for exporting private key data
Occasionally, the private key needs to be exported, e. g. if the user needs to transfer their data to another device or wants to create a backup. Allowing developers to have this functionality doesn't hurt.
It may make sense to also implement a function that exports the private key data in a more standard format, similar to how the public key data is exportable as X.509. Perhaps for private key, it should be something like a PEM format (in essence a container around the key) that only includes the private key?
Once the private key getter is made public, it may also make sense to expose a function for obtaining the complete pair (where applicable) as a single data blob (again, PEM for example)
I agree. I'm currently trying to figure out how to convert the data to PEM format. The data appears to be much shorter than what the base64 part in a PEM usually takes up.
I found this relevant question on Stackoverflow, but I'm stuck in the same position. http://stackoverflow.com/questions/32955716/generating-a-pkcs12-key-from-seckeyref-on-ios
I can investigate this as well in the near future (hopefully), however, for the time being it might be worth looking into how the public key X.509 export/import works, seeing as a PEM file contains something similar. In terms of exporting the data, make sure that you have a private key to export.
Any update on this? Unfortunately, I haven't found the time to investigate this myself.
Hey @henrinormak, alas, nor have I. When I was working on it I was trying to look up the intricacies of the private key format, but never got around to implementing it.