From a813ba681dc3fe4853da14ee6d1e61c495f79104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Sun, 12 Jan 2020 22:56:40 +0100 Subject: Make key generator skeleton --- .../java/pl/edu/mimuw/cloudatlas/KeyGenerator.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/KeyGenerator.java (limited to 'src') 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(); + } + } +} -- cgit v1.2.3