I have given modulus, public exponent and private exponent and I need to store those values securely on Android. How can I achieve that?
Most examples are creating public and private keys without getting n,d,e parameters. I have given those n,e,d values and want to store them securely and then use those values to create my ICC Public Key Certificate and also to sign my dynamic data.
How can I achieve that?
Use the Keystore System.
setEntry() allows you to store any object implementing KeyStore.Entry. You can simply implement your own subtype if you need to store data that doesn't fit the defaults. (There's RSAPrivateCrtKey though, which you can store in a PrivateKeyEntry.)
Probably, the only secure storage on an Android device would be Android Keystore System.
Key material never enters the application process.
and
Key material may be bound to the secure hardware.
(see http://developer.android.com/training/articles/keystore.html)
The problem with it is that you are restricted in what you can store in it. The KeyChain class allows you to store private keys and certificate chains. While, the Keystore Provider supports the following types of entries: PrivateKeyEntry, SecretKeyEntry, TrustedCertificateEntry according to docs. In practice, trying to put an instance of SecretKeyEntry causes an exception.
I suggest putting two entries in the keystore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With