Generating RSA Key Pairs Swift iOS - ios

I am trying to find a good library to do the following:
Generate RSA public and private key pairs
Encrypt / decrypt using keys
Sign using private key / verify with public key
Generate SHA256 hashes
I tried many libraries, but I can't seem to find something simple and straightforward with all these functions. In python pycrypto covers all this, it's really strange that there doesn't seem to be something like this available for Swift.

If you are using iOS 13 or above as the base SDK for your app then you should look at CryptoKit from Apple as it should cover what you are looking for.
https://developer.apple.com/documentation/cryptokit
If you need to support devices running versions of iOS older than iOS13 then you should look at CommonCrypto (also native to Apple) but if you can afford to only support iOS13 and above then CryptoKit is far better and easier to implement.

Related

is there a way to sign a string wth SHA1withRSA in dart?

Hello I am cosidering using dart for a project, but have a requirement where I need to be able to create a digest by signing a string with a key using SHA1withRSA.
So far the official crypto library in dart does not seem to support RSA encryption. There are other libraries but with very limited documentation.

Dart PKCS12 p12 pfx generation

Is there a way in dart to generate a file in the PKCS12 / .p12 / .pfx Format by passing in a Certificate and it's Private Key in pure Dart?
The BouncyCastle Port has no support for PKCS 12
For Android, there is the Bouncy Castle Library (Java), I tested it and it works like a charm.
For iOS I find it difficult to build a Plugin with the Open SSL Library linked to it because there is currently no way to tell Xcode to include C Code inside a Flutter Plugin.
dart:ffi would be an option, but it seems like dart has problems with C pointers, so I am not sure how to tackle this.

AES 128 Bit IOS Encryption [duplicate]

I'm new to encrypting in iOS and i'm stuck with AES128 encryption. Is there some pre-built library (perhaps OpenSSL) which i can use easily?
If so, how do I implement it and use it? Are there tutorials?
I've found several "easy" tutorials how to build OpenSSL and import it to Xcode, but none of them worked for me. Also, it needs to be compatible with iOS4, so solution via CommonCrypto doesn't seem to be a solution (since several essential methods are only iOS 5+ compatible).
Thanks for any kind of help, i'm pulling my hair out over this :)
This is written in Obj-C and allows for AES128 encryption of NSString and NSData.
I take it back. It uses CommonCrypt.
If anyone is still interested in this question i found a solution on http://dotmac.rationalmind.net/2009/02/aes-interoperability-between-net-and-iphone/ . On this page you can download very simple obj-c classes which are compatible with iOS4 and doesn't need any 3rd party libraries.

How to hash using ripemd128 on iOS / OS X?

I would like to hash a string using ripemd128 on iOS / OS X, but there does not seem to be core support for this, or any simple open source framework implementing it. Anyone has a solution?
If RIPEMD is not natively supported by the iOS SDK you can use an external library:
crypto++ For the integration with iOS you can see this page.
sphlib is a library implementing standard digest algorithms. It is written in ANSI C and should be compatible with iOS.

iOS library to Encrypt AES128 CFB no padding

Does anyone know of an iOS library that allows us to encrypt using AES128 CFB mode with not padding. Looks like commoncrypto does not support this .
Thanks
I'd suggest pushing OpenSSL into your project, if possible. A quick search for "ios openssl" returns a first hit for Easy inclusion of OpenSSL into iOS projects. See also AES interoperability between .Net and iPhone?
Beware that without padding, you'll need to feed the cipher blocks of the correct size.

Resources