  We propose and analyze a multi-functional setup consisting of high finesse
optical cavities, beam splitters, and phase shifters. The basic scheme projects
arbitrary photonic two-mode input states onto the subspace spanned by the
product of Fock states |n>|n> with n=0,1,2,.... This protocol does not only
provide the possibility to conditionally generate highly entangled photon
number states as resource for quantum information protocols but also allows one
to test and hence purify this type of quantum states in a communication
scenario, which is of great practical importance. The scheme is especially
attractive as a generalization to many modes allows for distribution and
purification of entanglement in networks. In an alternative working mode, the
setup allows of quantum non demolition number resolved photodetection in the
optical domain.
