def frame_iv(algorithm, sequence_number):
    """Builds the deterministic IV for a body frame.

    :param algorithm: Algorithm for which to build IV
    :type algorithm: aws_encryption_sdk.identifiers.Algorithm
    :param int sequence_number: Frame sequence number
    :returns: Generated IV
    :rtype: bytes
    :raises ActionNotAllowedError: if sequence number of out bounds
    """
    if sequence_number < 1 or sequence_number > MAX_FRAME_COUNT:
        raise ActionNotAllowedError(
            "Invalid frame sequence number: {actual}\nMust be between 1 and {max}".format(
                actual=sequence_number, max=MAX_FRAME_COUNT
            )
        )
    prefix_len = algorithm.iv_len - 4
    prefix = b"\x00" * prefix_len
    return prefix + struct.pack(">I", sequence_number)
Builds the deterministic IV for a body frame.

    :param algorithm: Algorithm for which to build IV
    :type algorithm: aws_encryption_sdk.identifiers.Algorithm
    :param int sequence_number: Frame sequence number
    :returns: Generated IV
    :rtype: bytes
    :raises ActionNotAllowedError: if sequence number of out bounds