Program: 111310
Project: 111310
Buggy source:
@Test public void testInvalidKeyset() throws Exception {
  KeyFormat format=KeyFormat.newBuilder().setTypeUrl(macTypeUrl).build();
  KeysetManager manager=new KeysetManager.Builder().setKeyFormat(format).build();
  manager.rotate();
  Keyset keyset=manager.getKeysetHandle().getKeyset();
  KeyData echoAeadKey=Registry.INSTANCE.newKey(KeyFormat.newBuilder().setTypeUrl(echoAeadTypeUrl).build());
  EchoAead echoAead=Registry.INSTANCE.getPrimitive(echoAeadKey);
  KeysetHandle keysetHandle=manager.getKeysetHandle(echoAead);
  assertNotNull(keysetHandle.getEncryptedKeyset());
  KmsEncryptedKeyset encryptedKeyset=KmsEncryptedKeyset.newBuilder().setEncryptedKeyset(ByteString.copyFrom(keysetHandle.getEncryptedKeyset())).setKmsKey(echoAeadKey).setKeysetInfo(keysetHandle.getKeysetInfo()).build();
  byte[] proto=encryptedKeyset.toByteArray();
  proto[0]=(byte)~proto[0];
  try {
    KeysetHandle handle=KmsEncryptedKeysetHandle.fromBinaryFormat(proto);
    fail("String_Node_Str");
  }
 catch (  GeneralSecurityException e) {
    assertTrue(e.toString().contains("String_Node_Str"));
  }
  String str=TextFormat.printToUnicodeString(encryptedKeyset);
  try {
    KeysetHandle handle=KmsEncryptedKeysetHandle.fromTextFormat(str + "String_Node_Str");
    fail("String_Node_Str");
  }
 catch (  GeneralSecurityException e) {
    assertTrue(e.toString().contains("String_Node_Str"));
  }
  KmsEncryptedKeyset encryptedKeySet2=encryptedKeyset.toBuilder().clearEncryptedKeyset().build();
  try {
    KeysetHandle handle=KmsEncryptedKeysetHandle.fromBinaryFormat(proto);
    fail("String_Node_Str");
  }
 catch (  GeneralSecurityException e) {
    assertTrue(e.toString().contains("String_Node_Str"));
  }
  KmsEncryptedKeyset encryptedKeySet3=encryptedKeyset.toBuilder().clearKmsKey().build();
  try {
    KeysetHandle handle=KmsEncryptedKeysetHandle.fromBinaryFormat(proto);
    fail("String_Node_Str");
  }
 catch (  GeneralSecurityException e) {
    assertTrue(e.toString().contains("String_Node_Str"));
  }
}

Fixed version (ground truth):
@Test public void testInvalidKeyset() throws Exception {
  KeyFormat format=KeyFormat.newBuilder().setTypeUrl(macTypeUrl).build();
  KeysetManager manager=new KeysetManager.Builder().setKeyFormat(format).build();
  manager.rotate();
  KeyData echoAeadKey=Registry.INSTANCE.newKey(KeyFormat.newBuilder().setTypeUrl(echoAeadTypeUrl).build());
  EchoAead echoAead=Registry.INSTANCE.getPrimitive(echoAeadKey);
  KeysetHandle keysetHandle=manager.getKeysetHandle(echoAead);
  assertNotNull(keysetHandle.getEncryptedKeyset());
  KmsEncryptedKeyset encryptedKeyset=KmsEncryptedKeyset.newBuilder().setEncryptedKeyset(ByteString.copyFrom(keysetHandle.getEncryptedKeyset())).setKmsKey(echoAeadKey).setKeysetInfo(keysetHandle.getKeysetInfo()).build();
  byte[] proto=encryptedKeyset.toByteArray();
  proto[0]=(byte)~proto[0];
  try {
    KeysetHandle unused=KmsEncryptedKeysetHandle.fromBinaryFormat(proto);
    fail("String_Node_Str");
  }
 catch (  GeneralSecurityException e) {
    assertTrue(e.toString().contains("String_Node_Str"));
  }
  String str=TextFormat.printToUnicodeString(encryptedKeyset);
  try {
    KeysetHandle unused=KmsEncryptedKeysetHandle.fromTextFormat(str + "String_Node_Str");
    fail("String_Node_Str");
  }
 catch (  GeneralSecurityException e) {
    assertTrue(e.toString().contains("String_Node_Str"));
  }
  KmsEncryptedKeyset encryptedKeySet2=encryptedKeyset.toBuilder().clearEncryptedKeyset().build();
  try {
    KeysetHandle unused=KmsEncryptedKeysetHandle.fromProto(encryptedKeySet2);
    fail("String_Node_Str");
  }
 catch (  GeneralSecurityException e) {
    assertTrue(e.toString().contains("String_Node_Str"));
  }
  KmsEncryptedKeyset encryptedKeySet3=encryptedKeyset.toBuilder().clearKmsKey().build();
  try {
    KeysetHandle unused=KmsEncryptedKeysetHandle.fromProto(encryptedKeySet3);
    fail("String_Node_Str");
  }
 catch (  GeneralSecurityException e) {
    assertTrue(e.toString().contains("String_Node_Str"));
  }
}