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

NN_Div generates segmentation violation

XMLWordPrintable

    • 0.9internal
    • generic
    • generic
    • Not verified

      Calling NN_Div() (in src/solaris/oak/crypt/nn.c) repeatedly with large numbers results in a
      segmentation violation. Since NN_Div() is used to also calculate the modulo operation the
      following oak program will demonstrate the problem:

      import oak.util.*;
      import oak.crypt.*;

      class q {
          public static void GCD(VPInteger p1, VPInteger p2) {
              int i = 0;
              VPInteger u, v, t;

              // manually calculate GCD of prime1 and prime2
              System.out.println("Calculating GCD.");
              u = new VPInteger(p1);
              v = new VPInteger(p2);
              while (! v.isZero()) {
                  t = u.mod(v);
                  u = v;
                  v = t;
              }
              System.out.println("GCD is "+u);
          }

          public static void main(String Args[]) {
          VPInteger u, v, t;

          VPInteger p1 = new VPInteger(512, 65537);
          VPInteger p2 = new VPInteger(512, 32765);

          VPInteger key1_prime1 = new VPInteger(512,
              "df02b615fe15928f41b02b586b51c2c02260ca396818ca4cba60bb892465be35");
          VPInteger key1_prime2 = new VPInteger(512,
              "dceeb60d543518b4ac74834a0546c507f2e91e389a87e2f2becc6f8c67d1c931");

          int i = 0;

          // manually calculate GCD of prime1 and prime2
          // This one will FAIL if nn.c is compiled O4, it will pass if its compile O2
           q.GCD(prime1, prime2);
           // This one passes in either case because it doesn't iterate enough times
          // q.GCD(p1, p2);
          }
      }

            duke J. Duke
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: