yes that would be legal. as if you ever took the time to read some EULA's, then you would notice that the ones with cd keys always say "this software is licensed, not sold. You may distribute, download, or copy this software."
so basically you could do it.