Skip to content
Tcl Source Code History Of Ticket 2413689fffffffff
Login

History Of Ticket 2413689fffffffff

Artifacts Associated With Ticket 2413689fffffffff

  1. Ticket change [cd89880e03] (rid 95907) by gcramer on 2008-12-10 11:58:14:

    1. assignee initialized to: "kennykb"
    2. cmimetype initialized to: "text/plain"
    3. 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.
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "gcramer"
    10. subsystem initialized to: "56. LibTomMath"
    11. title initialized to: "Bug in function s_mp_sqr()"
    12. type initialized to: "Bug"
  2. Ticket change [dcf6b74d0e] (rid 114578) by kennykb on 2008-12-11 04:21:53:

    1. 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.
      
      
      
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"
  3. Ticket change [81671c566b] (rid 117023) by kennykb on 2008-12-11 04:21:54:

    1. closedate changed to: "2008-12-10T21:21:54"
    2. closer changed to: "kennykb"
    3. resolution changed to: "Invalid"
    4. status changed to: "Closed"
  4. Ticket change [ce46ba45b7] (rid 96027) by gcramer on 2008-12-16 00:06:28:

    1. icomment:
      You are right. I overlooked the maximum value (1<<28)-1, in my library I'm using all 32 bits. Many tanks!
      
      
    2. login: "gcramer"
    3. mimetype: "text/plain"
    4. username: "gcramer"