algolagnia

sexual gratification derived from administering or experiencing pain, including both sadism and masochism.