Hi,

It appears that your sample values are given in little-endian format ( big-endian is more usual and BN_bn2hex use it for example). I did check the computation with various mathematical toolbox and they all gave the same result as OpenSSL BN_mod_exp which is 66694e28fdca0bb1f34fe13e3b38088180766f8cc4283ef6a9c1e427f364d7e2 in big-endian or E2D764F327E4C1A9F63E28C48C6F76808108383B3EE14FF3B10BCAFD284E6966 in little endian.as you mention it in your message. So, it's your "expected" result that is false. How did you compute this value?

Cheers,
--
Mounir IDRASSI
IDRIX
http://www.idrix.fr

Sargeras wrote:
I'm working in a client for authentication of SRP6 and I have a problem with
the function BN_mod_exp.
I'd appreciate some guidance

The values that I use with this function perfectly matches the ones
required.

It's written in C++ and here are the parts of the code that I think are
important.

BigNumber BigNumber::ModExp(const BigNumber &bn1, const BigNumber &bn2)
{
    BigNumber ret;
    BN_CTX *bnctx;

    bnctx = BN_CTX_new();
    BN_mod_exp(ret._bn, _bn, bn1._bn, bn2._bn, bnctx);
    BN_CTX_free(bnctx);

    return ret;
}

BigNumber temp;
temp = g.ModExp(x, N);

Where g, x and N are instances of the class BigNumber.
Here are my output checkings, where I print the calculated value and the
expected.

N (calculated):
B79B3E2A87823CAB8F5EBFBF8EB10108535006298B5BADBD5B53E1895E644B89
N (expected): B79B3E2A87823CAB8F5EBFBF8EB10108535006298B5BADBD5B53E1895E644B89

g (calculated): 07
g (expected):   07

x (calculated): CBFE739D7B671EE5EF8BD304A670459ED445C6CB
x (expected):   CBFE739D7B671EE5EF8BD304A670459ED445C6CB

temp (calculated):
E2D764F327E4C1A9F63E28C48C6F76808108383B3EE14FF3B10BCAFD284E6966
temp (expected): F965C5F89FF0175FA73E2DFCDB28CEAEEFD69999BE88CC015E3356DCE95FC265

Any other piece of code will be given if asked.

Thank you all for your time.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to