Yes, both moisture andO2are required for rusting. Iron is a reducing agent (gives up electrons) while the oxygen is the oxidising agent (gains electrons). The rate of corrosion is affected by water and accelerated by electrolytes.
The key reaction is the reduction of oxygen:
O2+4e−+2H2O→4OH− Because it forms hydroxide ions, this process is strongly affected by the presence of acid.