@Test public void sharedKeyFailsIfPublicKeyTooSmall() { final byte[] sharedKey = new byte[crypto_secretbox_BEFORENMBYTES]; final Throwable throwable = catchThrowable( () -> this.secretBox.cryptoBoxBeforenm( sharedKey, Arrays.copyOf(publicKey, publicKey.length-1), privateKey ) ); assertThat(throwable).isInstanceOf(ArrayIndexOutOfBoundsException.class); }
@Override public int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey) { return curve25519xsalsa20poly1305.crypto_box_beforenm(output, publicKey, privateKey); }
JnaclSecretBox implements SecretBox { @Override public int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey) { return curve25519xsalsa20poly1305.crypto_box_beforenm(output, publicKey, privateKey); } }
JnaclSecretBox implements SecretBox { @Override public int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey) { return curve25519xsalsa20poly1305.crypto_box_beforenm(output, publicKey, privateKey); }  }
JnaclSecretBox implements SecretBox { @Override public int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey) { return curve25519xsalsa20poly1305.crypto_box_beforenm(output, publicKey, privateKey); }  @Override int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey); @Override int cryptoBoxAfternm(final byte[] output, final byte[] message, final int messageLength, final byte[] nonce, final byte[] sharedKey); @Override int cryptoBoxOpenAfternm(final byte[] output, final byte[] message, final int messageLength, final byte[] nonce, final byte[] sharedKey); @Override int cryptoBoxKeypair(final byte[] publicKey, final byte[] privateKey); }
JnaclSecretBox implements SecretBox { @Override public int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey) { return curve25519xsalsa20poly1305.crypto_box_beforenm(output, publicKey, privateKey); }  @Override int cryptoBoxBeforenm(final byte[] output, final byte[] publicKey, final byte[] privateKey); @Override int cryptoBoxAfternm(final byte[] output, final byte[] message, final int messageLength, final byte[] nonce, final byte[] sharedKey); @Override int cryptoBoxOpenAfternm(final byte[] output, final byte[] message, final int messageLength, final byte[] nonce, final byte[] sharedKey); @Override int cryptoBoxKeypair(final byte[] publicKey, final byte[] privateKey);  }