@Test public void generateNewKeys() throws Exception { KeyPair keyPair = encryptor.generateNewKeys(); assertThat(keyPair).isNotNull(); assertThat(keyPair.getPublicKey()).isNotNull(); assertThat(keyPair.getPrivateKey()).isNotNull(); LOGGER.info("Public key size: {}", keyPair.getPublicKey().getKeyBytes().length); LOGGER.info("Private key size: {}", keyPair.getPrivateKey().getKeyBytes().length); String b64encodedPrivateKey = Base64.getEncoder().encodeToString(keyPair.getPrivateKey().getKeyBytes()); LOGGER.info("base64 encoded private key: {}", b64encodedPrivateKey); LOGGER.info("base64 encoded private key length: {}", b64encodedPrivateKey.length()); String b64encodedPublicKey = Base64.getEncoder().encodeToString(keyPair.getPublicKey().getKeyBytes()); LOGGER.info("base64 encoded public key: {}", b64encodedPublicKey); LOGGER.info("base64 encoded public key length: {}", b64encodedPublicKey.length()); }
@Override public KeyPair generateNewKeys() { final java.security.KeyPair keyPair = keyPairGenerator.generateKeyPair(); return new KeyPair( PublicKey.from(keyToBytes(keyPair.getPublic())), PrivateKey.from(keyToBytes(keyPair.getPrivate()))); }
EllipticalCurveEncryptor implements Encryptor { @Override public KeyPair generateNewKeys() { final java.security.KeyPair keyPair = keyPairGenerator.generateKeyPair(); return new KeyPair( PublicKey.from(keyToBytes(keyPair.getPublic())), PrivateKey.from(keyToBytes(keyPair.getPrivate()))); } }
EllipticalCurveEncryptor implements Encryptor { @Override public KeyPair generateNewKeys() { final java.security.KeyPair keyPair = keyPairGenerator.generateKeyPair(); return new KeyPair( PublicKey.from(keyToBytes(keyPair.getPublic())), PrivateKey.from(keyToBytes(keyPair.getPrivate()))); } EllipticalCurveEncryptor(final String symmetricCipher, final String ellipticCurve);  EllipticalCurveEncryptor(final String symmetricCipher, final String ellipticCurve, int nonceLength, int sharedKeyLength); }
EllipticalCurveEncryptor implements Encryptor { @Override public KeyPair generateNewKeys() { final java.security.KeyPair keyPair = keyPairGenerator.generateKeyPair(); return new KeyPair( PublicKey.from(keyToBytes(keyPair.getPublic())), PrivateKey.from(keyToBytes(keyPair.getPrivate()))); } EllipticalCurveEncryptor(final String symmetricCipher, final String ellipticCurve);  EllipticalCurveEncryptor(final String symmetricCipher, final String ellipticCurve, int nonceLength, int sharedKeyLength); @Override SharedKey computeSharedKey(PublicKey publicKey, PrivateKey privateKey); @Override byte[] seal(byte[] message, Nonce nonce, PublicKey publicKey, PrivateKey privateKey); @Override byte[] open(byte[] cipherText, Nonce nonce, PublicKey publicKey, PrivateKey privateKey); @Override byte[] sealAfterPrecomputation(byte[] message, Nonce nonce, SharedKey sharedKey); @Override byte[] openAfterPrecomputation(byte[] cipherText, Nonce nonce, SharedKey sharedKey); @Override Nonce randomNonce(); @Override KeyPair generateNewKeys(); @Override SharedKey createSingleKey(); }
EllipticalCurveEncryptor implements Encryptor { @Override public KeyPair generateNewKeys() { final java.security.KeyPair keyPair = keyPairGenerator.generateKeyPair(); return new KeyPair( PublicKey.from(keyToBytes(keyPair.getPublic())), PrivateKey.from(keyToBytes(keyPair.getPrivate()))); } EllipticalCurveEncryptor(final String symmetricCipher, final String ellipticCurve);  EllipticalCurveEncryptor(final String symmetricCipher, final String ellipticCurve, int nonceLength, int sharedKeyLength); @Override SharedKey computeSharedKey(PublicKey publicKey, PrivateKey privateKey); @Override byte[] seal(byte[] message, Nonce nonce, PublicKey publicKey, PrivateKey privateKey); @Override byte[] open(byte[] cipherText, Nonce nonce, PublicKey publicKey, PrivateKey privateKey); @Override byte[] sealAfterPrecomputation(byte[] message, Nonce nonce, SharedKey sharedKey); @Override byte[] openAfterPrecomputation(byte[] cipherText, Nonce nonce, SharedKey sharedKey); @Override Nonce randomNonce(); @Override KeyPair generateNewKeys(); @Override SharedKey createSingleKey();  }