Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8188046

java.lang.Math.mutliplyHigh does not run in constant time

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
    • Resolved In Build:
      b05

      Description

      The pure Java implementation of mutliplyHigh looks like this:

          public static long multiplyHigh(long x, long y) {
              if (x < 0 || y < 0) {
                  // Use technique from section 8-2 of Henry S. Warren, Jr.,
                  // Hacker's Delight (2nd ed.) (Addison Wesley, 2013), 173-174.
              } else {
                  // Use Karatsuba technique with two base 2^32 digits.
              }

      This two-way branch gains very little in speed but potentially leaks information to a timing attack. What little the fast path gains from one fewer multiply it loses on the conditional branch: I've not been able to measure any significant difference in speed.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              aph Andrew Haley
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: