private byte[] getHMAC(byte[] message) {

        try {
            return getMacInstance(mode, key).doFinal(message);
        }
        catch (InvalidKeyException e) {

            // As the key is verified during construction of the TOTPGenerator,
            // this should never happen
            throw new IllegalStateException("Provided key became invalid after "
                    + "passing validation.", e);

        }

    }
Calculates the HMAC for the given message using the key and algorithm
provided when this TOTPGenerator was created.

@param message
    The message to calculate the HMAC of.

@return
    The HMAC of the given message.
extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/totp/TOTPGenerator.java