@@ -23,15 +23,15 @@ |
||
23 | 23 | admin_page_head("Account Ownership Keys"); |
24 | 24 | |
25 | 25 | if (!file_exists($account_ownership_private_key_file_path)) { |
26 | - echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script in the BOINC web server ops directory.</p>"; |
|
26 | + echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script in the BOINC web server ops directory.</p>"; |
|
27 | 27 | } else { |
28 | - echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' exists.</p>"; |
|
28 | + echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' exists.</p>"; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | if (!file_exists($account_ownership_public_key_file_path)) { |
32 | - echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script in the BOINC web server ops directory.</p>"; |
|
32 | + echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script in the BOINC web server ops directory.</p>"; |
|
33 | 33 | } else { |
34 | - echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' exists.</p>"; |
|
34 | + echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' exists.</p>"; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | echo "<p>For more info see the related wiki page: <a href=\"https://boinc.berkeley.edu/trac/wiki/ProofOfOwnership\">ProofOfOwnership</a></p>"; |
@@ -23,15 +23,15 @@ |
||
23 | 23 | admin_page_head("Account Ownership Keys"); |
24 | 24 | |
25 | 25 | if (!file_exists($account_ownership_private_key_file_path)) { |
26 | - echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script in the BOINC web server ops directory.</p>"; |
|
26 | + echo "<p>The account ownership private key '".$account_ownership_private_key_file_name."' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script in the BOINC web server ops directory.</p>"; |
|
27 | 27 | } else { |
28 | - echo "<p>The account ownership private key '" . $account_ownership_private_key_file_name . "' exists.</p>"; |
|
28 | + echo "<p>The account ownership private key '".$account_ownership_private_key_file_name."' exists.</p>"; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | if (!file_exists($account_ownership_public_key_file_path)) { |
32 | - echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script in the BOINC web server ops directory.</p>"; |
|
32 | + echo "<p>The account ownership public key '".$account_ownership_public_key_file_name."' <b>doesn't</b> exist. Please run the 'generate_account_ownership_keys.php' script in the BOINC web server ops directory.</p>"; |
|
33 | 33 | } else { |
34 | - echo "<p>The account ownership public key '" . $account_ownership_public_key_file_name . "' exists.</p>"; |
|
34 | + echo "<p>The account ownership public key '".$account_ownership_public_key_file_name."' exists.</p>"; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | echo "<p>For more info see the related wiki page: <a href=\"https://boinc.berkeley.edu/trac/wiki/ProofOfOwnership\">ProofOfOwnership</a></p>"; |
@@ -24,50 +24,50 @@ |
||
24 | 24 | require_once("../inc/account_ownership.inc"); |
25 | 25 | |
26 | 26 | if (php_sapi_name() == "cli") { |
27 | - if (!empty($argv[1])) { |
|
27 | + if (!empty($argv[1])) { |
|
28 | 28 | if ($argv[1] == "overwrite") { |
29 | - if (file_exists($account_ownership_private_key_file_path)) { |
|
29 | + if (file_exists($account_ownership_private_key_file_path)) { |
|
30 | 30 | // If the private key exists, delete it. |
31 | 31 | unlink($account_ownership_private_key); |
32 | 32 | echo "erased '$account_ownership_private_key_file_name' \n"; |
33 | - } |
|
34 | - if (file_exists($account_ownership_public_key_file_path)) { |
|
33 | + } |
|
34 | + if (file_exists($account_ownership_public_key_file_path)) { |
|
35 | 35 | // If the public key exists, delete it. |
36 | 36 | unlink($account_ownership_public_key); |
37 | 37 | echo "erased '$account_ownership_public_key_file_name' \n"; |
38 | - } |
|
38 | + } |
|
39 | + } |
|
39 | 40 | } |
40 | - } |
|
41 | 41 | |
42 | - if ((!file_exists($account_ownership_private_key_file_path)) && (!file_exists($account_ownership_public_key_file_path))) { |
|
42 | + if ((!file_exists($account_ownership_private_key_file_path)) && (!file_exists($account_ownership_public_key_file_path))) { |
|
43 | 43 | |
44 | 44 | try { |
45 | - $generated_pkey = openssl_pkey_new(array( |
|
45 | + $generated_pkey = openssl_pkey_new(array( |
|
46 | 46 | 'digest_alg' => 'sha512', |
47 | 47 | 'private_key_bits' => 4096, |
48 | 48 | 'private_key_type' => OPENSSL_KEYTYPE_RSA |
49 | - )); |
|
49 | + )); |
|
50 | 50 | |
51 | - $pubkey = openssl_pkey_get_details($generated_pkey); // Get the public key from the generated pkey pair |
|
52 | - file_put_contents($account_ownership_public_key, $pubkey['key']); // Save the public key to disk |
|
53 | - openssl_pkey_export_to_file($generated_pkey, $account_ownership_private_key); // Save the private key to disk |
|
54 | - openssl_pkey_free($generated_pkey); // Free key data securely from memory |
|
51 | + $pubkey = openssl_pkey_get_details($generated_pkey); // Get the public key from the generated pkey pair |
|
52 | + file_put_contents($account_ownership_public_key, $pubkey['key']); // Save the public key to disk |
|
53 | + openssl_pkey_export_to_file($generated_pkey, $account_ownership_private_key); // Save the private key to disk |
|
54 | + openssl_pkey_free($generated_pkey); // Free key data securely from memory |
|
55 | 55 | |
56 | - if ((file_exists($account_ownership_private_key_file_path)) && (file_exists($account_ownership_public_key_file_path))) { |
|
56 | + if ((file_exists($account_ownership_private_key_file_path)) && (file_exists($account_ownership_public_key_file_path))) { |
|
57 | 57 | echo "Successfully generated a new account ownership keypair. \n"; |
58 | - } else { |
|
58 | + } else { |
|
59 | 59 | throw new Exception('Failed to generate account ownership keypair.'); |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | 62 | } catch (Exception $e) { |
63 | 63 | echo 'Caught exception during account ownership key generation: ', $e->getMessage(), "\n"; |
64 | 64 | } |
65 | 65 | |
66 | - } else { |
|
66 | + } else { |
|
67 | 67 | echo "The private and public keys already exist. Repeat the command with the 'overwrite' parameter to replace the existing ownership keys. \n"; |
68 | - } |
|
68 | + } |
|
69 | 69 | } else { |
70 | - echo "This script must be run from the CLI \n"; |
|
70 | + echo "This script must be run from the CLI \n"; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | ?> |