Anonymous Or are both of them wrong?
Many dictionaries* consider both of them right. The underlying idea is that even though used with its ed ending looks like an ordinary past tense verb, usage has not settled and two forms are acceptable with the auxiliary do:
He didn't use/used to be rich.
And, since it can be considered an auxiliary, also: He used not to be rich.
CB
* One of these is Collins.