@Test public void generateNewKeysSodiumSuccess() { final KeyPair result = this.jnacl.generateNewKeys(); assertThat(result).isNotNull(); assertThat(result.getPrivateKey()).isNotNull(); assertThat(result.getPublicKey()).isNotNull(); assertThat(result.getPublicKey().getKeyBytes()).hasSize(32); assertThat(result.getPrivateKey().getKeyBytes()).hasSize(32); verify(this.secretBox).cryptoBoxKeypair(any(byte[].class), any(byte[].class)); }
@Override public KeyPair generateNewKeys() { final byte[] publicKey = new byte[crypto_secretbox_PUBLICKEYBYTES]; final byte[] privateKey = new byte[crypto_secretbox_SECRETKEYBYTES]; LOGGER.info("Generating new keypair..."); final int jnaclResult = secretBox.cryptoBoxKeypair(publicKey, privateKey); if (jnaclResult == -1) { LOGGER.error("Unable to generate a new keypair!"); throw new EncryptorException("jnacl could not generate a new public/private keypair"); } final PublicKey pubKey = PublicKey.from(publicKey); final PrivateKey privKey = PrivateKey.from(privateKey); LOGGER.info("Generated new key pair with public key {}", pubKey); LOGGER.debug("Generated public key {} and private key {}", pubKey, privKey); return new KeyPair(pubKey, privKey); }
Jnacl implements Encryptor { @Override public KeyPair generateNewKeys() { final byte[] publicKey = new byte[crypto_secretbox_PUBLICKEYBYTES]; final byte[] privateKey = new byte[crypto_secretbox_SECRETKEYBYTES]; LOGGER.info("Generating new keypair..."); final int jnaclResult = secretBox.cryptoBoxKeypair(publicKey, privateKey); if (jnaclResult == -1) { LOGGER.error("Unable to generate a new keypair!"); throw new EncryptorException("jnacl could not generate a new public/private keypair"); } final PublicKey pubKey = PublicKey.from(publicKey); final PrivateKey privKey = PrivateKey.from(privateKey); LOGGER.info("Generated new key pair with public key {}", pubKey); LOGGER.debug("Generated public key {} and private key {}", pubKey, privKey); return new KeyPair(pubKey, privKey); } }
Jnacl implements Encryptor { @Override public KeyPair generateNewKeys() { final byte[] publicKey = new byte[crypto_secretbox_PUBLICKEYBYTES]; final byte[] privateKey = new byte[crypto_secretbox_SECRETKEYBYTES]; LOGGER.info("Generating new keypair..."); final int jnaclResult = secretBox.cryptoBoxKeypair(publicKey, privateKey); if (jnaclResult == -1) { LOGGER.error("Unable to generate a new keypair!"); throw new EncryptorException("jnacl could not generate a new public/private keypair"); } final PublicKey pubKey = PublicKey.from(publicKey); final PrivateKey privKey = PrivateKey.from(privateKey); LOGGER.info("Generated new key pair with public key {}", pubKey); LOGGER.debug("Generated public key {} and private key {}", pubKey, privKey); return new KeyPair(pubKey, privKey); } Jnacl(final SecureRandom secureRandom, final SecretBox secretBox); }
Jnacl implements Encryptor { @Override public KeyPair generateNewKeys() { final byte[] publicKey = new byte[crypto_secretbox_PUBLICKEYBYTES]; final byte[] privateKey = new byte[crypto_secretbox_SECRETKEYBYTES]; LOGGER.info("Generating new keypair..."); final int jnaclResult = secretBox.cryptoBoxKeypair(publicKey, privateKey); if (jnaclResult == -1) { LOGGER.error("Unable to generate a new keypair!"); throw new EncryptorException("jnacl could not generate a new public/private keypair"); } final PublicKey pubKey = PublicKey.from(publicKey); final PrivateKey privKey = PrivateKey.from(privateKey); LOGGER.info("Generated new key pair with public key {}", pubKey); LOGGER.debug("Generated public key {} and private key {}", pubKey, privKey); return new KeyPair(pubKey, privKey); } Jnacl(final SecureRandom secureRandom, final SecretBox secretBox); @Override SharedKey computeSharedKey(final PublicKey publicKey, final PrivateKey privateKey); @Override byte[] seal(
            final byte[] message, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey); @Override byte[] open(
            final byte[] cipherText, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey); @Override byte[] sealAfterPrecomputation(final byte[] message, final Nonce nonce, final SharedKey sharedKey); @Override byte[] openAfterPrecomputation(final byte[] cipherText, final Nonce nonce, final SharedKey sharedKey); @Override Nonce randomNonce(); @Override KeyPair generateNewKeys(); @Override SharedKey createSingleKey(); }
Jnacl implements Encryptor { @Override public KeyPair generateNewKeys() { final byte[] publicKey = new byte[crypto_secretbox_PUBLICKEYBYTES]; final byte[] privateKey = new byte[crypto_secretbox_SECRETKEYBYTES]; LOGGER.info("Generating new keypair..."); final int jnaclResult = secretBox.cryptoBoxKeypair(publicKey, privateKey); if (jnaclResult == -1) { LOGGER.error("Unable to generate a new keypair!"); throw new EncryptorException("jnacl could not generate a new public/private keypair"); } final PublicKey pubKey = PublicKey.from(publicKey); final PrivateKey privKey = PrivateKey.from(privateKey); LOGGER.info("Generated new key pair with public key {}", pubKey); LOGGER.debug("Generated public key {} and private key {}", pubKey, privKey); return new KeyPair(pubKey, privKey); } Jnacl(final SecureRandom secureRandom, final SecretBox secretBox); @Override SharedKey computeSharedKey(final PublicKey publicKey, final PrivateKey privateKey); @Override byte[] seal(
            final byte[] message, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey); @Override byte[] open(
            final byte[] cipherText, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey); @Override byte[] sealAfterPrecomputation(final byte[] message, final Nonce nonce, final SharedKey sharedKey); @Override byte[] openAfterPrecomputation(final byte[] cipherText, final Nonce nonce, final SharedKey sharedKey); @Override Nonce randomNonce(); @Override KeyPair generateNewKeys(); @Override SharedKey createSingleKey();  }