@Test public void openUsingKeysSodiumReturnsSucesss() { final byte[] data = new byte[100]; final byte[] result = this.jnacl.open(data, nonce, publicKey, privateKey); assertThat(result).isNotEmpty(); }
@Override public byte[] open( final byte[] cipherText, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey) { LOGGER.debug( "Opening message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); try { final byte[] paddedInput = pad(cipherText, crypto_secretbox_BOXZEROBYTES); final NaCl nacl = new NaCl(privateKey.getKeyBytes(), publicKey.getKeyBytes()); final byte[] plaintext = nacl.decrypt(paddedInput, nonce.getNonceBytes()); LOGGER.debug( "Opened message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); return plaintext; } catch (final Exception ex) { throw new EncryptorException(ex.getMessage()); } }
Jnacl implements Encryptor { @Override public byte[] open( final byte[] cipherText, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey) { LOGGER.debug( "Opening message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); try { final byte[] paddedInput = pad(cipherText, crypto_secretbox_BOXZEROBYTES); final NaCl nacl = new NaCl(privateKey.getKeyBytes(), publicKey.getKeyBytes()); final byte[] plaintext = nacl.decrypt(paddedInput, nonce.getNonceBytes()); LOGGER.debug( "Opened message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); return plaintext; } catch (final Exception ex) { throw new EncryptorException(ex.getMessage()); } } }
Jnacl implements Encryptor { @Override public byte[] open( final byte[] cipherText, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey) { LOGGER.debug( "Opening message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); try { final byte[] paddedInput = pad(cipherText, crypto_secretbox_BOXZEROBYTES); final NaCl nacl = new NaCl(privateKey.getKeyBytes(), publicKey.getKeyBytes()); final byte[] plaintext = nacl.decrypt(paddedInput, nonce.getNonceBytes()); LOGGER.debug( "Opened message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); return plaintext; } catch (final Exception ex) { throw new EncryptorException(ex.getMessage()); } } Jnacl(final SecureRandom secureRandom, final SecretBox secretBox); }
Jnacl implements Encryptor { @Override public byte[] open( final byte[] cipherText, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey) { LOGGER.debug( "Opening message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); try { final byte[] paddedInput = pad(cipherText, crypto_secretbox_BOXZEROBYTES); final NaCl nacl = new NaCl(privateKey.getKeyBytes(), publicKey.getKeyBytes()); final byte[] plaintext = nacl.decrypt(paddedInput, nonce.getNonceBytes()); LOGGER.debug( "Opened message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); return plaintext; } catch (final Exception ex) { throw new EncryptorException(ex.getMessage()); } } 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 byte[] open( final byte[] cipherText, final Nonce nonce, final PublicKey publicKey, final PrivateKey privateKey) { LOGGER.debug( "Opening message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); try { final byte[] paddedInput = pad(cipherText, crypto_secretbox_BOXZEROBYTES); final NaCl nacl = new NaCl(privateKey.getKeyBytes(), publicKey.getKeyBytes()); final byte[] plaintext = nacl.decrypt(paddedInput, nonce.getNonceBytes()); LOGGER.debug( "Opened message using nonce {}, public key {} and private key {}", nonce, publicKey, privateKey); return plaintext; } catch (final Exception ex) { throw new EncryptorException(ex.getMessage()); } } 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();  }