Artifacts Associated With Ticket 2413689fffffffffffffffffffffffffffffffff
Ticket change [cd89880e03] (rid 95907) by gcramer on 2008-12-10 11:58:14:
- assignee initialized to: "kennykb"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Function s_mp_sqr() has a bug. I have no example, but I developed a multiple precision library by myself, and I had the same bug in my code. In line bn_s_mp_sqr.c:59 "r = ((mp_word) *tmpt) + r + r + ((mp_word) u);" an integer overflow may occur! This leads to wrong results in general. Inside the function "HAC pp.596-597, Algorithm 14.16" is referenced, but "Note 14.17 (i)" is not regarded appropriately.
- foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "gcramer"
- subsystem initialized to: "56. LibTomMath"
- title initialized to: "Bug in function s_mp_sqr()"
- type initialized to: "Bug"
Ticket change [dcf6b74d0e] (rid 114578) by kennykb on 2008-12-11 04:21:53:
- icomment:
In this case, overflow appears impossible. It is important to remember that not all the bits of an mp_digit are actually used; the maximum value for an mp_digit is (1<<28)-1. So here I see that r (a 64-bit integer) is set to the product of two mp_digits (which is less than 2**56). It's subsequently doubled, and then two more mp_digits are added to it, so it winds up still less than 2**58 + 2**29. This is comfortably less than 2**63-1, the maximum size of an mp_word. Even if MP_31BIT is defined - which Tcl does not do - the result of this addition is at most 2**62 + 2**32, still less than 2**63-1. (Tcl does not define MP_31BIT because observed performance is better with the Comba multipliers, which are incompatible with that option.) Overflow would be possible if tommath used all 32 bits of an mp_digit. But it doesn't.
- login: "kennykb"
- mimetype: "text/plain"
- username: "kennykb"
- icomment:
Ticket change [81671c566b] (rid 117023) by kennykb on 2008-12-11 04:21:54:
- closedate changed to: "2008-12-10T21:21:54"
- closer changed to: "kennykb"
- resolution changed to: "Invalid"
- status changed to: "Closed"
Ticket change [ce46ba45b7] (rid 96027) by gcramer on 2008-12-16 00:06:28:
- icomment:
You are right. I overlooked the maximum value (1<<28)-1, in my library I'm using all 32 bits. Many tanks!
- login: "gcramer"
- mimetype: "text/plain"
- username: "gcramer"
- icomment: