Hi Mowat,
What is logged in your JavaScript, Apache and PHP error logs/consoles at the time of the problem? Use the smallest (512-byte) key to test.
Do you have the php-openssl module installed and active in your PHP install? If not, then you should install and activate it, as the usual problem with key generation is that the server can only do so very slowly – and runs out of time before PHP is killed by policy on the server, if php-openssl is not present (that module speeds cryptographic calculations up hugely).
David