X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=crypto.h;h=0a2d4869cea4679813929d6c33da8b85acd2da36;hp=507c0a06242157b85be327806279e8711c72d938;hb=85a33377d64ae8438e6582a7b8472f5a4bd41942;hpb=e4e06ca028a8aa4d33db30946a8909a86c141f99 diff --git a/crypto.h b/crypto.h index 507c0a06..0a2d4869 100644 --- a/crypto.h +++ b/crypto.h @@ -20,9 +20,11 @@ typedef struct { unsigned char dhkey[DHKEY_SIZE]; // shared key, not NUL terminated char client_idfp[FP64_SIZE+1]; - char client_keyfp[FP64_SIZE+1]; // NULL if signature fail + char client_keyfp[FP64_SIZE+1]; + qboolean client_issigned; char server_idfp[FP64_SIZE+1]; - char server_keyfp[FP64_SIZE+1]; // NULL if signature fail + char server_keyfp[FP64_SIZE+1]; + qboolean server_issigned; qboolean authenticated; qboolean use_aes; void *data; @@ -31,7 +33,10 @@ crypto_t; void Crypto_Init(void); void Crypto_Init_Commands(void); +void Crypto_LoadKeys(void); // NOTE: when this is called, the SV_LockThreadMutex MUST be active void Crypto_Shutdown(void); +qboolean Crypto_Available(void); +void sha256(unsigned char *out, const unsigned char *in, int n); // may ONLY be called if Crypto_Available() const void *Crypto_EncryptPacket(crypto_t *crypto, const void *data_src, size_t len_src, void *data_dst, size_t *len_dst, size_t len); const void *Crypto_DecryptPacket(crypto_t *crypto, const void *data_src, size_t len_src, void *data_dst, size_t *len_dst, size_t len); #define CRYPTO_NOMATCH 0 // process as usual (packet was not used) @@ -45,13 +50,13 @@ int Crypto_ServerParsePacket(const char *data_in, size_t len_in, char *data_out, qboolean Crypto_ServerAppendToChallenge(const char *data_in, size_t len_in, char *data_out, size_t *len_out, size_t maxlen); crypto_t *Crypto_ServerGetInstance(lhnetaddress_t *peeraddress); -qboolean Crypto_ServerFinishInstance(crypto_t *out, crypto_t *in); // also clears allocated memory +qboolean Crypto_FinishInstance(crypto_t *out, crypto_t *in); // also clears allocated memory, and frees the instance received by ServerGetInstance const char *Crypto_GetInfoResponseDataString(void); // retrieves a host key for an address (can be exposed to menuqc, or used by the engine to look up stored keys e.g. for server bookmarking) // pointers may be NULL -qboolean Crypto_RetrieveHostKey(lhnetaddress_t *peeraddress, int *keyid, char *keyfp, size_t keyfplen, char *idfp, size_t idfplen, int *aeslevel); -int Crypto_RetrieveLocalKey(int keyid, char *keyfp, size_t keyfplen, char *idfp, size_t idfplen); // return value: -1 if more to come, +1 if valid, 0 if end of list +qboolean Crypto_RetrieveHostKey(lhnetaddress_t *peeraddress, int *keyid, char *keyfp, size_t keyfplen, char *idfp, size_t idfplen, int *aeslevel, qboolean *issigned); +int Crypto_RetrieveLocalKey(int keyid, char *keyfp, size_t keyfplen, char *idfp, size_t idfplen, qboolean *issigned); // return value: -1 if more to come, +1 if valid, 0 if end of list size_t Crypto_SignData(const void *data, size_t datasize, int keyid, void *signed_data, size_t signed_size); size_t Crypto_SignDataDetached(const void *data, size_t datasize, int keyid, void *signed_data, size_t signed_size);