Class KeyAgreementSupport


  • public final class KeyAgreementSupport
    extends Object
    Support for key agreement operations.
    • Field Detail

      • KEY_ALGORITHMS

        public static final Set<String> KEY_ALGORITHMS
        JCA key algorithms that support key agreement.
    • Constructor Detail

      • KeyAgreementSupport

        private KeyAgreementSupport()
        Constructor.
    • Method Detail

      • getExplicitKeySize

        @Nullable
        public static Integer getExplicitKeySize​(@Nonnull
                                                 AgreementMethod agreementMethod)
        Look for an explicit key size via an AgreementMethod's grandparent's EncryptionMethod child's KeySize child element.
        Parameters:
        agreementMethod - the AgreementMethod to process
        Returns:
        the key size, or null if not present
      • validateKeyAlgorithmAndSize

        public static void validateKeyAlgorithmAndSize​(@Nonnull
                                                       String algorithmURI,
                                                       @Nullable
                                                       Integer specifiedKeyLength)
                                                throws KeyAgreementException
        Validate the specified algorithm URI and key length for consistency.

        If the algorithm URI does not imply a key length, then the specified key length must be non-null. If the algorithm URI does imply a key length and the optional specified key length is non-null, they must be the same length.

        Parameters:
        algorithmURI - the algorithm URI
        specifiedKeyLength - the optional specified key length
        Throws:
        KeyAgreementException - if algorithm and specified key lengths are not consistent
      • supportsKeyAgreement

        public static boolean supportsKeyAgreement​(@Nullable
                                                   Credential credential)
        Evaluate whether the specified credential contains a public key which supports key agreement.
        Parameters:
        credential - the credential to evaluate
        Returns:
        true if supports key agreement, false if does not