error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue."));
}
$privkey_contents=fread($privkey,8192);// Reading contents of private key into var
fclose($privkey);// Closing private key file
$userid=$user->id;// Retrieving the user's UserId
$message_data="$userid$user_data";// Create the message which will be signed.
$private_key_pem=openssl_pkey_get_private($privkey_contents);// Loading the private key into memory
openssl_sign($message_data,$signature,$private_key_pem,OPENSSL_ALGO_SHA512);// Compute signature using SHA512
openssl_free_key($private_key_pem);// Free the private key from memory for additional security
$pubkey=fopen($account_ownership_public_key_file_path,"r");// Open public key file
if((!isset($pubkey))||empty($pubkey)){
error_page(tra("The proof of account ownership feature is not set up properly. Contact the project administrator to resolve the issue."));
}
$pubkey_contents=fread($pubkey,8192);// Read contents to var
fclose($pubkey);// Close pub key file
$base64_sig=base64_encode($signature);// Base64 encode the generated signature to enable safe output to text file.
$decoded_sig=base64_decode($base64_sig);// Decode base64 sig for use in sig_verification
$pubkeyid=openssl_pkey_get_public($pubkey_contents);// fetch public key into memory
$sig_verification=openssl_verify($message_data,$decoded_sig,$pubkeyid,OPENSSL_ALGO_SHA512);// Verify that the generated signature against the original data, using the public key.
openssl_free_key($pubkeyid);// Free the public key from memory
// Check if signature was successfully validated
if($sig_verification==1){
$url_tokens=url_tokens($user->authenticator);
// The generated signature has been successfully verified using the public key.
global$master_url;// Define global master_url variable for use in output
echo"<p>Do not share this information with anyone other than the external system which has requested this proof of account ownership.</p>";
error_page(tra("Invalid input. User input must have a length > 0 and < 4096. <form><input type='button' value='Go back!'' onclick='history.back()'></form>"));
}
}
functionaccount_ownership_form($user){
// GET request - the user has navigated to the page.
page_head(tra("Generate proof of account ownership"),null,null,null,boinc_recaptcha_get_head_extra());