Part of Edit 2: Solved my issue, see bottom edits.
Hello,
I have an issue that is not really making much sense to me and am hoping a second set of eyes might spot something I'm not catching. I'm in the key exchange phase of the login sequence and am unable to come to a common shared key despite all shared values matching on both ends. I'm using the Diffie Hellman implementation by CptSky provided on the development wiki (

).
I am successfully exchanging keys with the client, as I'm able to correctly decipher the 1052 packet sent from the client to the server. This tells me that the GenerateRequest and the HandleResponse functions are correctly implemented, other wise I would not be able to decipher that packet. (Is this a correct assumption?)
I am not successfully able to decipher that same packet on the server I have setup and I've traced that back to a mis-match in the shared key.
Here is an output from both my Proxy and my Server - This tells me that both the A and the B keys are being transmitted correctly between the proxy and the server.
Keys as seen by Proxy:
P - KEY
E7A69EBDF105F2A6BBDEAD7E798F76A209AD73FB466431E2E7 352ED262F8C558F10BEFEA977DE9E21DCEE9B04D245F300ECC BBA03E72630556D011023F9E857F
G - KEY
05
A - KEY
324A423BD49D916E648BD84AEF3AFA95EFD68FB6BF94357CC8 E8FD5A2022C166293856EE017F6449F329CB884E71BCF62B73 A376A699E7EEE86A0379FF0440C3
B - KEY
DAC2EA4A75F0707A650D76971F859A574B35C6EC31C6E44924 FF1C01426EDADEC09133B95F784CA2DD844ADE599D7A17242F 476D4C3F4EB72986C6B7711DAE4B
S - KEY
415B45E74DD9190C502EFDE84A5FF3E1B429B029A5D84E8D2F 18F1F422EE1B8BE52E54C6D020767B14E149D0EE2AF6C8C73C 6C2DBC48FA536C7FE76D09F3EBE3
Keys as seen by Server:
P - KEY
E7A69EBDF105F2A6BBDEAD7E798F76A209AD73FB466431E2E7 352ED262F8C558F10BEFEA977DE9E21DCEE9B04D245F300ECC BBA03E72630556D011023F9E857F
G - KEY
05
A - KEY
324A423BD49D916E648BD84AEF3AFA95EFD68FB6BF94357CC8 E8FD5A2022C166293856EE017F6449F329CB884E71BCF62B73 A376A699E7EEE86A0379FF0440C3
B - KEY
DAC2EA4A75F0707A650D76971F859A574B35C6EC31C6E44924 FF1C01426EDADEC09133B95F784CA2DD844ADE599D7A17242F 476D4C3F4EB72986C6B7711DAE4B
S - KEY
7F33B3383C6E73E8A271F16E6107204F85BE0CC1F4713FB8FC 57886679B562879F886574F95E9AE27489B0112ADF2550A37D CE44026CC7A5C1062F5D0421D9DE
Here is my code handling the DH Packet From Server to Client
Code:
cipher.ClientExchange = new DiffieHellman(cipher.DHtoClient.P, cipher.DHtoClient.G);
cipher.DHtoClient.Edit(packet, cipher.ClientExchange.GenerateRequest());
Here is my code handling the DH Packet From Client to Server
Code:
cipher.ClientExchange.HandleResponse(cipher.DHtoServer.PublicKey);
cipher.ServerExchange = new Security.DiffieHellman(cipher.DHtoClient.P, cipher.DHtoClient.G);
cipher.DHtoServer.Edit(pack, cipher.ServerExchange.GenerateResponse(cipher.DHtoClient.PublicKey))
Based on everything I've read, the S-Key is supposed to be the same. And from the simple explanation on the wiki about Diffie Hellman, the GenerateReponse is correctly implemented, not sure where else I can be going wrong.
Any help is appreciated.
Edit:
Forget everything I said above. My shared keys are correct, I was accidentally comparing the shared key between the client and proxy to the one generated server side....stupid. Brings me back to trying to figure out why I'm not able to decipher a packet sent from the proxy to the server.. The ciphers were both initialized with the same shared key (verified properly this time) and I've setup the IV's on the server to be all zeros, so I can't get those mixed up.
Not really sure what could be wrong if the cipher between Client and Proxy is functioning properly and my Server and Proxy cipher was instanced with the same Shared key...at a loss.
Edit 2:
Rubber-duckied my way out of this one. I was doing everything correctly except pointing my server facing cipher to my new instance...This took ~15 hours over the last two days...but hey, I'm pretty comfortable with it now.