  We present a procedure for exactly diagonalizing finite-range quadratic
fermionic Hamiltonians with arbitrary boundary conditions in one of D
dimensions, and periodic in the remaining D-1. The key is a
Hamiltonian-dependent separation of the bulk from the boundary. By combining
information from the two, we identify a matrix function that completely
characterizes the solutions, and allow to identify an indicator of
bulk-boundary correspondence. As an illustration, we show how our method
correctly describes the zero-energy Majorana modes of a time-reversal-invariant
s-wave superconductor in a Josephson ring configuration, and predicts that a
fractional 4 pi Josephson effect can only be observed in phases hosting an odd
number of Majorana pairs.
