# Confused about how chosen ciphertext attacks work?

When performing a CCA, the adversary gets the public key. At some point, he will send a message m to the challenger, and the challenger will send back either $E_{pk}(m)$ or $E_{pk}(r)$, where r is some random string of same length as m. The goal of the adversary is now to guess which one the challenger sends back. However, the adversary already has the pk, so why can't he himself not just encrypt his message and check if it fits with the one he got back?

-
Because encryption is not deterministic. – fkraiem Nov 25 '15 at 11:20
Thank you! That was really simple, it just didn't occur to me. – Mai Nov 25 '15 at 11:23
Somebody can perhaps write a more detailed answer, my time is lacking right now... – fkraiem Nov 25 '15 at 11:27