Minion Beta! - Help us test our new AddOn updater. Get it now!
Download
(7 Kb)
Download
Updated: 07-07-13 01:31 PM
Compatibility:
Siege of Orgrimmar (5.4)
Escalation (5.3)
Updated:07-07-13 01:31 PM
Created:07-07-13 01:31 PM
Downloads:394
Favorites:2
MD5:
Categories:Libraries, Developer Utilities

LibDSA

Version: 1.0
by: elcius [More]

A library for validating and generating Digital Signatures in World of Warcraft.

The Digital Signature Algorithm provides a way of ensuring data received from another player originated from the addon developer and was not modified as it was passed between players.
If you want a technical explanation of how it works you can read FIPS PUB 186-3.

The maths is complicated but the result is fairly basic, you generate a public key and a private key, you hard-code the public key into your addon, then using the private key you can sign a string of data (any length or content) and then send that data along with the generated signature to users of the addon in-game, users can use the public key to validate that the signature matches the received string, if either the signature or the string were altered by even a single bit, it will result in a failed validation.

Key Generation using OpenSSL:
First get yourself a copy of OpenSSL, you may need to use it a lot or just once to generate the keys.
Once you have it compiled (Windows users can find pre-compiled binaries here) input the following commands to generate a key pair.

Code:
openssl dsaparam -out dsaparam.pem 1024
openssl gendsa dsaparam.pem -out dsa_priv.pem
openssl dsa -in dsa_priv.pem -pubout -out dsa_pub.pem
Depending on the nature of your system you may want to pick a smaller key length, currently even 128 bit keys still take significant effort to crack.
The type of the content you're sending should be the first factor you account for, other factors include how frequently the users will need to do validations and whether or not the validation needs to be done quickly or if can be run in the background.

Extracting Key Values from the generated key files:
Once you have generated your key files you need to pull the actual values out of them.
First copy the contents of one of the generated pem files into an ASN.1 decoder.
Decode the structure, and depending on which file you selected copy the values (in hex) into your script, use the code in DSA_test() as a reference for how to load them.
Public keys contain 4 integers, 3 grouped together in a sequence, these are (in order) p, q and g, the remaining value is y, stored in a bit-string.
Private keys contain 6 integers, the first of which is a zero, the remaining 5 are (in order) p,q,g,y and finally x (should never be packaged or stored anywhere publicly accessible).

Signature Generation Using OpenSSL:
Signing a string follows basically the same method, these commands in sequence will take a string (payload.txt) and use the private key file to generate a signature file (sigfile.txt).
Code:
openssl dgst -dss1 -sha256 -out sigfile.bin -sign dsa_priv.pem payload.txt
openssl enc -base64 -in sigfile.bin -out sigfile.txt
Use the same method you used for extracting the key values to get the signature values from the sigfile, the structure just contains the two integers r and s (in that order).

In-game Signature Generation:
If you plan on generating signatures in-game you need the public key value x available in-game, this value should not be packaged with the public application, but can be extracted from the private key file.
See DSA_test() for an example of signing.

Optional Files (0)


There have been no comments posted to this file.
Be the first to add one.



Category Jump: