In 1871, a national prohibition, Paragraph 175, was added to the Reich
Penal Code. it read:
When the Nazis came to power in 1933, they put a halt to efforts
seeking reform of this law. In 1935, after the murder of Ernst
Rohm, the NSDAP amended the Paragraph 175 to close what were seen
as loopholes in the current law.
The new law had three parts:
Paragraph 174 of the penal code forbade incest and other sexual
offenses with dependents, while paragraph 176 outlawed pedophilia.
Persons convicted under these laws also wore the pink triangle.
The Nazis passed other laws that targeted sex offenders. In 1933, they enacted the Law Against Dangerous Habitual Criminals and Measures for Protection and Recovery. This law gave German judges the power to order compulsory castrations in cases involving rape, defilement, illicit sex acts with children (Paragraph 176), coercion to commit sex offenses (paragraph 177), the committing of indecent acts in public including homosexual acts (paragraph 183), murder or manslaughter of a victim (paragraphs 223226), if they were committed to arouse or gratify the sex drive, or homosexual acts with boys under 14. The Amendment to the Law for the Prevention of Offspring with Hereditary Diseases dated June 26, 1935 allowed castration indicated by reason of crime for men convicted under paragraph 175 if the men consented. A May 20, 1939 memo from Himmler allows concentration camp prisoners to be blackmailed into castration.
Sources: People with a History: An Online Guide to Lesbian, Gay, Bisexual and Trans History, http://pwh.evansville.edu/