Class ConcatKDF

    • Field Detail

      • algorithmID

        @Nullable
        private String algorithmID
        AlgorithmID.
      • partyUInfo

        @Nullable
        private String partyUInfo
        PartyUInfo.
      • partyVInfo

        @Nullable
        private String partyVInfo
        PartyVInfo.
      • suppPubInfo

        @Nullable
        private String suppPubInfo
        SuppPubInfo.
      • suppPrivInfo

        @Nullable
        private String suppPrivInfo
        SuppPrivInfo.
    • Constructor Detail

      • ConcatKDF

        public ConcatKDF()
    • Method Detail

      • getDigestMethod

        @NonnullAfterInit
        public String getDigestMethod()
        Get the digest method algorithm URI.
        Returns:
        the algorithm URI
      • setDigestMethod

        public void setDigestMethod​(@Nullable
                                    String newDigestMethod)
        Set the digest method algorithm URI.
        Parameters:
        newDigestMethod - the algorithm URI
      • getAlgorithmID

        @Nullable
        public String getAlgorithmID()
        Get the AlgorithmID in its unpadded hex-encoded form.
        Returns:
        the AlgorithmID
      • setAlgorithmID

        public void setAlgorithmID​(@Nullable
                                   String newAlgorithmID)
        Set the AlgorithmID in its unpadded hex-encoded form.
        Parameters:
        newAlgorithmID - the AlgorithmID
      • getPartyUInfo

        @Nullable
        public String getPartyUInfo()
        Get the PartyUInfo in its unpadded hex-encoded form.
        Returns:
        the PartyUInfo
      • setPartyUInfo

        public void setPartyUInfo​(@Nullable
                                  String newPartyUInfo)
        Set the PartyUInfo in its unpadded hex-encoded form.
        Parameters:
        newPartyUInfo - the PartyUInfo
      • getPartyVInfo

        @Nullable
        public String getPartyVInfo()
        Get the PartyVInfo in its unpadded hex-encoded form.
        Returns:
        the PartyUInfo
      • setPartyVInfo

        public void setPartyVInfo​(@Nullable
                                  String newPartyVInfo)
        Set the PartyVInfo in its unpadded hex-encoded form.
        Parameters:
        newPartyVInfo - the PartyVInfo
      • getSuppPubInfo

        @Nullable
        public String getSuppPubInfo()
        Get the SuppPubInfo in its unpadded hex-encoded form.
        Returns:
        the SuppPubInfo
      • setSuppPubInfo

        public void setSuppPubInfo​(@Nullable
                                   String newSuppPubInfo)
        Set the SuppPubInfo in its unpadded hex-encoded form.
        Parameters:
        newSuppPubInfo - the SuppPubInfo
      • getSuppPrivInfo

        @Nullable
        public String getSuppPrivInfo()
        Get the SuppPrivInfo in its unpadded hex-encoded form.
        Returns:
        the SuppPrivInfo
      • setSuppPrivInfo

        public void setSuppPrivInfo​(@Nullable
                                    String newSuppPrivInfo)
        Set the SuppPrivInfo in its unpadded hex-encoded form.
        Parameters:
        newSuppPrivInfo - the SuppPrivInfo
      • derive

        protected byte[] derive​(@Nonnull
                                byte[] secret,
                                @Nonnull
                                byte[] otherInfo,
                                @Nonnull
                                Integer keyLength)
                         throws KeyDerivationException
        Derive the key bytes.

        This re-factored method mostly exists to facilitate unit testing using external test vectors which only specify the OtherInfo as an input, rather than its 5 constituent parts as defined in NIST SP 800-56A and XML Encryption 1.1.

        Parameters:
        secret - the input secret from which to derive the key
        otherInfo - the OtherInfo bit string as defined in NIST SP 800-56A
        keyLength - the length of the derived key, in bits
        Returns:
        the derived key bytes
        Throws:
        KeyDerivationException - if key derivation does not complete successfully
      • getDigestInstance

        @Nonnull
        protected org.bouncycastle.crypto.Digest getDigestInstance​(@Nonnull
                                                                   String digestURI)
                                                            throws KeyDerivationException
        Get a new instance of the Bouncy Castle Digest for the specified digest algorithm URI.
        Parameters:
        digestURI - the digest algorithm URI
        Returns:
        a new corresponding instance of BC Digest
        Throws:
        KeyDerivationException - if the specified digest algorithm is unsupported
      • decodeParam

        @Nonnull
        protected byte[] decodeParam​(@Nullable
                                     String value,
                                     @Nonnull
                                     String name)
                              throws KeyDerivationException
        Decode the specified concatenation parameter value for input to the derivation operation.
        Parameters:
        value - the value to process
        name - the name of the value being processed, for diagnostic purposes
        Returns:
        the decoded value, which may be an empty array
        Throws:
        KeyDerivationException - if parameter value could not be decoded successfully
      • padParam

        @Nullable
        protected static String padParam​(@Nullable
                                         String value)
        Pad the specified concatenation parameter value for output in the formed required by XML Encryption 1.1.

        No syntactic validation is done on the input value. Since only whole byte-aligned values are not supported, this method merely pre-pends "00" to indicate 0 padding bits.

        Parameters:
        value - the value to process
        Returns:
        the padded value, which may be null
      • unpadParam

        @Nullable
        protected static String unpadParam​(@Nullable
                                           String value,
                                           @Nullable
                                           String name)
                                    throws KeyDerivationException
        Unpad the specified concatenation parameter value from the padded from required by XML Encryption 1.1 for input to the derivation operation.

        Since only whole byte-aligned values supported, this method required input values to begin with "00", indicating 0 padding bits.

        Parameters:
        value - the value to process
        name - the name of the value being processed, for diagnostic purposes
        Returns:
        the unpadded value, which may be null
        Throws:
        KeyDerivationException - if the input value is invalid