Reputation: 35
I need to build an iOS application in which PGP keys will be created in order to encrypt and decrypt certain messages.
Since I'm new to PGP encryption in iOS is there some library that will allow me to create, keep and access the PGP keys as well as do the encryption and decryption using the keys.
I've implemented a backend and Android version using RSA algorithm with bouncy castle and OpenPGP in JAVA, however I will need to do the same with the iOS version. That means that the keys created in iOS should be in the same format and compatible with the ones created in the Android version.
Upvotes: 3
Views: 3957
Reputation: 1452
If you really need Bouncy Castle as-is, consider using j2objc
We recently encountered the same situation and so far have had luck with using j2objc to convert both Bouncy Castle and the code that was using it to Objective C. We needed strong compatibility between the iOS and Android versions of the app and didn't want to risk finding out there were incompatibilities with our solution down the road.
In order to convert Bouncy Castle we had to remove a handful of LDAP-related classes (which we didn't have a need for anyway) but beyond that it was pretty straightforward. We did this through trial and error, seeing what it couldn't convert and then just removing the file and trying again.
Using j2objc also had the advantage of letting us port over a lot of the business logic and avoid having to re-implement it in Swift/Objective-C. We just created some simple wrappers in Swift for the classes we needed to use directly and used those throughout the app.
Important Caveats
It's worth noting that this isn't a solution for everyone though, as mentioned in this comment on an issue there are some potential ramifications to using Bouncy Castle this way, so make sure you know what you're doing. It's also something that takes time and know-how to set up, between understanding potential Java classpath issues and figuring out how to pull in and convert everything you need (ideally using shell scripts or something similar to automate the process for when you have updates).
So unless you're using a lot of Bouncy Castle features this may come with additional complexities that make it not worthwhile, particularly the US Export Compliance piece.
Upvotes: 1
Reputation: 3784
Check out this projects: UNNetPGP or ObjectivePGP, this may do the job for you.
Upvotes: 3
Reputation: 46050
OpenPGP keys have a standard format defined in the RFC 4880 (two formats - binary and base64-encoded). As far as I know, it's BouncyCastle that can create keys in some custom non-standard format.
One of options is to use our SecureBlackbox (C++ edition) on iOS - it offers full scope of OpenPGP functionality including key generation and management.
Upvotes: 2
Reputation: 89509
I just did a cursory search (which I'm thinking you may have also done) and I found the "GPGTools" project, which is basically an Open Source OpenPGP implementation.
And since it's derived from OpenPGP, the keys you create should be compatible with the keys created on the Android side. They have an OLD (circa 2011) project page here, but the current code (which is in a state of flux) can be found on GitHub.
Upvotes: 0