Theory of scattering of elastic waves from flat cracks of arbitrary shape