|
3 | 3 | import net.sharksystem.asap.ASAPSecurityException; |
4 | 4 | import net.sharksystem.asap.util.Log; |
5 | 5 |
|
6 | | -import javax.crypto.KeyGenerator; |
7 | 6 | import javax.crypto.SecretKey; |
8 | 7 | import java.io.*; |
9 | 8 | import java.security.*; |
@@ -34,21 +33,10 @@ public BasicCryptoKeyStorage(CharSequence ownerID, KeyPair ownerKeyPair) { |
34 | 33 | } |
35 | 34 |
|
36 | 35 | public SecretKey generateSymmetricKey() throws ASAPSecurityException { |
37 | | - return BasicCryptoKeyStorage.generateSymmetricKey( |
| 36 | + return ASAPCryptoAlgorithms.generateSymmetricKey( |
38 | 37 | DEFAULT_SYMMETRIC_KEY_TYPE, DEFAULT_AES_KEY_SIZE); |
39 | 38 | } |
40 | 39 |
|
41 | | - public static SecretKey generateSymmetricKey(String keyType, int size) throws ASAPSecurityException { |
42 | | - try { |
43 | | - KeyGenerator gen = KeyGenerator.getInstance(keyType); |
44 | | - gen.init(size); |
45 | | - SecretKey secretKey = gen.generateKey(); |
46 | | - return secretKey; |
47 | | - } catch (NoSuchAlgorithmException e) { |
48 | | - throw new ASAPSecurityException("BasicCryptoKeyStorage", e); |
49 | | - } |
50 | | - } |
51 | | - |
52 | 40 | private String getLogStart() { |
53 | 41 | return this.getClass().getSimpleName() + ": "; |
54 | 42 | } |
@@ -147,10 +135,7 @@ public String getSymmetricKeyType() { |
147 | 135 |
|
148 | 136 | @Override |
149 | 137 | public boolean isOwner(CharSequence peerID) { |
150 | | - String ownerString = this.getOwner().toString(); |
151 | | - String peerIDString = peerID.toString(); |
152 | | - |
153 | | - return ownerString.equalsIgnoreCase(peerIDString); |
| 138 | + return ASAPCryptoAlgorithms.sameID(this.getOwner(), peerID); |
154 | 139 | } |
155 | 140 |
|
156 | 141 | @Override |
|
0 commit comments