is there a way to sign a string wth SHA1withRSA in dart? - 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.

Related

Is AES 256 CBC Crypto (Cipher) logic is there in Kotlin Multi Platform (KMM)?

I found AES encryption logic in Kotlin by using JavaX libraries. Since it's specific to java (Android) so it's not executing for iOS.
You can use krypto or libsodum wrapper libraries.
For example, with krypto library you can easily implement AES CBC in commanMain module by using these functions:
implementation("com.soywiz.korlibs.krypto:krypto:${Version.krypto}")
AES.encryptAesEcb(dataByteArray, keyByteArray, Padding.NoPadding)
AES.decryptAesEcb(dataByteArray, keyByteArray, Padding.ANSIX923Padding)

Generating RSA Key Pairs Swift 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.

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.

can we create a pass (.pkpass file) programmatically in Xcode?

Though we can add a pass in the pass application in iOS 6.0 programmatically given we have .pkpass file in our document directory or we get it from the server. But i have searched all the apple documentation in which steps are given to generate the .pkpass file manually.
Is this feasible to create a .pkpass file programmatically using Xcode.
The .pkpass file is composed of several components. The most difficult component that must be done programmatically is the signature of the manifest file. The other parts are trivial to assemble on the iPhone platform programmatically. You may note that Apple's documentation uses a shell command to compute this value using the OpenSSL library. I had to manually write a function that signed the manifest files using the OpenSSL C library, however it is not trivial due to a lack of examples and the complexity of the library. The signing function selected by Apple for the manifest is not present in their CommonCrypto framework.
Also, in order to sign these passes on the phone, the credentials must be present in the binary's bundle or compiled assets which is probably not a good idea to distribute if you would like to protect the integrity of your profile and signing identities.
So in summary: This is certainly possible, and is doable using the existing specifications and libraries. However, I would not recommend doing this on the phone. It is fairly difficult, and may introduce security risks if not done properly. Additionally, if you incorporate the OpenSSL library in your binary then you must report to Apple that you incorporate encryption in your device and must register for an ERN with the government. There may also be other export conditions on your code depending on your locality (but of course I am not a lawyer so this is a guess).

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