Corrected some log message for hsm_key_factory and fixed a bug in the loop for generating keys.