def decode_handshake(handshake):
    """
    Decodes a received handshake.

    :param handshake: The raw byte string that is received.
    :return: Dict with the keys pstr, pstrlen, reserved, info_hash and peer_id
    """
    handshake = list(handshake)
    handshake.reverse()

    pstrlen = ord(handshake.pop())

    pstr = b""
    for _ in range(pstrlen):
        pstr += handshake.pop()

    reserved = b""
    for _ in range(8):
        reserved += handshake.pop()

    info_hash = b""
    for _ in range(20):
        info_hash += handshake.pop()

    peer_id = b""
    for _ in range(20):
        peer_id += handshake.pop()

    decoded_handshake = dict(pstr=pstr, pstrlen=pstrlen, reserved=reserved,
                             info_hash=info_hash, peer_id=peer_id)

    return decoded_handshake