Hi, ok. It seem to me that I am not the only one who expects different results with the BN_FLG_CONSTIME flag. I measured the time only of the BN_nnmod function in the BN_mod_add function. The BN_add function, which is executed before the BN_nnmod function, maybe needs more time, because it has to do a carry or creating a new word for the value which is bigger than the modulos.
-------- Original-Nachricht -------- > Datum: Tue, 29 May 2012 22:52:11 +0100 > Von: "Matt Caswell (fr...@baggins.org)" <fr...@baggins.org> > An: openssl-users@openssl.org > Betreff: Re: Problems with OpenSSl BN > On 29/05/12 16:55, chip...@gmx.de wrote: > > Hi, > > > > thank you again for your answer. > > > > Now I set for every variable the BN_FLG_CONSTIME Flag, so that I can be > sure, that they will need the same time. > > I measured the time the BN_nnmod operation in the BN_mod_add function > needs for the modulo operation and I see again big differences in the > operationtimes. Shouldn't the modulo operation now need nearly equal time for > the > same modulos? It seems to me that all mod-operations needs a little bit > more time now but they only little converge. The difference is about 40 > percent sometimes. A number which is bigger then the modulos takes normally > about > 30 percent more time for the Mod operation, then a smaller one. How can > one converge the operation time? > Hmmm...that is strange. I just did some testing of my own to check this > out. I wrote a quick test program that times how long it takes to do > 10,000,000 BN_mod_add operations first adding a 254 bit number to a 254 > bit number such that the result was greater than the modulus. I then > repeated but adding a 254 bit number to a 253 bit number such that the > result was less than the modulus. Finally I repeated both experiments > but with BN_FLG_CONSTTIME set on both numbers. > > These are my results: > > Without CONSTTIME flag > Result greater than modulus (BN_FLG_CONSTTIME not set) :11s 328065us > Result less than modulus (BN_FLG_CONSTTIME not set) :2s 665665us > > With CONSTTIME flag > Result greater than modulus (BN_FLG_CONSTTIME set) :11s 219340us > Result less than modulus (BN_FLG_CONSTTIME set) :2s 656643us > > This doesn't seem right to me. Can anyone on the list suggest if this is > correct behaviour or a bug? This is not the way I thought > BN_FLG_CONSTTIME worked? I would have expected the final result to be > roughly the same as the third? > > My code is attached in case I made a stupid error. > > > Something that is also strange, when I use some bignums for example as a > summand in a Mod_add function, then the value of the summand itself get > lost. (I don't overwrite it). When I want to use the summands value later, > then it just has the value zero. > Do you have some example code of this? > > > Thank you for your help. > -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org