Skip to content

Commit dbffd6c

Browse files
committed
that crypto architecture is still a mess.
1 parent 9380b65 commit dbffd6c

File tree

2 files changed

+54
-46
lines changed

2 files changed

+54
-46
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package net.sharksystem.crypto;
2+
3+
import net.sharksystem.asap.ASAPSecurityException;
4+
5+
import javax.crypto.SecretKey;
6+
import java.security.PrivateKey;
7+
import java.security.PublicKey;
8+
9+
public interface BasicCryptoSettings {
10+
String DEFAULT_RSA_ENCRYPTION_ALGORITHM = "RSA/ECB/PKCS1Padding";
11+
String DEFAULT_SYMMETRIC_KEY_TYPE = "AES";
12+
String DEFAULT_SYMMETRIC_ENCRYPTION_ALGORITHM = "AES/ECB/PKCS5Padding";
13+
// public static int DEFAULT_AES_KEY_SIZE = 256;
14+
int DEFAULT_AES_KEY_SIZE = 128; // TODO we can do better
15+
String DEFAULT_SIGNATURE_ALGORITHM = "SHA256withRSA";
16+
17+
/**
18+
*
19+
* @return private key of local device - for signing
20+
* @throws ASAPSecurityException
21+
*/
22+
PrivateKey getPrivateKey() throws ASAPSecurityException;
23+
24+
// debugging
25+
// PrivateKey getPrivateKey(CharSequence subjectID) throws ASAPSecurityException;
26+
27+
/**
28+
* @return public key of local device - for signing
29+
* @throws ASAPSecurityException
30+
*/
31+
PublicKey getPublicKey() throws ASAPSecurityException;
32+
33+
String getRSAEncryptionAlgorithm();
34+
35+
String getRSASigningAlgorithm();
36+
37+
SecretKey generateSymmetricKey() throws ASAPSecurityException;
38+
39+
String getSymmetricEncryptionAlgorithm();
40+
41+
String getSymmetricKeyType();
42+
43+
int getSymmetricKeyLen();
44+
45+
/**
46+
*
47+
* @param peerID
48+
* @return true if peerID is owners' id.
49+
*/
50+
boolean isOwner(CharSequence peerID);
51+
52+
CharSequence getOwner();
53+
}

src/net/sharksystem/crypto/BasicKeyStore.java

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,11 @@
66
import java.security.PrivateKey;
77
import java.security.PublicKey;
88

9-
public interface BasicKeyStore {
10-
String DEFAULT_RSA_ENCRYPTION_ALGORITHM = "RSA/ECB/PKCS1Padding";
11-
String DEFAULT_SYMMETRIC_KEY_TYPE = "AES";
12-
String DEFAULT_SYMMETRIC_ENCRYPTION_ALGORITHM = "AES/ECB/PKCS5Padding";
13-
// public static int DEFAULT_AES_KEY_SIZE = 256;
14-
int DEFAULT_AES_KEY_SIZE = 128; // TODO we can do better
15-
String DEFAULT_SIGNATURE_ALGORITHM = "SHA256withRSA";
16-
17-
/**
18-
*
19-
* @return private key of local device - for signing
20-
* @throws ASAPSecurityException
21-
*/
22-
PrivateKey getPrivateKey() throws ASAPSecurityException;
23-
24-
// debugging
25-
// PrivateKey getPrivateKey(CharSequence subjectID) throws ASAPSecurityException;
26-
9+
public interface BasicKeyStore extends BasicCryptoSettings {
2710
/**
28-
*
2911
* @param subjectID
3012
* @return public key of recipient - to encrypt
3113
* @throws ASAPSecurityException if key cannot be found
3214
*/
3315
PublicKey getPublicKey(CharSequence subjectID) throws ASAPSecurityException;
34-
35-
/**
36-
* @return public key of local device - for signing
37-
* @throws ASAPSecurityException
38-
*/
39-
PublicKey getPublicKey() throws ASAPSecurityException;
40-
41-
String getRSAEncryptionAlgorithm();
42-
43-
String getRSASigningAlgorithm();
44-
45-
SecretKey generateSymmetricKey() throws ASAPSecurityException;
46-
47-
String getSymmetricEncryptionAlgorithm();
48-
49-
String getSymmetricKeyType();
50-
51-
int getSymmetricKeyLen();
52-
53-
/**
54-
*
55-
* @param peerID
56-
* @return true if peerID is owners' id.
57-
*/
58-
boolean isOwner(CharSequence peerID);
59-
60-
CharSequence getOwner();
6116
}

0 commit comments

Comments
 (0)