vpnmain.cgi: Rewrite algorithm generation code