### Question:
CloudBlobCryptoAgentImpl implements CloudBlobCryptoAgent { @Override public ByteBuffer decrypt(ByteBuffer buffer) throws GeneralSecurityException { EncryptedDataPayload encryptedDataPayload = EncryptedDataPayload.deserialize(buffer); Object key = cryptoService.decryptKey(encryptedDataPayload.encryptedKey, contextKey); return cryptoService.decrypt(encryptedDataPayload.encryptedData, key); } CloudBlobCryptoAgentImpl(CryptoService cryptoService, KeyManagementService kms, String context); @Override ByteBuffer encrypt(ByteBuffer buffer); @Override ByteBuffer decrypt(ByteBuffer buffer); @Override String getEncryptionContext();  }### Answer:
@Test public void testBadDecryptInput() throws GeneralSecurityException { byte[] garbage = TestUtils.getRandomBytes(10000); for (int i = 0; i < CloudBlobCryptoAgentImpl.EncryptedDataPayload.INITIAL_MESSAGE_LENGTH; i++) { garbage[i] = 0; } try { cryptoAgent.decrypt(ByteBuffer.wrap(garbage)).array(); fail("Should have thrown exception"); } catch (GeneralSecurityException e) { } garbage[1] = 1; garbage[2] = -128; try { cryptoAgent.decrypt(ByteBuffer.wrap(garbage)).array(); fail("Should have thrown exception"); } catch (GeneralSecurityException e) { } garbage[2] = 0; garbage[5] = 79; garbage[6] = -128; garbage[10] = -128; try { cryptoAgent.decrypt(ByteBuffer.wrap(garbage)).array(); fail("Should have thrown exception"); } catch (GeneralSecurityException e) { } garbage[6] = 0; garbage[10] = 0; garbage[13] = 79; try { cryptoAgent.decrypt(ByteBuffer.wrap(garbage)).array(); fail("Should have thrown exception"); } catch (GeneralSecurityException e) { } }