Boundary Green functions of topological insulators and superconductors