A cryptography library and a SharedPreferences wrapper for Android that encrypts the content with 256 bit AES encryption. The Encryption key is securely stored in device's KeyStore.
562
stars
97
forks
source link
RSA Key Generation failed with "IllegalArgumentException: startDate == null" #32
I run into that issue on API 21 when init the SecurePreferenceStore with
SecuredPreferenceStore.init(context.getApplicationContext(), new DefaultRecoveryHandler());
The following Exception was thrown:
Caused by: java.lang.IllegalArgumentException: startDate == null at android.security.KeyPairGeneratorSpec.<init>(KeyPairGeneratorSpec.java:141) at android.security.KeyPairGeneratorSpec$Builder.build(KeyPairGeneratorSpec.java:482) at devliving.online.securedpreferencestore.EncryptionManager.generateRSAKeys(EncryptionManager.java:614) at devliving.online.securedpreferencestore.EncryptionManager.generateKey(EncryptionManager.java:480) at devliving.online.securedpreferencestore.EncryptionManager.setup(EncryptionManager.java:151) at devliving.online.securedpreferencestore.EncryptionManager.<init>(EncryptionManager.java:130) at devliving.online.securedpreferencestore.SecuredPreferenceStore.<init>(SecuredPreferenceStore.java:44) at devliving.online.securedpreferencestore.SecuredPreferenceStore.init(SecuredPreferenceStore.java:93) at devliving.online.securedpreferencestore.SecuredPreferenceStore.init(SecuredPreferenceStore.java:114)
The Problem is that both startDate is null when generating the RSA Key. Looking deeper in the code I realized that both startDate and endDate are not set (both are null) in the EncryptionManager:
I run into that issue on API 21 when init the SecurePreferenceStore with
SecuredPreferenceStore.init(context.getApplicationContext(), new DefaultRecoveryHandler());
The following Exception was thrown:
Caused by: java.lang.IllegalArgumentException: startDate == null at android.security.KeyPairGeneratorSpec.<init>(KeyPairGeneratorSpec.java:141) at android.security.KeyPairGeneratorSpec$Builder.build(KeyPairGeneratorSpec.java:482) at devliving.online.securedpreferencestore.EncryptionManager.generateRSAKeys(EncryptionManager.java:614) at devliving.online.securedpreferencestore.EncryptionManager.generateKey(EncryptionManager.java:480) at devliving.online.securedpreferencestore.EncryptionManager.setup(EncryptionManager.java:151) at devliving.online.securedpreferencestore.EncryptionManager.<init>(EncryptionManager.java:130) at devliving.online.securedpreferencestore.SecuredPreferenceStore.<init>(SecuredPreferenceStore.java:44) at devliving.online.securedpreferencestore.SecuredPreferenceStore.init(SecuredPreferenceStore.java:93) at devliving.online.securedpreferencestore.SecuredPreferenceStore.init(SecuredPreferenceStore.java:114)
The Problem is that both startDate is null when generating the RSA Key. Looking deeper in the code I realized that both startDate and endDate are not set (both are null) in the EncryptionManager: