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

Ineffective SecureRandom usage in RSA encoding with PKCS1Padding.

XMLWordPrintable

    • b79
    • generic
    • generic

        Currently sun.security.rsa.RSAPadding::padV15 uses fixed size (64 bytes) buffer for obtaining random bytes from SecureRandom.
        Here we got two sources of inefficiency:
        - when length of required padding is greater than 64 -> several calls of SecureRandom.nextBytes are required that increases contention blocking on SecureRandom
        - when length of required padding is less than 64 it causes unnecessary overhead (e.g. nextBytes for 16 bytes is 4x times faster than for 64 bytes)

        Suggested performance improvement shows RSA encoding speedup:
        - 10%-18% when NativePRNG SecureRandom is used,
        - 5%-7% when SHA1PRNG is used.

          1. key2048.png
            key2048.png
            31 kB
          2. t1.png
            t1.png
            26 kB
          3. t4.png
            t4.png
            27 kB
          4. webrev.zip
            61 kB
          5. webrev.zip
            60 kB

              skuksenko Sergey Kuksenko
              skuksenko Sergey Kuksenko
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: