@Test public void generatingRandomKeyReturnsCorrectSize() { final int expectedKeysize = 32; final SharedKey key = this.kalium.createSingleKey(); verify(this.sodium).randombytes(any(byte[].class), eq(expectedKeysize)); }
@Override public SharedKey createSingleKey() { LOGGER.info("Generating random key"); final byte[] keyBytes = new byte[CRYPTO_BOX_CURVE25519XSALSA20POLY1305_PUBLICKEYBYTES]; this.sodium.randombytes(keyBytes, keyBytes.length); final SharedKey key = SharedKey.from(keyBytes); LOGGER.info("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; }
Kalium implements Encryptor { @Override public SharedKey createSingleKey() { LOGGER.info("Generating random key"); final byte[] keyBytes = new byte[CRYPTO_BOX_CURVE25519XSALSA20POLY1305_PUBLICKEYBYTES]; this.sodium.randombytes(keyBytes, keyBytes.length); final SharedKey key = SharedKey.from(keyBytes); LOGGER.info("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; } }
Kalium implements Encryptor { @Override public SharedKey createSingleKey() { LOGGER.info("Generating random key"); final byte[] keyBytes = new byte[CRYPTO_BOX_CURVE25519XSALSA20POLY1305_PUBLICKEYBYTES]; this.sodium.randombytes(keyBytes, keyBytes.length); final SharedKey key = SharedKey.from(keyBytes); LOGGER.info("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; } Kalium(final NaCl.Sodium sodium); }
Kalium implements Encryptor { @Override public SharedKey createSingleKey() { LOGGER.info("Generating random key"); final byte[] keyBytes = new byte[CRYPTO_BOX_CURVE25519XSALSA20POLY1305_PUBLICKEYBYTES]; this.sodium.randombytes(keyBytes, keyBytes.length); final SharedKey key = SharedKey.from(keyBytes); LOGGER.info("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; } Kalium(final NaCl.Sodium sodium); @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[] encryptedPayload, final Nonce nonce, final SharedKey sharedKey); @Override Nonce randomNonce(); @Override KeyPair generateNewKeys(); @Override SharedKey createSingleKey(); }
Kalium implements Encryptor { @Override public SharedKey createSingleKey() { LOGGER.info("Generating random key"); final byte[] keyBytes = new byte[CRYPTO_BOX_CURVE25519XSALSA20POLY1305_PUBLICKEYBYTES]; this.sodium.randombytes(keyBytes, keyBytes.length); final SharedKey key = SharedKey.from(keyBytes); LOGGER.info("Random key generated"); LOGGER.debug("Generated key with value {}", key); return key; } Kalium(final NaCl.Sodium sodium); @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[] encryptedPayload, final Nonce nonce, final SharedKey sharedKey); @Override Nonce randomNonce(); @Override KeyPair generateNewKeys(); @Override SharedKey createSingleKey();  }