Erm.. here's some more on how the stuff works:
Private registration:
The registration starts when loading the registration form in Publicator. A long and unique hash is generated (8x32chrs) using javascript, with the function genString(). The 256chr string AND the hidden field which is it's container (bigstr_b, are then printed into the form by javascript.
The auth-part of the registrationform contains 4 textfields for typing, 6 hidden fields filled with values and one empty hidden field for the opaque hash:
Text fields:
- Username
- Admin password
- User password
- User password again
Hidden fields:
- $magent (md5'd user agent)
- $mdip (md5'd ip)
- $mseed (seed)
- $kembo_check (the value from the admins cookie - his auth hash)
- bigstr_b (the javascript-generated 256chr hash for tampering)
- tampered (the vessel for the submit hash once it's made opaque)
Of these, only the two last of the hidden fields is used in the actual password-encryption, while the rest is provided for one sole purpose:
To check if the admin is typing his own password correctly ;-)
Beacause this is the one crucial point - the admin password is NOT submitted. The only values to leave the client are the username of the new user and the opaque hash. When arriving on the server, the serverside script fetches the administrators password from his user-file to use it as the key for finding the users password in the opaque hash.
This is what occurs when admin submits the form:
The value bigstr_b is loaded into the doRegPub()-function in the registration Javascript to provide the hash in which to put the password
A javascript-function reproduces the value of the administrators auth hash from the hidden fields in the form
the form validates if the type-in fields are filled in correctly for the auth (with javascript):
-has the admin typed a name for the new user?
-is the user passwords filled in, and if so, are they equal?
-is the admin password correct? (Checked by comparing the calculated value with the $kembo_check)
The calculation for the replace-operation in the bigstr_b-hash starts by md5(users password), then chop it into four 8chrs pieces. then the double md5-value of the admin password is chopped - we use only the 6 first chrs
The 6 chrs is converted to decimal values (returns 4 digits)
The users password-pieces are replaced into the long hash at the points specified by the decimals defined (adm#x) as itself and in two other values as spacers/start-char:
spacer = amd#1 + adm#2
startChar = ((amd#1 + adm#2) *2)
The password is then replaced into the big hash about as this:
startChar + spacer + adm#1 + (passpiece1) + spacer + adm#2 + (passpiece2) + spacer + adm#3 + (passpiece3) + spacer + adm#4 + (passpiece4)
The tampered hash is then 3DES-encrypted using the 24 first chars of the double md5'ed adminpass
the 3DES-bin is printed to hex, and submitted along with the new users username (all other values are cleared before submit!)
Gooey?
knutm