def METHOD_NAME(
    self, algorithm: HashAlgorithm
) -> KeySerializationEncryptionBuilder:
    if self._format is not PrivateFormat.PKCS12:
        raise TypeError(
            "hmac_hash only supported with PrivateFormat.PKCS12"
        )
    if self._hmac_hash is not None:
        raise ValueError("hmac_hash already set")
    return KeySerializationEncryptionBuilder(
        self._format,
        _kdf_rounds=self._kdf_rounds,
        _hmac_hash=algorithm,
        _key_cert_algorithm=self._key_cert_algorithm,
    )