Moved code specific to CPGenKey, CPDeriveKey or CPImportKey from new_key into the respective functions.