Yes that's legal. There is actually a company named UsedSoft, which is specialized in selling used Software. They went through different courts and they won every time. It's even legal to sell Licences from a volume licence contract.