Changes between Version 2 and Version 3 of ProofOfOwnership
- Timestamp:
- Feb 12, 2019, 6:45:28 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ProofOfOwnership
v2 v3 1 1 = Proof of Account Ownership = 2 Provides your users a proof of BOINC project account ownership using OpenSSL public key cryptography. The user enters a message and that is signed alongside their account ID using the project's private key, proving that the user owns the account to external systems. 2 Provides your users a proof of BOINC project account ownership using OpenSSL public key cryptography. 3 4 The user enters a message which is signed alongside their account ID using the project's private key, providing a standardized proof of account ownership to external systems. 5 6 This is an optional extension to the BOINC web server. 3 7 4 8 == User guide == 5 1. Login then navigate to the 'Proof of Account Ownership' page.[[BR]]2. Enter the message you wish to be signed.[[BR]]3. Complete the captcha then submit the form.[[BR]]4. A text box will appear, copy the contents. 9 === Instructions === 10 1. Login then navigate to the 'Proof of Account Ownership' page. 11 1. Enter the message you wish to be signed alongside your account ID. 12 1. Complete the captcha then submit the form. 13 1. A text box will appear, copy and save the full contents to an xml file. 6 14 15 === Example XML output === 16 {{{ 17 <account_ownership_verification> 18 <master_url>http://domain.tld/project_name/</master_url> 19 <msg>1 Enter text</msg> 20 <signature>BASE64_SIGNED_MSG</signature> 21 </account_ownership_verification> 22 }}} 7 23 == Project administrator guide == 8 Changes required to integrate this functionality: 9 10 1. Have the latest stable OpenSSL installed on your BOINC web server.[[BR]]2. Install the latest BOINC PR2965 web server changes: 11 24 === Changes to web server === 12 25 {{{ 13 26 html/inc/util.inc - fixing ttok warnings … … 18 31 html/user/account_ownership_form.php - new file 19 32 }}} 20 3. Configure reCAPTCHA for the form.[[BR]]4. Generate OpenSSL keys in the /project/keys/ folder: 33 === Changes required to integrate this functionality: === 34 1. Have the latest stable OpenSSL installed on your BOINC web server. 35 1. Install the latest BOINC PR2965 web server changes 36 1. Configure reCAPTCHA for the form. 37 1. Generate OpenSSL keys in the /project/keys/ folder: 21 38 22 39 {{{ … … 24 41 openssl rsa -pubout -in ownership_sign_private.pem -out ownership_sign_public.pem 25 42 }}} 26 5. Adjust key permissions:43 5. Adjust key permissions: 27 44 28 45 {{{ … … 31 48 chmod --reference upload_private ownership_sign_private.pem 32 49 }}} 33 6. Try the form, sign a message, attempt to verify the message using your public key and the decoded base64 message from the form.50 6. Try the form, sign a message, attempt to verify the message using your public key and the decoded base64 message from the form. 34 51 35 == Security==52 === Security === 36 53 The private key needs to remain on the web server, however if this key is compromised then proof of account ownership could be forged. It's important to maintain an updated and secure BOINC project web server to reduce the risk of this happening. 37 54 38 If you believe that the private key has been compromised, then simply generate a new key pair to start from scratch, users will need to regenerate their signed messages. 55 If you believe that the private key has been compromised, simply generate a new key pair to start from scratch, users will need to regenerate their signed messages to maintain a current proof of account ownership on external systems. 56 57 ---- 58 == Verifying signed messages == 59 === Pre-requisites === 60 Follow the above user guide with your project, copy the output XML text snippet and save to 'xml_data.xml'. 61 62 Extract the PUBLIC_KEY_VALUE from the XML output produced by 'get_project_config.php' into a file called 'ownership_sign_public.pem'. Don't include the 'ownership_signature_public_key' tags in the file, don't include trailing return/newline characters in the text file. 63 64 {{{ 65 <ownership_signature_public_key>PUBLIC_KEY_VALUE</ownership_signature_public_key> 66 }}} 67 === Python verification script === 68 The below script takes the public key and the saved xml file and prints whether it's valid or not. Requires the following python modules: pycryptodome, base64, xmltodict 69 70 {{{ 71 from Crypto.PublicKey import RSA # package: pycryptodome 72 from Crypto.Signature import PKCS1_v1_5 73 from Crypto.Hash import SHA512 74 from base64 import b64decode 75 import xmltodict # For handling XML data 76 77 with open('xml_data.xml') as fd: # Entire output XML snippet 78 boinc_xml_data = xmltodict.parse(fd.read()) 79 80 with open('ownership_sign_public.pem') as f: # public key *.pem file 81 public_key_data = f.read() 82 83 message = boinc_xml_data['account_ownership_verification']['msg'] 84 signature = boinc_xml_data['account_ownership_verification']['signature'] 85 86 rsakey = RSA.importKey(public_key_data) 87 verifier = PKCS1_v1_5.new(rsakey) 88 digest = SHA512.new() 89 digest.update(bytes(message, encoding = "utf8")) 90 91 if verifier.verify(digest, b64decode(signature)): 92 print("Successfully verified Account Ownership.") 93 else: 94 print("Failed to verify UserID ownership.") 95 96 }}} 97 === Linux command line === 98 Create the following bash script with filename 'verify.sh'. 99 100 {{{ 101 #!/bin/bash 102 SIG=$(sed -n 's/<signature>\(.*\)<\/signature>/\1/p' xml_data.xml) 103 MSG=$(sed -n 's/<msg>\(.*\)<\/msg>/\1/p' xml_data.xml) 104 echo -n $SIG > signature.txt 105 echo -n $MSG > msg.txt 106 base64 -d signature.txt > decoded_signature.txt 107 openssl dgst -sha512 -verify ownership_sign_public.pem -signature decoded_signature.txt msg.txt 108 }}} 109 Enable it to be executable then run the script 110 111 {{{ 112 chmod +x verify.sh 113 ./verify.sh 114 115 }}} 116 Expected successful output: 117 118 {{{ 119 Verified OK 120 }}}