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

isProbablePrime is not implemented correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.2.0
    • security-libs
    • None
    • 1.2fcs
    • generic
    • generic
    • Not verified


      > ------- Start of forwarded message -------
      > From: David Hopwood <###@###.###>
      > Newsgroups: comp.lang.java.security
      > Subject: Re: Algorithm behind java.math.BigInteger isProbablePrime
      > Date: Thu, 16 Apr 1998 19:01:39 +0100
      > Message-ID: <###@###.###>
      > References: <###@###.###>
      >
      > -----BEGIN PGP SIGNED MESSAGE-----
      >
      > In message <###@###.###>
      > Twan van der Schoot <###@###.###> wrote:
      >
      > > Dear Reader,
      >
      > > Can someone tell me which algorithm is used in the probabilistic
      > > primality test in java.lang.BigInteger isProbablyPrime()?
      >
      > > I guess it is Miller-Rabin. Is this correct?
      >
      > Yes, although there is a bug in the implementation:
      >
      > public boolean isProbablePrime(int certainty) {
      > /*
      > * This test is taken from the DSA spec.
      > */
      > int n = certainty/2;
      > if (n <= 0)
      > return true;
      >
      > should be changed to:
      >
      > public boolean isProbablePrime(int certainty) {
      > /*
      > * This test is taken from the DSA spec.
      > */
      > int n = certainty/2;
      > if (certainty % 2 == 1)
      > n++;
      > if (n <= 0)
      > return true;
      >
      > This doesn't make a great deal of difference for typical certainty
      > values, but it is annoying (especially since I pointed it out to
      > JavaSoft several months ago, and they don't appear to have done anything
      > about it).
      >
      > - --
      > David Hopwood <###@###.###>
      > PGP public key: http://www.users.zetnet.co.uk/hopwood/public.asc
      > Key fingerprint = 71 8E A6 23 0E D3 4C E5 0F 69 8C D4 FA 66 15 01
      > Key type/length = RSA 2048-bit (always check this as well as the fingerprint)
      >
      > -----BEGIN PGP SIGNATURE-----
      > Version: 2.6.3i
      > Charset: noconv
      >
      > iQEVAwUBNTYYcTkCAxeYt5gVAQEjkQgAhoiXy3QzqoBYD8FI0He3t+W4ZmjzwvrJ
      > uU3FJmd2NlvjH3Gzlq362z21oaSOLSK2rMUPedcsRJqGFoimhnT+9gp2cq94KQv+
      > 2ttWmzGon0TWhg59cnXR/cPm07fDwJ4of32TRM5Fvq8rClcu3qAT/XWY2Fr3AOPG
      > rvejkicKjD8kEpeQllwqCayqswzJ7PvPUWcjQIsqRlOMyNLtFjuXKTdtcdQdnU24
      > YNiUUS/eP02u/6KMjnrsEzFODjrj7kz5Q83rbVBKw/CbvSate/9c84NvFQTVeuNv
      > UkV9r/tpiJUv9c+N/cNoCiNVbVBNdhqZr3GOeLN30f2VePD9kk19ZA==
      > =GxhO
      > -----END PGP SIGNATURE-----
      >
      >
      > ------- End of forwarded message -------


            jlueheorcl Jan Luehe (Inactive)
            jlueheorcl Jan Luehe (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: