66import android .security .keystore .KeyProperties ;
77import android .util .Log ;
88
9- import net .sharksystem .SharkException ;
109import net .sharksystem .asap .ASAPException ;
1110import net .sharksystem .asap .ASAPSecurityException ;
1211import net .sharksystem .asap .android .apps .ASAPComponentNotYetInitializedException ;
1312import net .sharksystem .asap .util .DateTimeHelper ;
1413import net .sharksystem .crypto .ASAPCertificateImpl ;
1514import net .sharksystem .crypto .ASAPKeyStorage ;
16- import net .sharksystem .crypto .BasicKeyStore ;
1715import net .sharksystem .crypto .InMemoASAPKeyStorage ;
1816import net .sharksystem .crypto .SharkCryptoException ;
19- import net .sharksystem .persons .ASAPKeyStoreWithWriteAccess ;
20- import net .sharksystem .persons .ASAPPKI ;
21- import net .sharksystem .persons .SampleFullAsapPKIStorage ;
2217import net .sharksystem .persons .android .PersonsStorageAndroidComponent ;
2318
2419import java .io .IOException ;
3833/**
3934 * Overwrites key creation and add kex persistence to the more general super class
4035 */
41- public class AndroidASAPKeyStorage extends InMemoASAPKeyStorage
42- // SampleFullAsapPKIStorage
43- // implements ASAPKeyStoreWithWriteAccess, ASAPPKI, BasicKeyStore
44- {
36+ public class AndroidASAPKeyStorage extends InMemoASAPKeyStorage {
37+
38+ public static final String SN_ANDROID_DEFAULT_SIGNING_ALGORITHM = "SHA256withRSA/PSS" ;
4539
4640 private static final String KEYPAIR_CREATION_TIME = "ASAPCertificatesKeyPairCreationTime" ;
4741 public static final String KEYSTORE_NAME = "AndroidKeyStore" ;
@@ -70,9 +64,8 @@ public AndroidASAPKeyStorage(Context initialContext,
7064 /////////////////////////////////////////////////////////////////////////////////////////////
7165
7266 @ Override
73- public String getRSASigningAlgorithm () {
74- // return DEFAULT_SIGNATURE_ALGORITHM;
75- return "SHA256withECDSA" ;
67+ public String getAsymmetricSigningAlgorithm () {
68+ return SN_ANDROID_DEFAULT_SIGNING_ALGORITHM ;
7669 }
7770
7871 /*
@@ -87,12 +80,17 @@ public String getSymmetricKeyType() {
8780
8881 @Override
8982 public int getSymmetricKeyLen() {
90- return DEFAULT_AES_KEY_SIZE ;
83+ return DEFAULT_SYMMETRIC_KEY_SIZE ;
9184 }
9285
9386 @Override
94- public String getRSAEncryptionAlgorithm() {
95- return DEFAULT_RSA_ENCRYPTION_ALGORITHM;
87+ public String getAsymmetricEncryptionAlgorithm() {
88+ return DEFAULT_ASYMMETRIC_ENCRYPTION_ALGORITHM;
89+ }
90+
91+ @Override
92+ public String getAsymmetricSigningAlgorithm() {
93+ return DEFAULT_ASYMMETRIC_SIGNATURE_ALGORITHM;
9694 }
9795 */
9896
@@ -239,7 +237,11 @@ protected void reloadKeys() throws ASAPSecurityException {
239237 super .setPrivateKey (privateKeyEntry .getPrivateKey ());
240238 super .setPublicKey (privateKeyEntry .getCertificate ().getPublicKey ());
241239 } catch (KeyStoreException | UnrecoverableEntryException | NoSuchAlgorithmException e ) {
242- throw new ASAPSecurityException (e .getLocalizedMessage ());
240+ Log .d (this .getLogStart (), e .getLocalizedMessage ());
241+ e .printStackTrace ();
242+
243+ // maybe not generated yet.
244+ this .generateKeyPair ();
243245 }
244246 }
245247
0 commit comments