@Test
  public void decrypt_failsWithModifiedContextInfo() throws GeneralSecurityException {
    HpkePublicKey recipientPublicKey = getPublicKey(getDefaultValidParams());
    HpkePrivateKey recipientPrivateKey = getPrivateKey(recipientPublicKey);
    HybridEncrypt hpkeEncrypt = HpkeEncrypt.create(recipientPublicKey);
    HybridDecrypt hpkeDecrypt = HpkeDecrypt.create(recipientPrivateKey);

    byte[] input = Random.randBytes(200);
    byte[] contextInfo = Random.randBytes(100);
    byte[] ciphertext = hpkeEncrypt.encrypt(input, contextInfo);
    byte[] extendedContextInfo =
        com.google.crypto.tink.subtle.Bytes.concat(contextInfo, "modified context".getBytes(UTF_8));
    byte[] shortContextInfo = Arrays.copyOf(contextInfo, 10);
    byte[] emptyContextInfo = new byte[0];
    byte[] nullContextInfo = null;

    expect.that(hpkeDecrypt.decrypt(ciphertext, contextInfo)).isEqualTo(input);
    assertThrows(
        GeneralSecurityException.class, () -> hpkeDecrypt.decrypt(ciphertext, extendedContextInfo));
    assertThrows(
        GeneralSecurityException.class, () -> hpkeDecrypt.decrypt(ciphertext, shortContextInfo));
    assertThrows(
        GeneralSecurityException.class, () -> hpkeDecrypt.decrypt(ciphertext, emptyContextInfo));
    assertThrows(
        GeneralSecurityException.class, () -> hpkeDecrypt.decrypt(ciphertext, nullContextInfo));
  }
Unit tests for {@link HpkeEncrypt} and {@link HpkeDecrypt}.
java_src/src/test/java/com/google/crypto/tink/hybrid/internal/HpkeEncryptDecryptTest.java