Both OPT and CPT are absolutely legal. You can apply for any number of Day 1 CPTs to maintain your status, which still doesn't have any effect on your green card processing. Green card or Permanent resident card lets you stay in USA with out the need for a non immigrant visa like H1B.