m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-12 22:56:40 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-12 22:56:40 +0100
commita813ba681dc3fe4853da14ee6d1e61c495f79104 (patch)
tree2fb91d5c5ac347f97e5fb7ce0d31086d411e5fc7 /src/main
parentedc0b9821f2c95b13eb04036c28a2cc8312f69c4 (diff)
Make key generator skeleton
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/KeyGenerator.java38
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();
+ }
+ }
+}