Add getSize() method to java.security.Key

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P3
    • None
    • Affects Version/s: None
    • Component/s: security-libs
    • None

      Default methods allow us to add a getSize() method to the java.security.Key interface (and applicable sub-interfaces), which would be a very useful addition and eliminate the need for the internal sun.security.util.KeyUtils.getKeySize() method and qualified exports to any modules that depend on it (such as java.xml.crypto).

      The getSize() method would return the size of the key, or -1 if it cannot be determined:
          /**
           * Returns the size of this key, or -1 if the size is unknown.
           *
           * @implSpec
           * The default implementation of this method returns -1.
           *
           * @return the size of this key, or -1 if the size is unknown.
           */
          default public int getSize() {
              return -1;
          }

      Sub-interfaces such as DSAPublicKey, RSAPublicKey, etc can then override the default method to return the size of the key, instead of -1.

            Assignee:
            Haimay Chao
            Reporter:
            Sean Mullan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: