diff options
Diffstat (limited to 'src/main/java/pl/edu/mimuw')
-rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/KeyGenerator.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/KeyGenerator.java b/src/main/java/pl/edu/mimuw/cloudatlas/KeyGenerator.java new file mode 100644 index 0000000..8581280 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/KeyGenerator.java @@ -0,0 +1,38 @@ +package pl.edu.mimuw.cloudatlas; + +import java.security.*; + +public class KeyGenerator { + private final static int NUM_KEY_BITS = 1024; + private final static String ENCRYPTION_ALGORITHM = "RSA"; + + // TODO + // TODO read key values from files + // TODO gradlew + private static void printKeyToFile(byte[] keyValue, String fileName) { + + } + + private static void generateKeys() throws NoSuchAlgorithmException { + PublicKey publicKey; + PrivateKey privateKey; + + KeyPairGenerator keyGenerator = + KeyPairGenerator.getInstance(ENCRYPTION_ALGORITHM); + keyGenerator.initialize(NUM_KEY_BITS); + KeyPair keyPair = keyGenerator.generateKeyPair(); + + privateKey = keyPair.getPrivate(); + printKeyToFile(privateKey.getEncoded(), "query_signer"); + publicKey = keyPair.getPublic(); + printKeyToFile(publicKey.getEncoded(), "query_signer.pub"); + } + + public static void main() { + try { + generateKeys(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + } +} |