Second-order characterizations of convex and pseudoconvex functions