@Test public void testEncryptToSameRustJs() { byte[] encryptedValue = streamEncryptionService.encryptWithIv(SHARED_SECRET, PLAINTEXT, NONCE_IV); assertThat(encryptedValue).isEqualTo(CIPHERTEXT); }
@VisibleForTesting byte[] encryptWithIv(final SharedSecret sharedSecret, final byte[] plainText, final byte[] iv) throws EncryptionException { Objects.requireNonNull(sharedSecret); Objects.requireNonNull(plainText); Objects.requireNonNull(iv); if (this.encryptionMode == EncryptionMode.ENCRYPT_NON_STANDARD) { return this.nonStandardModeEncryptWithIv(sharedSecret, plainText, iv); } else { return this.standardModeEncryptWithIv(sharedSecret, plainText, iv); } }
AesGcmStreamEncryptionService implements StreamEncryptionService { @VisibleForTesting byte[] encryptWithIv(final SharedSecret sharedSecret, final byte[] plainText, final byte[] iv) throws EncryptionException { Objects.requireNonNull(sharedSecret); Objects.requireNonNull(plainText); Objects.requireNonNull(iv); if (this.encryptionMode == EncryptionMode.ENCRYPT_NON_STANDARD) { return this.nonStandardModeEncryptWithIv(sharedSecret, plainText, iv); } else { return this.standardModeEncryptWithIv(sharedSecret, plainText, iv); } } }
AesGcmStreamEncryptionService implements StreamEncryptionService { @VisibleForTesting byte[] encryptWithIv(final SharedSecret sharedSecret, final byte[] plainText, final byte[] iv) throws EncryptionException { Objects.requireNonNull(sharedSecret); Objects.requireNonNull(plainText); Objects.requireNonNull(iv); if (this.encryptionMode == EncryptionMode.ENCRYPT_NON_STANDARD) { return this.nonStandardModeEncryptWithIv(sharedSecret, plainText, iv); } else { return this.standardModeEncryptWithIv(sharedSecret, plainText, iv); } } AesGcmStreamEncryptionService();  AesGcmStreamEncryptionService(final EncryptionMode encryptionMode); }
AesGcmStreamEncryptionService implements StreamEncryptionService { @VisibleForTesting byte[] encryptWithIv(final SharedSecret sharedSecret, final byte[] plainText, final byte[] iv) throws EncryptionException { Objects.requireNonNull(sharedSecret); Objects.requireNonNull(plainText); Objects.requireNonNull(iv); if (this.encryptionMode == EncryptionMode.ENCRYPT_NON_STANDARD) { return this.nonStandardModeEncryptWithIv(sharedSecret, plainText, iv); } else { return this.standardModeEncryptWithIv(sharedSecret, plainText, iv); } } AesGcmStreamEncryptionService();  AesGcmStreamEncryptionService(final EncryptionMode encryptionMode); @Override byte[] encrypt(final SharedSecret sharedSecret, final byte[] plainText); @Override byte[] decrypt(final SharedSecret sharedSecret, final byte[] cipherMessage); }
AesGcmStreamEncryptionService implements StreamEncryptionService { @VisibleForTesting byte[] encryptWithIv(final SharedSecret sharedSecret, final byte[] plainText, final byte[] iv) throws EncryptionException { Objects.requireNonNull(sharedSecret); Objects.requireNonNull(plainText); Objects.requireNonNull(iv); if (this.encryptionMode == EncryptionMode.ENCRYPT_NON_STANDARD) { return this.nonStandardModeEncryptWithIv(sharedSecret, plainText, iv); } else { return this.standardModeEncryptWithIv(sharedSecret, plainText, iv); } } AesGcmStreamEncryptionService();  AesGcmStreamEncryptionService(final EncryptionMode encryptionMode); @Override byte[] encrypt(final SharedSecret sharedSecret, final byte[] plainText); @Override byte[] decrypt(final SharedSecret sharedSecret, final byte[] cipherMessage);  }