We study a class of authentication codes with secrecy. We determine the maximum success probabilities of the impersonation and the substitution attacks on these codes and the level of secrecy. Therefore we give an answer to an open problem stated in Ding et al. (J Pure Appl Algebra 196:149-168, 2005). Our proofs use the number of rational places of a certain class of algebraic function fields. We determine this number by extending the corresponding results of E. Cak double dagger ak and F. A-zbudak (Finite Fields Appl 14(1):209-220, 2008). Our authentication codes use a map which is not perfect nonlinear in certain subcases. We give an extended and unified approach so that the parameters of our authentication codes are good also when the corresponding map is not perfect nonlinear.