Skip to content

R-P-S/SC2-RSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SC2 RSA Signature Verification

This project provides a custom implementation of RSA signature verification in SC2, enabling secure message validation through RSA signatures. RSA signatures work by encrypting a hash of the message with a private key, allowing the recipient to verify its authenticity by decrypting it with the corresponding public key.

The project includes:

  • BigNum Library: An arbitrary-precision arithmetic library (specifically written for SC2) to handle large integers beyond the 32-bit limit.

  • SHA1 Library: A hashing library (also specifically tailored for SC2) to provide the necessary functionality for message hashing in RSA signature verification.

  • Python Signing Tool: Generates RSA key pairs, signs messages, and outputs a Base64-encoded string for use in SC2.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/R-P-S/SC2-RSA.git
    cd SC2-RSA
    
  2. Requirements:

  3. Install Required Python Package

     pip install https://github.com/R-P-S/SC2-RSA/archive/master.zip
    

    This command installs all necessary Python dependencies for the signing tool.

Usage

  1. Initial Run of the Python Signing Tool

    $ sc2signer
    

    The tool will guide you through the setup. On the first run, you’ll be asked to select an RSA key size:

    • Select 1024 or 2048 bits. A 1024-bit key is recommended for optimal performance. If you're using a 2048-bit key, set the constant KEY_SIZE_MULTIPLIER to 2 in bignum.galaxy or in the trigger library if using the GUI.

      Once keys are generated, the script saves them to a .pem file and copies the public key to your clipboard. Paste this key into the PUBLIC_KEY constant in rsa.galaxy or, if using the GUI, into the PUBLIC_KEY constant in the trigger module.

  2. Signing Messages with the Python Script

    • Enter a message and player ID (X-S2-X-XXXXXXX) when prompted.
    • The script will ask how many days the signed message should remain valid. If you provide a number of days (e.g., 7), the tool calculates a Unix timestamp for expiration. It embeds that timestamp in the signed message. If you enter 0 for days, there is no expiration attached to the signature.
    • The script outputs a signed message in Base64 format.
  3. Verifying Signatures in SC2

    Once a signed message is generated, it can be verified in-game. The included example trigger gt_DecryptSignature listens for the chat command (e.g., -m {signed_message}) and verifies the signature by:

    • Decrypting the RSA signature.
    • Comparing it with the expected hash.
  4. Key File Location

    The RSA key pair is stored in a user-specific directory. Make sure to keep this file secure, as it contains the private key used for signing.

    • Windows: C:\Users\<Username>\AppData\Local\SC2Signer\rsa_keys.pem
    • macOS: /Users/<Username>/Library/Application Support/SC2Signer/rsa_keys.pem
    • Linux: /home/<Username>/.local/share/SC2Signer/rsa_keys.pem

Example

Python Signing Tool

Example run:

$ sc2signer
Write message: Marine 5
Enter Player Profile ID: SC2E-TEST-ACCOUNT
How many days should the signed message be valid? (0 for no time limit): 0

console

Verification

In Starcraft 2's chat console:

-m {signed_message}

screenshot

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

RSA signature verifier for sc2

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages