'Checks the performance impact of reusing stolen upload tokens.
Upload policies are HMAC\'d by the server only so they can be
grabbed from the wire and reused to perform a DOS attack. To limit
the impact of this attack, we need to bail out as soon as possible
once we realize we are handed a stream that was not encrypted with
the client key that is indicated in the policy.'

def testKeyMismatch(self):

    encrypted_data = self.encrypt_wrapper.read(((1024 * 1024) * 100))
    wrong_key = crypto.RSAPrivateKey().GenerateKey()
    decrypt_wrapper = uploads.DecryptStream(readers_private_key=self.readers_private_key, writers_public_key=wrong_key.GetPublicKey(), outfd=self.outfd)
    with self.assertRaises(crypto.VerificationError):
        decrypt_wrapper.write(encrypted_data[:600])
