<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 12/10/2015 05:55 AM, Jayalakshmi bhat wrote:<br>
    <blockquote
cite="mid:CALq8RvKZ_Vvq_VFBH262iQBnx8ofjLJvYbaN3hRVGbEod+=NHg@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div dir="ltr"><span style="font-size:12.8px">Hi Matt,</span>
        <div style="font-size:12.8px"><br>
        </div>
        <div style="font-size:12.8px">Thanks for the patch.
          Unfortunately patch did not work. I continued debugging and
          found that issue was in constant_time_msb.</div>
        <span class="im" style="font-size:12.8px">
          <div><span style="font-size:12.8px"><br>
            </span></div>
          <div><span style="font-size:12.8px">static inline unsigned int
              constant_time_msb(unsigned int a) </span><span
              style="font-size:12.8px">{</span></div>
        </span>
        <div style="font-size:12.8px">-    <b>return 0 - (a >>
            (sizeof(a) * 8 - 1));</b></div>
        <div style="font-size:12.8px"><span style="white-space:pre-wrap">+   </span>return
          (((unsigned)((int)(a) >> (sizeof(int) * 8 - 1))));</div>
      </div>
    </blockquote>
    <br>
    Hmm, right-shifting a negative value is implementation-defined
    behavior, so I don't think that this construct would necessarily be
    portable to all systems.  It's not clear to me what purpose the "0 -
    " was supposed to perform in the original version, though.<br>
    <br>
    In any case, it seems that the '8' literal there ought to be
    CHAR_BIT (<limits.h>).  I am curious what value CHAR_BIT has
    in the environment that Jaya is running in.<br>
    <br>
    -Ben<br>
    <br>
    <blockquote
cite="mid:CALq8RvKZ_Vvq_VFBH262iQBnx8ofjLJvYbaN3hRVGbEod+=NHg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div style="font-size:12.8px">} </div>
        <div style="font-size:12.8px"><br>
        </div>
        <div style="font-size:12.8px">Changed constant_time_msb
          implementation as shown above. All the tests passed. I have
          attached the <span style="font-size:12.8px">dis-assembly of
            the</span> code for both successful case and failure case. 
          This was requested by Jakob. </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>