@Test public void generatingRandomKeyReturnsCorrectSize() { final int expectedKeysize = 32; final SharedKey key = this.jnacl.createSingleKey(); assertThat(key.getKeyBytes()).hasSize(expectedKeysize); }
@Override public SharedKey createSingleKey() { LOGGER.debug("Generating random key"); final byte[] keyBytes = new byte[crypto_secretbox_PUBLICKEYBYTES]; this.secureRandom.nextBytes(keyBytes); final SharedKey key = SharedKey.from(keyBytes); LOGGER.debug("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; }
Jnacl implements Encryptor { @Override public SharedKey createSingleKey() { LOGGER.debug("Generating random key"); final byte[] keyBytes = new byte[crypto_secretbox_PUBLICKEYBYTES]; this.secureRandom.nextBytes(keyBytes); final SharedKey key = SharedKey.from(keyBytes); LOGGER.debug("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; } }
Jnacl implements Encryptor { @Override public SharedKey createSingleKey() { LOGGER.debug("Generating random key"); final byte[] keyBytes = new byte[crypto_secretbox_PUBLICKEYBYTES]; this.secureRandom.nextBytes(keyBytes); final SharedKey key = SharedKey.from(keyBytes); LOGGER.debug("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; } Jnacl(final SecureRandom secureRandom, final SecretBox secretBox); }
Jnacl implements Encryptor { @Override public SharedKey createSingleKey() { LOGGER.debug("Generating random key"); final byte[] keyBytes = new byte[crypto_secretbox_PUBLICKEYBYTES]; this.secureRandom.nextBytes(keyBytes); final SharedKey key = SharedKey.from(keyBytes); LOGGER.debug("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; } 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 SharedKey createSingleKey() { LOGGER.debug("Generating random key"); final byte[] keyBytes = new byte[crypto_secretbox_PUBLICKEYBYTES]; this.secureRandom.nextBytes(keyBytes); final SharedKey key = SharedKey.from(keyBytes); LOGGER.debug("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; } 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();  }