Organa entrusted R2-D2 and C-3PO to Raymus Antilles, the Captain of
the Tantive IV, who was instructed to treat them well and to wipe
C-3PO's memory. Although R2-D2's inability to speak basic spared him
from experiencing a memory wipe, it did undergo reprogramming to
restrict access to the holo-recordings of Leia's birthparents,
including Skywalker choking Amidala and her deathbed during delivery,
to ensure that Leia's true parentage remained a secret.`
I think for C-3PO the situation is clear: After his memory wipe he shouldn't have been able to remember that Vader was Anakin. For R2-D2 it is very likely that the reprogramming prevented him from telling Luke about Skywalker being Vader.