diff options
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/App.java')
-rw-r--r-- | src/main/java/org/openslx/satellitedaemon/App.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/App.java b/src/main/java/org/openslx/satellitedaemon/App.java index 7c87401..6a4ebf4 100644 --- a/src/main/java/org/openslx/satellitedaemon/App.java +++ b/src/main/java/org/openslx/satellitedaemon/App.java @@ -109,25 +109,26 @@ public class App private static boolean checkConfig() { if (Identity.getOrganizationName() == null) return false; - // TODO: check members of identity.java. - // Testing encryption and description + // First check existing members (modulus, privExp, pubExp) of Identity. + if (!Identity.checkMembers()) + return false; + + // Testing encryption and description with given public and private key. + // Idea: creating random text for encrypting and decrypting again. Random rnd = new Random(); if (Identity.keySize() != -1) { int size = rnd.nextInt(Identity.keySize() - 1); BigInteger text = new BigInteger(size,rnd); RSAPublicKey pub = (RSAPublicKey) Identity.getPublicKey(); RSAPrivateKey priv = (RSAPrivateKey) Identity.getPrivateKey(); + // Encrypt. BigInteger cipher = text.modPow(pub.getPublicExponent(), pub.getModulus()); + // Decrypt again. BigInteger decrypted = cipher.modPow(priv.getPrivateExponent(), priv.getModulus()); boolean isPassed = text.equals(decrypted); return isPassed; } return false; -// System.out.println("--- RSA encryption test ---"); -// System.out.println("Is test passed: "+isPassed); -// System.out.println("Original text: "+text); -// System.out.println("Cipher text: "+cipher); -// System.out.println("Decrypted text: "+decrypted); } private static boolean genId(String organizationName) { |