ddnet/src/engine/map.h
heinrich5991 ca8fcc823c Use more secure hash function for map downloads
SHA256 was chosen because it is reasonably standard, the file names
don't explode in length (this rules out SHA512) and it is supported by
basically all versions of OpenSSL (this rules out SHA512/256 and SHA3).

The protocol is changed in a backward compatible way: The supporting
server sends the SHA256 corresponding to the map in the `MAP_DETAILS`
message prior to sending the `MAP_CHANGE` message. The client saves the
SHA256 obtained from the `MAP_DETAILS` message until the next
`MAP_CHANGE` message.

For servers not supporting this protocol, the client falls back to
simply opening maps like in the previous scheme.

Remove the `map_version` tool, it is not being used and would have been
a little bit effort to update.

Use the OpenSSL implementation of SHA256 if it is supported, otherwise
fall back to a public domain one.

Fix #1127.
2018-06-24 17:04:50 +02:00

41 lines
1.1 KiB
C++

/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef ENGINE_MAP_H
#define ENGINE_MAP_H
#include <base/hash.h>
#include "kernel.h"
class IMap : public IInterface
{
MACRO_INTERFACE("map", 0)
public:
virtual void *GetData(int Index) = 0;
virtual int GetDataSize(int Index) = 0;
virtual void *GetDataSwapped(int Index) = 0;
virtual void UnloadData(int Index) = 0;
virtual void *GetItem(int Index, int *Type, int *pID) = 0;
virtual int GetItemSize(int Index) = 0;
virtual void GetType(int Type, int *pStart, int *pNum) = 0;
virtual void *FindItem(int Type, int ID) = 0;
virtual int NumItems() = 0;
};
class IEngineMap : public IMap
{
MACRO_INTERFACE("enginemap", 0)
public:
virtual bool Load(const char *pMapName) = 0;
virtual bool IsLoaded() = 0;
virtual void Unload() = 0;
virtual SHA256_DIGEST Sha256() = 0;
virtual unsigned Crc() = 0;
virtual int MapSize() = 0;
virtual IOHANDLE File() = 0;
};
extern IEngineMap *CreateEngineMap();
#endif