Asymmetric Key Generation in Flutter
When developing applications focused on security and encryption, we may need to use Asymmetric Keys in order to sign and verify data before sending it to our servers. Though the encryption algorithms may be complex, we can use the help of libraries such as Pointy Castle to integrate it in our Flutter applications.
PointyCastle is a port of Java’s Bouncy Castle and it provides us the implementation for the most commonly used cryptography algorithms. With this library we will create the main methods to build an app example, that is able to generate a new asymmetric key pair and sign a message with a private key.
In order to achieve this result, we will have to go through the following steps:
- Generating a RSA KeyPair using PointyCastle’s
RSAKeyGenerator
- Using
Isolate
for optimizing the generation of a KeyPair - Encoding Asymmetric Keys to Plain Text
- Signing a message with a Private Key
We will also look into the curious case of generating keys in a physical iOS device in Debug Mode.