[OTR-dev] Replicating Public Key generation in C#
Bjorn Kuiper
bjorn at kuiper.nu
Fri Sep 27 12:36:28 EDT 2013
Hi,
I'm currently in the process of implementing the sesskey tool of the OTR
toolkit in C#. I have, afaik, successfully implemented the DS1536 method
but I'm having problems to validate my results.
Using the knowledge from this previous thread, I was able to convert the
private key into a decimal value (stored in the C# BigInteger struct):
http://www.cypherpunks.ca/pipermail/otr-dev/2013-February/001648.html
So using the following private key:
48BFDA215C31A9F0B226B3DB11F862450A0F30DA
which according to the previous thread, should translates into a decimal
value of 415325779662433871844955547383752003988573073626
I'm trying to calculate the public key by executing BigInteger.ModPow
using a value of 2 with the PrivateKey as the exponent and the
predefined 1536 modules
ModPow documentation:
http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.modpow.aspx
According to the sesskey tool the public key should result in the
following (hex) string value
b1be99fd638d2b634f9825f753ff7f2213ae7207a390b5df3b685a8516d63d49c3bceeb826c1cd09eb030430772193b82f1f4ab01c77e38b7eff100c0fb296bd1d6148bd205fdce3a2ec33ef9c3413eb06d1f413d52ad0747b9273783f7ee88435498b5774967da987ce10e7a2cec72ceecc8f95ceaf92edf82b3e0f69faa87de5eb4748325f82f0bc43f24984b5af2c9d3043d9871c3c952b22a5b292cdead6a67caa62c0196745ed608a6aaf8797fe5801f0506b8f8aa5f431dc583ea584a8
the decimal result that i get is out of the BigInteger.ModPow
calculation is:
56297874329874523891724860318406166018023571889488421132412684709044200024226414358676733151153929853542813702874891309683023480972891877964343284383881926039957254861647157705459295440282616997045285351124170499352162116691691956916479496812304601840337399499809750076379361938944427446622841466327740501036935422563225487567435087517275782634535178804160766011454736370075140831679684721550998242918581577673480508577383191776531766891345242
converted to a Hex string makes:
6E4CFBF33154E1B2F4D40D8D750425B5184ACD7C1F2020328948D6310EFD50B57B9F4608FDA059786B34ADDBA6E1ACBCEE644367688EA1313F15226410FDECD2493B72D44E25B9784716230140D4D4551F22217FFDB0A5CCD98706FF6E5F3BBCBA02AE5DE5968A5A1AE948909E3E08B4F9831DD9C80D487B3A6FA3BDD382ED26C7D5F9B6A7B38AA108DADC9E62B2359E16214DD8DB7DEF90D7F6AAE66E0576CE4373CDFA25D7ECA46DEE3CC3F23E8CAF672A8B1F5059755A
Can somebody indicate where you think it is going wrong. My
implementation of the DH1536 method can be found here:
https://otr.codeplex.com/SourceControl/latest#OTRdotNET/OffTheRecord.DiffieHellman/DH1536.cs
Thank you for your help
Bjorn
More information about the OTR-dev
mailing list