code: public void calculateDigest(int digestPos, byte[] handshakeMessage, int handshakeOffset, byte[] key, int keyLen, byte[] digest, int digestOffset) {
          if (log.isTraceEnabled()) {
              log.trace("calculateDigest - digestPos: {} handshakeOffset: {} keyLen: {} digestOffset: {}", digestPos, handshakeOffset, keyLen, digestOffset);
          }
          int messageLen = Constants.HANDSHAKE_SIZE - DIGEST_LENGTH; // 1504
          byte[] message = new byte[messageLen];
          // copy bytes from handshake message starting at handshake offset into message start at index 0 and up-to digest position length
          System.arraycopy(handshakeMessage, handshakeOffset, message, 0, digestPos);
          // copy bytes from handshake message starting at handshake offset plus digest position plus digest length
          // into message start at digest position and up-to message length minus digest position
          System.arraycopy(handshakeMessage, handshakeOffset + digestPos + DIGEST_LENGTH, message, digestPos, messageLen - digestPos);
          calculateHMAC_SHA256(message, 0, messageLen, key, keyLen, digest, digestOffset);
      }
docs: Calculates the digest given the its offset in the handshake data.
  
  @param digestPos digest position
  @param handshakeMessage handshake message
  @param handshakeOffset handshake message offset
  @param key contains the key
  @param keyLen the length of the key
  @param digest contains the calculated digest
  @param digestOffset digest offset