import json
import base64


def deserialize_validation_info(raw):
    """Deserialize the raw validation info.

    Args:
        raw (unicode or bytes):
            The raw validation info from the client.

    Returns:
        dict:
        The deserialized validation info.

    Raises:
        ValueError:
            Either the data could not be base64-decoded or the resulting JSON
            was of an invalid format (i.e., it was not a dictionary).

        TypeError:
            The base64-decoded data could not be interpreted as JSON.
    """
    value = json.loads(base64.b64decode(raw))

    if not isinstance(value, dict):
        raise ValueError('Invalid format.')

    return value