Skip to content

Commit ab2b3b2

Browse files
committed
Sign and encrypt works - going to debug decrypt and verify now.
1 parent ae105ca commit ab2b3b2

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed
0 Bytes
Binary file not shown.
135 Bytes
Binary file not shown.

app/libs/ASAPCertificate_0.1.0.jar

157 Bytes
Binary file not shown.

app/src/main/java/net/sharksystem/persons/android/PersonsStorageAndroidComponent.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
public class PersonsStorageAndroidComponent extends FullAsapPKIStorage //ASAPPKIImpl
4242
implements ASAPApplicationComponent, PersonsStorage, OwnerFactory /*InMemoPersonsStorageImpl*/ {
4343

44-
public static final String SN_ANDROID_DEFAULT_SIGNING_ALGORITHM = "SHA256withRSA/PSS";
4544
private static final String PERSONS_STORAGE_FILE_NAME = "sn2_personsStorageFile";
4645

4746
private static PersonsStorageAndroidComponent instance = null;
@@ -61,8 +60,7 @@ private PersonsStorageAndroidComponent(ASAPApplication asapApplication,
6160
asapApplication.getOwnerID(), // id
6261
asapApplication.getOwnerName() // name
6362
),
64-
keyStorage,
65-
SN_ANDROID_DEFAULT_SIGNING_ALGORITHM
63+
keyStorage
6664
);
6765

6866
// set up component helper

app/src/main/java/net/sharksystem/sharknet/android/AndroidASAPKeyStorage.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@
66
import android.security.keystore.KeyProperties;
77
import android.util.Log;
88

9-
import net.sharksystem.SharkException;
109
import net.sharksystem.asap.ASAPException;
1110
import net.sharksystem.asap.ASAPSecurityException;
1211
import net.sharksystem.asap.android.apps.ASAPComponentNotYetInitializedException;
1312
import net.sharksystem.asap.util.DateTimeHelper;
1413
import net.sharksystem.crypto.ASAPCertificateImpl;
1514
import net.sharksystem.crypto.ASAPKeyStorage;
16-
import net.sharksystem.crypto.BasicKeyStore;
1715
import net.sharksystem.crypto.InMemoASAPKeyStorage;
1816
import net.sharksystem.crypto.SharkCryptoException;
19-
import net.sharksystem.persons.ASAPKeyStoreWithWriteAccess;
20-
import net.sharksystem.persons.ASAPPKI;
21-
import net.sharksystem.persons.SampleFullAsapPKIStorage;
2217
import net.sharksystem.persons.android.PersonsStorageAndroidComponent;
2318

2419
import java.io.IOException;
@@ -38,10 +33,9 @@
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

Comments
 (0)