Twisted exchange interaction between localized spins embedded in a one- or two-dimensional electron gas with Rashba spin-orbit coupling