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

Unnecessary Hashtable usage in RSAPSSSignature.DIGEST_LENGTHS

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 24
    • None
    • security-libs

      The field sun.security.rsa.RSAPSSSignature#DIGEST_LENGTHS is modified only in <clinit>. It means we can use Immutable Map instead of Hashtable.

          private static final Hashtable<KnownOIDs, Integer> DIGEST_LENGTHS =
                  new Hashtable<>();
          static {
              DIGEST_LENGTHS.put(KnownOIDs.SHA_1, 20);
              DIGEST_LENGTHS.put(KnownOIDs.SHA_224, 28);
              DIGEST_LENGTHS.put(KnownOIDs.SHA_256, 32);
              DIGEST_LENGTHS.put(KnownOIDs.SHA_384, 48);
              DIGEST_LENGTHS.put(KnownOIDs.SHA_512, 64);
              DIGEST_LENGTHS.put(KnownOIDs.SHA_512$224, 28);
              DIGEST_LENGTHS.put(KnownOIDs.SHA_512$256, 32);
              DIGEST_LENGTHS.put(KnownOIDs.SHA3_224, 28);
              DIGEST_LENGTHS.put(KnownOIDs.SHA3_256, 32);
              DIGEST_LENGTHS.put(KnownOIDs.SHA3_384, 48);
              DIGEST_LENGTHS.put(KnownOIDs.SHA3_512, 64);
          }


      Hashtable is legacy synchronized class, which have synchronized on its get method. It's not needed in our case.

            aturbanov Andrey Turbanov
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: