![]() |
DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
|
|
#include "quakedef.h"
#include "crypto.h"
#include "common.h"
#include "thread.h"
#include "hmac.h"
#include "libcurl.h"
Go to the source code of this file.
Data Structures | |
struct | crypto_data_t |
struct | crypto_storedhostkey_t |
struct | server_cryptoconnect_t |
Macros | |
#define | CDATA ((crypto_data_t *) crypto->data) |
#define | CLEAR_CDATA if(crypto->data) { if(CDATA->id) qd0_blind_id_free(CDATA->id); Z_Free(crypto->data); } crypto->data = NULL |
#define | CRYPTOCONNECT_CONNECT 2 |
#define | CRYPTOCONNECT_DUPLICATE 4 |
#define | CRYPTOCONNECT_NONE 0 |
#define | CRYPTOCONNECT_PRECONNECT 1 |
#define | CRYPTOCONNECT_RECONNECT 3 |
#define | D0_BOOL int |
#define | D0_EXPORT |
#define | D0_RIJNDAEL_KEYLENGTH(keybits) |
#define | D0_RIJNDAEL_NROUNDS(keybits) |
#define | D0_RIJNDAEL_RKLENGTH(keybits) |
#define | D0_WARN_UNUSED_RESULT |
#define | FOURCC_D0ER (('d' << 0) | ('0' << 8) | ('e' << 16) | ('r' << 24)) |
#define | FOURCC_D0IC (('d' << 0) | ('0' << 8) | ('i' << 16) | ('c' << 24)) |
#define | FOURCC_D0IQ (('d' << 0) | ('0' << 8) | ('i' << 16) | ('q' << 24)) |
#define | FOURCC_D0IR (('d' << 0) | ('0' << 8) | ('i' << 16) | ('r' << 24)) |
#define | FOURCC_D0PI (('d' << 0) | ('0' << 8) | ('p' << 16) | ('i' << 24)) |
#define | FOURCC_D0PK (('d' << 0) | ('0' << 8) | ('p' << 16) | ('k' << 24)) |
#define | FOURCC_D0SI (('d' << 0) | ('0' << 8) | ('s' << 16) | ('i' << 24)) |
#define | FOURCC_D0SK (('d' << 0) | ('0' << 8) | ('s' << 16) | ('k' << 24)) |
#define | MAKE_CDATA if(!crypto->data) crypto->data = Z_Malloc(sizeof(crypto_data_t)) |
#define | MAX_CRYPTOCONNECTS 16 |
#define | MAX_PUBKEYS 16 |
#define | PROTOCOL_D0_BLIND_ID FOURCC_D0PK |
#define | PROTOCOL_VLEN (('v' << 0) | ('l' << 8) | ('e' << 16) | ('n' << 24)) |
#define | USE_AES |
Typedefs | |
typedef struct d0_blind_id_s | d0_blind_id_t |
typedef void * | d0_createmutex_t(void) |
typedef void | d0_destroymutex_t(void *) |
typedef D0_BOOL(* | d0_fastreject_function) (const d0_blind_id_t *ctx, void *pass) |
typedef void | d0_free_t(void *p) |
typedef int | d0_lockmutex_t(void *) |
typedef void * | d0_malloc_t(size_t len) |
typedef int | d0_unlockmutex_t(void *) |
Functions | |
static void | aescpy (unsigned char *key, const unsigned char *iv, unsigned char *dst, const unsigned char *src, size_t len) |
static qbool | Crypto_AddPrivateKey (d0_blind_id_t *pk, char *buf, size_t len) |
qbool | Crypto_Available (void) |
static void | Crypto_BuildChallengeAppend (void) |
static void | Crypto_BuildIdString (void) |
static qbool | Crypto_ClearHostKey (lhnetaddress_t *peeraddress) |
static void | Crypto_ClearHostKeys (void) |
static int | Crypto_ClientError (char *data_out, size_t *len_out, const char *msg) |
int | Crypto_ClientParsePacket (const char *data_in, size_t len_in, char *data_out, size_t *len_out, lhnetaddress_t *peeraddress, const char *peeraddressstring) |
static void | Crypto_CloseLibrary (void) |
static void * | Crypto_d0_createmutex (void) |
static void | Crypto_d0_destroymutex (void *m) |
static void | Crypto_d0_free (void *p) |
static int | Crypto_d0_lockmutex (void *m) |
static void * | Crypto_d0_malloc (size_t len) |
static int | Crypto_d0_unlockmutex (void *m) |
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) |
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) |
qbool | Crypto_FinishInstance (crypto_t *out, crypto_t *crypto) |
const char * | Crypto_GetInfoResponseDataString (void) |
static void | Crypto_HostKey_Clear_f (cmd_state_t *cmd) |
static void | Crypto_HostKeys_f (cmd_state_t *cmd) |
void | Crypto_Init (void) |
void | Crypto_Init_Commands (void) |
static void | Crypto_InitHostKeys (void) |
static void | Crypto_KeyGen_f (cmd_state_t *cmd) |
static void | Crypto_KeyGen_Finished (int code, size_t length_received, unsigned char *buffer, void *cbdata) |
static void | Crypto_Keys_f (cmd_state_t *cmd) |
static unsigned long | Crypto_LittleLong (const char *data) |
static size_t | Crypto_LoadFile (const char *path, char *buf, size_t nmax, qbool inuserdir) |
void | Crypto_LoadKeys (void) |
static qbool | Crypto_OpenLibrary (void) |
static size_t | Crypto_ParsePack (const char *buf, size_t len, unsigned long header, const char **lumps, size_t *lumpsize, size_t nlumps) |
static d0_blind_id_t * | Crypto_ReadPublicKey (char *buf, size_t len) |
static void | Crypto_Reload_f (cmd_state_t *cmd) |
qbool | Crypto_RetrieveHostKey (lhnetaddress_t *peeraddress, int *keyid, char *keyfp, size_t keyfplen, char *idfp, size_t idfplen, int *aeslevel, qbool *issigned) |
int | Crypto_RetrieveLocalKey (int keyid, char *keyfp, size_t keyfplen, char *idfp, size_t idfplen, qbool *issigned) |
static void | Crypto_Rijndael_CloseLibrary (void) |
static qbool | Crypto_Rijndael_OpenLibrary (void) |
static qbool | Crypto_SavePubKeyTextFile (int i) |
qbool | Crypto_ServerAppendToChallenge (const char *data_in, size_t len_in, char *data_out, size_t *len_out, size_t maxlen_out) |
static int | Crypto_ServerError (char *data_out, size_t *len_out, const char *msg, const char *msg_client) |
static crypto_t * | Crypto_ServerFindInstance (lhnetaddress_t *peeraddress, qbool allow_create) |
crypto_t * | Crypto_ServerGetInstance (lhnetaddress_t *peeraddress) |
int | Crypto_ServerParsePacket (const char *data_in, size_t len_in, char *data_out, size_t *len_out, lhnetaddress_t *peeraddress) |
static int | Crypto_ServerParsePacket_Internal (const char *data_in, size_t len_in, char *data_out, size_t *len_out, lhnetaddress_t *peeraddress) |
void | Crypto_Shutdown (void) |
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) |
static int | Crypto_SoftClientError (char *data_out, size_t *len_out, const char *msg) |
static int | Crypto_SoftServerError (char *data_out, size_t *len_out, const char *msg) |
static void | Crypto_StoreHostKey (lhnetaddress_t *peeraddress, const char *keystring, qbool complain) |
static void | Crypto_UnLittleLong (char *data, unsigned long l) |
static void | Crypto_UnloadKeys (void) |
static size_t | Crypto_UnParsePack (char *buf, size_t len, unsigned long header, const char *const *lumps, const size_t *lumpsize, size_t nlumps) |
static const char * | GetUntilNul (const char **data, size_t *len) |
static qbool | PutWithNul (char **data, size_t *len, const char *str) |
static void | seacpy (unsigned char *key, const unsigned char *iv, unsigned char *dst, const unsigned char *src, size_t len) |
void | sha256 (unsigned char *out, const unsigned char *in, int n) |
#define CDATA ((crypto_data_t *) crypto->data) |
Definition at line 524 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
#define CLEAR_CDATA if(crypto->data) { if(CDATA->id) qd0_blind_id_free(CDATA->id); Z_Free(crypto->data); } crypto->data = NULL |
Definition at line 526 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), Crypto_FinishInstance(), Crypto_ServerFindInstance(), Crypto_ServerParsePacket_Internal(), and Crypto_Shutdown().
#define D0_BOOL int |
Definition at line 187 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), Crypto_KeyGen_Finished(), Crypto_LoadKeys(), Crypto_ServerParsePacket_Internal(), and main().
#define D0_RIJNDAEL_KEYLENGTH | ( | keybits | ) |
#define D0_RIJNDAEL_NROUNDS | ( | keybits | ) |
#define D0_RIJNDAEL_RKLENGTH | ( | keybits | ) |
#define FOURCC_D0ER (('d' << 0) | ('0' << 8) | ('e' << 16) | ('r' << 24)) |
Definition at line 56 of file crypto.c.
Referenced by Crypto_KeyGen_Finished().
#define FOURCC_D0IC (('d' << 0) | ('0' << 8) | ('i' << 16) | ('c' << 24)) |
#define FOURCC_D0IQ (('d' << 0) | ('0' << 8) | ('i' << 16) | ('q' << 24)) |
Definition at line 54 of file crypto.c.
Referenced by Crypto_KeyGen_f().
Definition at line 55 of file crypto.c.
Referenced by Crypto_KeyGen_Finished().
#define FOURCC_D0PI (('d' << 0) | ('0' << 8) | ('p' << 16) | ('i' << 24)) |
#define FOURCC_D0PK (('d' << 0) | ('0' << 8) | ('p' << 16) | ('k' << 24)) |
Definition at line 50 of file crypto.c.
Referenced by Crypto_ReadPublicKey().
#define FOURCC_D0SI (('d' << 0) | ('0' << 8) | ('s' << 16) | ('i' << 24)) |
Definition at line 53 of file crypto.c.
Referenced by Crypto_AddPrivateKey(), Crypto_KeyGen_f(), and Crypto_KeyGen_Finished().
#define FOURCC_D0SK (('d' << 0) | ('0' << 8) | ('s' << 16) | ('k' << 24)) |
#define MAKE_CDATA if(!crypto->data) crypto->data = Z_Malloc(sizeof(crypto_data_t)) |
Definition at line 525 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
#define MAX_CRYPTOCONNECTS 16 |
Definition at line 493 of file crypto.c.
Referenced by Crypto_ServerFindInstance(), and Crypto_Shutdown().
#define MAX_PUBKEYS 16 |
Definition at line 481 of file crypto.c.
Referenced by Crypto_BuildChallengeAppend(), Crypto_BuildIdString(), Crypto_ClientParsePacket(), Crypto_KeyGen_Finished(), Crypto_Keys_f(), Crypto_LoadKeys(), Crypto_RetrieveLocalKey(), Crypto_ServerParsePacket_Internal(), Crypto_SignData(), Crypto_SignDataDetached(), Crypto_StoreHostKey(), and Crypto_UnloadKeys().
#define PROTOCOL_D0_BLIND_ID FOURCC_D0PK |
Definition at line 46 of file crypto.c.
Referenced by Crypto_BuildChallengeAppend(), and Crypto_ClientParsePacket().
Definition at line 47 of file crypto.c.
Referenced by Crypto_BuildChallengeAppend(), and Crypto_ClientParsePacket().
typedef struct d0_blind_id_s d0_blind_id_t |
typedef D0_BOOL(* d0_fastreject_function) (const d0_blind_id_t *ctx, void *pass) |
|
static |
Definition at line 1472 of file crypto.c.
References D0_RIJNDAEL_NROUNDS, D0_RIJNDAEL_RKLENGTH, DHKEY_SIZE, i, qd0_rijndael_encrypt, qd0_rijndael_setup_encrypt, and src.
Referenced by Crypto_EncryptPacket().
|
static |
Definition at line 469 of file crypto.c.
References buf, Crypto_ParsePack(), FOURCC_D0SI, and qd0_blind_id_read_private_id.
Referenced by Crypto_LoadKeys().
Definition at line 1097 of file crypto.c.
References d0_blind_id_dll.
Referenced by checkextension(), and VM_digest_hex().
Definition at line 785 of file crypto.c.
References challenge_append, challenge_append_length, Crypto_UnLittleLong(), i, MAX_PUBKEYS, n, PROTOCOL_D0_BLIND_ID, PROTOCOL_VLEN, pubkeys, pubkeys_fp64, pubkeys_havepriv, and PutWithNul().
Referenced by Crypto_KeyGen_f(), and Crypto_LoadKeys().
Definition at line 842 of file crypto.c.
References crypto_aeslevel, crypto_idstring, crypto_idstring_buf, d0_rijndael_dll, dp_strlcat, dpsnprintf(), i, cvar_t::integer, MAX_PUBKEYS, NULL, pubkeys, pubkeys_fp64, pubkeys_havesig, pubkeys_priv_fp64, and va().
Referenced by Crypto_KeyGen_Finished(), and Crypto_LoadKeys().
|
static |
Definition at line 613 of file crypto.c.
References buf, CRC_Block(), CRYPTO_HOSTKEY_HASHSIZE, crypto_storedhostkey_hashtable, LHNETADDRESS_Compare(), LHNETADDRESS_ToString(), crypto_storedhostkey_t::next, strlen(), and Z_Free.
Referenced by Crypto_HostKey_Clear_f().
Definition at line 598 of file crypto.c.
References CRYPTO_HOSTKEY_HASHSIZE, crypto_storedhostkey_hashtable, i, crypto_storedhostkey_t::next, NULL, and Z_Free.
Referenced by Crypto_Reload_f().
|
static |
Definition at line 2093 of file crypto.c.
References CRYPTO_REPLACE, dpsnprintf(), and strlen().
Referenced by Crypto_ClientParsePacket().
int Crypto_ClientParsePacket | ( | const char * | data_in, |
size_t | len_in, | ||
char * | data_out, | ||
size_t * | len_out, | ||
lhnetaddress_t * | peeraddress, | ||
const char * | peeraddressstring ) |
Definition at line 2107 of file crypto.c.
References crypto_t::authenticated, bound, BuffLittleLong(), CCREP_PLAYER_INFO, CCREP_RULE_INFO, CCREP_SERVER_INFO, CDATA, cdata_id, CLEAR_CDATA, crypto_t::client_idfp, crypto_t::client_issigned, crypto_t::client_keyfp, cls, client_static_t::connect_address, client_static_t::connect_nextsendtime, client_static_t::connect_trying, client_static_t::crypto, crypto_aeslevel, Crypto_ClientError(), CRYPTO_DISCARD, Crypto_LittleLong(), CRYPTO_NOMATCH, CRYPTO_REPLACE, Crypto_RetrieveHostKey(), Crypto_SoftClientError(), Crypto_StoreHostKey(), d0_blind_id_dll, D0_BOOL, d0_rijndael_dll, crypto_t::dhkey, DHKEY_SIZE, dp_strlcpy, dpsnprintf(), FP64_SIZE, GetUntilNul(), host, i, id, InfoString_GetValue(), cvar_t::integer, LHNETADDRESS_Compare(), MAKE_CDATA, max, MAX_INPUTLINE, MAX_PUBKEYS, net_sourceaddresscheck, NETFLAG_CTL, NULL, PROTOCOL_D0_BLIND_ID, PROTOCOL_VLEN, pubkeys, pubkeys_fp64, pubkeys_havepriv, pubkeys_havesig, pubkeys_priv_fp64, PutWithNul(), qd0_blind_id_authenticate_with_private_id_challenge, qd0_blind_id_authenticate_with_private_id_response, qd0_blind_id_authenticate_with_private_id_start, qd0_blind_id_authenticate_with_private_id_verify, qd0_blind_id_copy, qd0_blind_id_fingerprint64_public_id, qd0_blind_id_new, qd0_blind_id_sessionkey_public_id, host_static_t::realtime, crypto_t::server_idfp, crypto_t::server_issigned, crypto_t::server_keyfp, crypto_t::use_aes, v, and va().
Referenced by NetConn_ClientParsePacket().
Definition at line 306 of file crypto.c.
References d0_blind_id_dll, and Sys_FreeLibrary().
Referenced by Crypto_Init(), and Crypto_Shutdown().
Definition at line 1020 of file crypto.c.
References Thread_CreateMutex.
Referenced by Crypto_Init().
Definition at line 1025 of file crypto.c.
References Thread_DestroyMutex.
Referenced by Crypto_Init().
Definition at line 1030 of file crypto.c.
References Thread_LockMutex.
Referenced by Crypto_Init().
|
static |
Definition at line 1010 of file crypto.c.
References cryptomempool, and Mem_Alloc.
Referenced by Crypto_Init().
Definition at line 1035 of file crypto.c.
References Thread_UnlockMutex.
Referenced by Crypto_Init().
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 ) |
Definition at line 1584 of file crypto.c.
References crypto_t::authenticated, BuffBigLong(), Com_HexDumpToConsole(), Con_Print(), Con_Printf(), developer_networking, crypto_t::dhkey, DHKEY_SIZE, HMAC_SHA256_32BYTES, i, cvar_t::integer, NULL, seacpy(), and crypto_t::use_aes.
Referenced by NetConn_ReceivedMessage().
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 ) |
Definition at line 1527 of file crypto.c.
References aescpy(), crypto_t::authenticated, BuffBigLong(), Com_HexDumpToConsole(), Con_Print(), Con_Printf(), developer_networking, crypto_t::dhkey, DHKEY_SIZE, HMAC_SHA256_32BYTES, i, cvar_t::integer, NULL, and crypto_t::use_aes.
Referenced by NetConn_ReceivedMessage(), and NetConn_SendUnreliableMessage().
Definition at line 558 of file crypto.c.
References crypto_t::authenticated, CLEAR_CDATA, and Con_Printf().
Referenced by NetConn_ConnectionEstablished(), and NetConn_ServerParsePacket().
const char * Crypto_GetInfoResponseDataString | ( | void | ) |
Definition at line 1689 of file crypto.c.
References crypto_aeslevel, crypto_idstring, crypto_idstring_buf, and cvar_t::integer.
Referenced by NetConn_BuildStatusResponse().
|
static |
Definition at line 1428 of file crypto.c.
References addr, cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), Con_Printf(), Crypto_ClearHostKey(), d0_blind_id_dll, i, and LHNETADDRESS_FromString().
Referenced by Crypto_Init_Commands().
|
static |
Definition at line 1403 of file crypto.c.
References crypto_storedhostkey_t::addr, crypto_storedhostkey_t::aeslevel, buf, Con_Print(), Con_Printf(), CRYPTO_HOSTKEY_HASHSIZE, crypto_keyfp_recommended_length, crypto_storedhostkey_hashtable, d0_blind_id_dll, i, crypto_storedhostkey_t::idfp, crypto_storedhostkey_t::keyid, LHNETADDRESS_ToString(), crypto_storedhostkey_t::next, and pubkeys_fp64.
Referenced by Crypto_Init_Commands().
Definition at line 1072 of file crypto.c.
References Con_Printf(), Crypto_CloseLibrary(), Crypto_d0_createmutex(), Crypto_d0_destroymutex(), Crypto_d0_free(), Crypto_d0_lockmutex(), Crypto_d0_malloc(), Crypto_d0_unlockmutex(), Crypto_InitHostKeys(), Crypto_OpenLibrary(), Crypto_Rijndael_CloseLibrary(), Crypto_Rijndael_OpenLibrary(), cryptomempool, Mem_AllocPool, NULL, qd0_blind_id_INITIALIZE, qd0_blind_id_setmallocfuncs, qd0_blind_id_setmutexfuncs, Thread_HasThreads(), and void().
Referenced by Host_Init().
Definition at line 1449 of file crypto.c.
References CF_SHARED, Cmd_AddCommand(), crypto_aeslevel, crypto_developer, Crypto_HostKey_Clear_f(), Crypto_HostKeys_f(), Crypto_KeyGen_f(), Crypto_Keys_f(), Crypto_Reload_f(), crypto_servercpudebug, crypto_servercpumaxtime, crypto_servercpupercent, Cvar_RegisterVariable(), d0_blind_id_dll, d0_rijndael_dll, and cvar_t::integer.
Referenced by Host_Init().
Definition at line 591 of file crypto.c.
References CRYPTO_HOSTKEY_HASHSIZE, crypto_storedhostkey_hashtable, i, and NULL.
Referenced by Crypto_Init().
|
static |
Definition at line 1217 of file crypto.c.
References base64_encode(), buf, cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), Con_Printf(), Crypto_BuildChallengeAppend(), crypto_idstring, crypto_idstring_buf, Crypto_KeyGen_Finished(), Crypto_LoadKeys(), Crypto_SavePubKeyTextFile(), Crypto_UnParsePack(), Curl_Begin_ToMemory(), d0_blind_id_dll, dp_strlcat, f, FOURCC_D0IQ, FOURCC_D0SI, FP64_SIZE, fs_basedir, FS_Close(), FS_CreatePath(), FS_SysOpen(), fs_userdir, FS_Write(), i, keygen_buf, keygen_i, NULL, pubkeys, pubkeys_fp64, pubkeys_havepriv, pubkeys_havesig, pubkeys_priv_fp64, qd0_blind_id_fingerprint64_public_id, qd0_blind_id_generate_private_id_request, qd0_blind_id_generate_private_id_start, qd0_blind_id_verify_private_id, qd0_blind_id_write_private_id, sessionid, cvar_t::string, strlen(), SV_LockThreadMutex, SV_UnlockThreadMutex, and va().
Referenced by Crypto_Init_Commands().
|
static |
Definition at line 1105 of file crypto.c.
References buf, buffer, Com_HexDumpToConsole(), CON_ERROR, Con_Print(), Con_Printf(), Crypto_BuildIdString(), Crypto_LittleLong(), Crypto_ParsePack(), Crypto_SavePubKeyTextFile(), Crypto_UnParsePack(), d0_blind_id_dll, D0_BOOL, f, FOURCC_D0ER, FOURCC_D0IR, FOURCC_D0SI, fs_basedir, FS_Close(), FS_CreatePath(), FS_SysOpen(), fs_userdir, FS_Write(), keygen_i, MAX_PUBKEYS, NULL, pubkeys, pubkeys_havesig, pubkeys_priv_fp64, qd0_blind_id_finish_private_id_request, qd0_blind_id_verify_public_id, qd0_blind_id_write_private_id, sessionid, cvar_t::string, SV_LockThreadMutex, SV_UnlockThreadMutex, and va().
Referenced by Crypto_KeyGen_f().
|
static |
Definition at line 1380 of file crypto.c.
References Con_Print(), Con_Printf(), d0_blind_id_dll, i, MAX_PUBKEYS, pubkeys, pubkeys_fp64, pubkeys_havepriv, pubkeys_havesig, pubkeys_priv_fp64, sessionid, and cvar_t::string.
Referenced by Crypto_Init_Commands().
|
static |
Definition at line 59 of file crypto.c.
References data.
Referenced by Crypto_ClientParsePacket(), Crypto_KeyGen_Finished(), and Crypto_ParsePack().
|
static |
Definition at line 388 of file crypto.c.
References buf, f, fs_basedir, FS_Close(), FS_Read(), FS_SysOpen(), fs_userdir, n, NULL, and va().
Referenced by Crypto_LoadKeys().
Definition at line 855 of file crypto.c.
References buf, Con_Printf(), Crypto_AddPrivateKey(), Crypto_BuildChallengeAppend(), Crypto_BuildIdString(), crypto_idstring, crypto_keyfp_recommended_length, Crypto_LoadFile(), Crypto_ReadPublicKey(), Crypto_SavePubKeyTextFile(), d0_blind_id_dll, D0_BOOL, FP64_SIZE, Host_LockSession(), i, keygen_i, MAX_PUBKEYS, NULL, pubkeys, pubkeys_fp64, pubkeys_havepriv, pubkeys_havesig, pubkeys_priv_fp64, qd0_blind_id_fingerprint64_public_id, qd0_blind_id_fingerprint64_public_key, qd0_blind_id_free, qd0_blind_id_verify_private_id, qd0_blind_id_verify_public_id, sessionid, cvar_t::string, and va().
Referenced by Crypto_KeyGen_f(), Crypto_Reload_f(), NetConn_OpenClientPorts(), NetConn_OpenServerPorts(), and PRVM_Prog_Load().
Definition at line 283 of file crypto.c.
References d0_blind_id_dll, d0_blind_id_funcs, NULL, and Sys_LoadDependency().
Referenced by Crypto_Init().
|
static |
Definition at line 76 of file crypto.c.
References buf, Crypto_LittleLong(), and i.
Referenced by Crypto_AddPrivateKey(), Crypto_KeyGen_Finished(), and Crypto_ReadPublicKey().
|
static |
Definition at line 450 of file crypto.c.
References buf, Crypto_ParsePack(), FOURCC_D0PK, NULL, qd0_blind_id_free, qd0_blind_id_new, qd0_blind_id_read_private_id_modulus, and qd0_blind_id_read_public_key.
Referenced by Crypto_LoadKeys().
|
static |
Definition at line 1373 of file crypto.c.
References Crypto_ClearHostKeys(), Crypto_LoadKeys(), and Crypto_UnloadKeys().
Referenced by Crypto_Init_Commands().
qbool Crypto_RetrieveHostKey | ( | lhnetaddress_t * | peeraddress, |
int * | keyid, | ||
char * | keyfp, | ||
size_t | keyfplen, | ||
char * | idfp, | ||
size_t | idfplen, | ||
int * | aeslevel, | ||
qbool * | issigned ) |
Definition at line 734 of file crypto.c.
References crypto_storedhostkey_t::addr, crypto_storedhostkey_t::aeslevel, buf, CRC_Block(), CRYPTO_HOSTKEY_HASHSIZE, crypto_storedhostkey_hashtable, d0_blind_id_dll, dp_strlcpy, crypto_storedhostkey_t::idfp, crypto_storedhostkey_t::issigned, crypto_storedhostkey_t::keyid, LHNETADDRESS_Compare(), LHNETADDRESS_ToString(), crypto_storedhostkey_t::next, pubkeys_fp64, and strlen().
Referenced by Crypto_ClientParsePacket(), VM_M_crypto_getencryptlevel(), VM_M_crypto_getidfp(), VM_M_crypto_getidstatus(), and VM_M_crypto_getkeyfp().
int Crypto_RetrieveLocalKey | ( | int | keyid, |
char * | keyfp, | ||
size_t | keyfplen, | ||
char * | idfp, | ||
size_t | idfplen, | ||
qbool * | issigned ) |
Definition at line 763 of file crypto.c.
References dp_strlcpy, MAX_PUBKEYS, pubkeys, pubkeys_fp64, pubkeys_havepriv, pubkeys_havesig, and pubkeys_priv_fp64.
Referenced by VM_M_crypto_getmyidfp(), VM_M_crypto_getmyidstatus(), and VM_M_crypto_getmykeyfp().
Definition at line 375 of file crypto.c.
References d0_rijndael_dll, and Sys_FreeLibrary().
Referenced by Crypto_Init(), and Crypto_Shutdown().
Definition at line 352 of file crypto.c.
References d0_rijndael_dll, d0_rijndael_funcs, NULL, and Sys_LoadDependency().
Referenced by Crypto_Init().
Definition at line 814 of file crypto.c.
References f, fs_basedir, FS_Close(), FS_Printf(), FS_SysOpen(), fs_userdir, i, pubkeys_fp64, pubkeys_havepriv, pubkeys_havesig, pubkeys_priv_fp64, sessionid, cvar_t::string, and va().
Referenced by Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), and Crypto_LoadKeys().
qbool Crypto_ServerAppendToChallenge | ( | const char * | data_in, |
size_t | len_in, | ||
char * | data_out, | ||
size_t * | len_out, | ||
size_t | maxlen_out ) |
Definition at line 1696 of file crypto.c.
References challenge_append, challenge_append_length, and d0_blind_id_dll.
Referenced by NetConn_ServerParsePacket().
|
static |
Definition at line 1709 of file crypto.c.
References Con_DPrintf(), CRYPTO_DISCARD, dpsnprintf(), and strlen().
Referenced by Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 528 of file crypto.c.
References CLEAR_CDATA, server_cryptoconnect_t::crypto, cryptoconnects, d0_blind_id_dll, crypto_t::data, host, i, server_cryptoconnect_t::lasttime, LHNETADDRESS_Compare(), MAX_CRYPTOCONNECTS, NULL, and host_static_t::realtime.
Referenced by Crypto_ServerGetInstance(), and Crypto_ServerParsePacket_Internal().
crypto_t * Crypto_ServerGetInstance | ( | lhnetaddress_t * | peeraddress | ) |
Definition at line 573 of file crypto.c.
References Crypto_ServerFindInstance().
Referenced by NetConn_ServerParsePacket().
int Crypto_ServerParsePacket | ( | const char * | data_in, |
size_t | len_in, | ||
char * | data_out, | ||
size_t * | len_out, | ||
lhnetaddress_t * | peeraddress ) |
Definition at line 2036 of file crypto.c.
References Con_Printf(), CRYPTO_DISCARD, crypto_servercpu_accumulator, crypto_servercpu_lastrealtime, crypto_servercpudebug, crypto_servercpumaxtime, crypto_servercpupercent, Crypto_ServerParsePacket_Internal(), host, InfoString_GetValue(), cvar_t::integer, MAX_INPUTLINE, NULL, host_static_t::realtime, ret, Sys_DirtyTime(), and cvar_t::value.
Referenced by NetConn_ServerParsePacket().
|
static |
Definition at line 1727 of file crypto.c.
References crypto_t::authenticated, bound, CDATA, challenges, CLEAR_CDATA, crypto_t::client_idfp, crypto_t::client_issigned, crypto_t::client_keyfp, crypto_aeslevel, CRYPTO_DISCARD, CRYPTO_MATCH, CRYPTO_NOMATCH, Crypto_ServerError(), Crypto_ServerFindInstance(), Crypto_SoftServerError(), d0_blind_id_dll, D0_BOOL, d0_rijndael_dll, crypto_t::dhkey, DHKEY_SIZE, dp_strlcpy, FP64_SIZE, GetUntilNul(), i, id, InfoString_GetValue(), cvar_t::integer, LHNETADDRESS_Compare(), LHNETADDRESS_GetAddressType(), LHNETADDRESSTYPE_LOOP, MAKE_CDATA, MAX_CHALLENGES, MAX_INPUTLINE, MAX_PUBKEYS, NULL, pubkeys, pubkeys_fp64, pubkeys_havepriv, pubkeys_havesig, pubkeys_priv_fp64, PutWithNul(), qd0_blind_id_authenticate_with_private_id_challenge, qd0_blind_id_authenticate_with_private_id_response, qd0_blind_id_authenticate_with_private_id_start, qd0_blind_id_authenticate_with_private_id_verify, qd0_blind_id_copy, qd0_blind_id_fingerprint64_public_id, qd0_blind_id_new, qd0_blind_id_sessionkey_public_id, crypto_t::server_idfp, crypto_t::server_issigned, crypto_t::server_keyfp, sv_public, time, crypto_t::use_aes, and va().
Referenced by Crypto_ServerParsePacket().
Definition at line 1043 of file crypto.c.
References CLEAR_CDATA, cls, client_static_t::crypto, server_cryptoconnect_t::crypto, Crypto_CloseLibrary(), Crypto_Rijndael_CloseLibrary(), Crypto_UnloadKeys(), cryptoconnects, cryptomempool, d0_blind_id_dll, i, MAX_CRYPTOCONNECTS, Mem_FreePool, and qd0_blind_id_SHUTDOWN.
Referenced by Host_Shutdown().
size_t Crypto_SignData | ( | const void * | data, |
size_t | datasize, | ||
int | keyid, | ||
void * | signed_data, | ||
size_t | signed_size ) |
Definition at line 2634 of file crypto.c.
References data, MAX_PUBKEYS, pubkeys, pubkeys_havepriv, and qd0_blind_id_sign_with_private_id_sign.
size_t Crypto_SignDataDetached | ( | const void * | data, |
size_t | datasize, | ||
int | keyid, | ||
void * | signed_data, | ||
size_t | signed_size ) |
Definition at line 2645 of file crypto.c.
References data, MAX_PUBKEYS, pubkeys, pubkeys_havepriv, and qd0_blind_id_sign_with_private_id_sign_detached.
Referenced by VM_uri_get().
|
static |
Definition at line 2100 of file crypto.c.
References Con_DPrintf(), and CRYPTO_DISCARD.
Referenced by Crypto_ClientParsePacket().
|
static |
Definition at line 1720 of file crypto.c.
References Con_DPrintf(), and CRYPTO_DISCARD.
Referenced by Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 635 of file crypto.c.
References crypto_storedhostkey_t::addr, crypto_storedhostkey_t::aeslevel, bound, buf, Con_Printf(), CRC_Block(), CRYPTO_HOSTKEY_HASHSIZE, crypto_storedhostkey_hashtable, d0_blind_id_dll, FP64_SIZE, crypto_storedhostkey_t::idfp, crypto_storedhostkey_t::issigned, crypto_storedhostkey_t::keyid, LHNETADDRESS_Compare(), LHNETADDRESS_ToString(), max, MAX_PUBKEYS, crypto_storedhostkey_t::next, pubkeys, pubkeys_fp64, strlen(), and Z_Malloc.
Referenced by Crypto_ClientParsePacket().
|
static |
Definition at line 68 of file crypto.c.
References data.
Referenced by Crypto_BuildChallengeAppend(), and Crypto_UnParsePack().
Definition at line 985 of file crypto.c.
References challenge_append_length, crypto_idstring, i, keygen_i, MAX_PUBKEYS, NULL, pubkeys, pubkeys_fp64, pubkeys_havepriv, pubkeys_havesig, pubkeys_priv_fp64, and qd0_blind_id_free.
Referenced by Crypto_Reload_f(), and Crypto_Shutdown().
|
static |
Definition at line 103 of file crypto.c.
References buf, Crypto_UnLittleLong(), and i.
Referenced by Crypto_KeyGen_f(), and Crypto_KeyGen_Finished().
|
static |
Definition at line 418 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 406 of file crypto.c.
References data, and strlen().
Referenced by Crypto_BuildChallengeAppend(), Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 1498 of file crypto.c.
References D0_RIJNDAEL_NROUNDS, D0_RIJNDAEL_RKLENGTH, DHKEY_SIZE, i, qd0_rijndael_decrypt, qd0_rijndael_setup_decrypt, and src.
Referenced by Crypto_DecryptPacket().
Definition at line 383 of file crypto.c.
References n, and qd0_blind_id_util_sha256.
Referenced by VM_digest_hex().
|
static |
Definition at line 509 of file crypto.c.
Referenced by Crypto_ClientParsePacket().
|
static |
Definition at line 487 of file crypto.c.
Referenced by Crypto_BuildChallengeAppend(), and Crypto_ServerAppendToChallenge().
|
static |
Definition at line 488 of file crypto.c.
Referenced by Crypto_BuildChallengeAppend(), Crypto_ServerAppendToChallenge(), and Crypto_UnloadKeys().
cvar_t crypto_aeslevel = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "crypto_aeslevel", "1", "whether to support AES encryption in authenticated connections (0 = no, 1 = supported, 2 = requested, 3 = required)"} |
Definition at line 31 of file crypto.c.
Referenced by Crypto_BuildIdString(), Crypto_ClientParsePacket(), Crypto_GetInfoResponseDataString(), Crypto_Init_Commands(), and Crypto_ServerParsePacket_Internal().
cvar_t crypto_developer = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "crypto_developer", "0", "print extra info about crypto handshake"} |
Definition at line 30 of file crypto.c.
Referenced by Crypto_Init_Commands(), and NetConn_ServerParsePacket().
|
static |
Definition at line 42 of file crypto.c.
Referenced by Crypto_BuildIdString(), Crypto_GetInfoResponseDataString(), Crypto_KeyGen_f(), Crypto_LoadKeys(), Crypto_UnloadKeys(), and NetConn_BuildStatusResponse().
|
static |
Definition at line 43 of file crypto.c.
Referenced by Crypto_BuildIdString(), Crypto_GetInfoResponseDataString(), and Crypto_KeyGen_f().
int crypto_keyfp_recommended_length |
Definition at line 41 of file crypto.c.
Referenced by Crypto_HostKeys_f(), Crypto_LoadKeys(), NetConn_ConnectionEstablished(), NetConn_ServerParsePacket(), and SV_ConnectClient().
|
static |
Definition at line 36 of file crypto.c.
Referenced by Crypto_ServerParsePacket().
|
static |
Definition at line 37 of file crypto.c.
Referenced by Crypto_ServerParsePacket().
cvar_t crypto_servercpudebug = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "crypto_servercpudebug", "0", "print statistics about time usage by crypto"} |
Definition at line 35 of file crypto.c.
Referenced by Crypto_Init_Commands(), and Crypto_ServerParsePacket().
cvar_t crypto_servercpumaxtime = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "crypto_servercpumaxtime", "0.01", "maximum allowed crypto CPU time per frame (0 = no limit)"} |
Definition at line 34 of file crypto.c.
Referenced by Crypto_Init_Commands(), and Crypto_ServerParsePacket().
cvar_t crypto_servercpupercent = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "crypto_servercpupercent", "10", "allowed crypto CPU load in percent for server operation (0 = no limit, faster)"} |
Definition at line 33 of file crypto.c.
Referenced by Crypto_Init_Commands(), and Crypto_ServerParsePacket().
|
static |
Definition at line 589 of file crypto.c.
Referenced by Crypto_ClearHostKey(), Crypto_ClearHostKeys(), Crypto_HostKeys_f(), Crypto_InitHostKeys(), Crypto_RetrieveHostKey(), and Crypto_StoreHostKey().
|
static |
Definition at line 507 of file crypto.c.
Referenced by Crypto_ServerFindInstance(), and Crypto_Shutdown().
|
static |
Definition at line 1004 of file crypto.c.
Referenced by Crypto_d0_malloc(), Crypto_Init(), and Crypto_Shutdown().
|
static |
Definition at line 282 of file crypto.c.
Referenced by Crypto_Available(), Crypto_ClientParsePacket(), Crypto_CloseLibrary(), Crypto_HostKey_Clear_f(), Crypto_HostKeys_f(), Crypto_Init_Commands(), Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), Crypto_Keys_f(), Crypto_LoadKeys(), Crypto_OpenLibrary(), Crypto_RetrieveHostKey(), Crypto_ServerAppendToChallenge(), Crypto_ServerFindInstance(), Crypto_ServerParsePacket_Internal(), Crypto_Shutdown(), and Crypto_StoreHostKey().
|
static |
Definition at line 237 of file crypto.c.
Referenced by Crypto_OpenLibrary().
|
static |
Definition at line 351 of file crypto.c.
Referenced by Crypto_BuildIdString(), Crypto_ClientParsePacket(), Crypto_Init_Commands(), Crypto_Rijndael_CloseLibrary(), Crypto_Rijndael_OpenLibrary(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 341 of file crypto.c.
Referenced by Crypto_Rijndael_OpenLibrary().
|
static |
Definition at line 491 of file crypto.c.
Referenced by Crypto_KeyGen_f().
|
static |
Definition at line 490 of file crypto.c.
Referenced by Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), Crypto_LoadKeys(), and Crypto_UnloadKeys().
|
extern |
Definition at line 87 of file netconn.c.
Referenced by Crypto_ClientParsePacket(), NetConn_ClientParsePacket(), and NetConn_Init().
|
static |
Definition at line 482 of file crypto.c.
Referenced by Crypto_BuildChallengeAppend(), Crypto_BuildIdString(), Crypto_ClientParsePacket(), Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), Crypto_Keys_f(), Crypto_LoadKeys(), Crypto_RetrieveLocalKey(), Crypto_ServerParsePacket_Internal(), Crypto_SignData(), Crypto_SignDataDetached(), Crypto_StoreHostKey(), and Crypto_UnloadKeys().
|
static |
Definition at line 483 of file crypto.c.
Referenced by Crypto_BuildChallengeAppend(), Crypto_BuildIdString(), Crypto_ClientParsePacket(), Crypto_HostKeys_f(), Crypto_KeyGen_f(), Crypto_Keys_f(), Crypto_LoadKeys(), Crypto_RetrieveHostKey(), Crypto_RetrieveLocalKey(), Crypto_SavePubKeyTextFile(), Crypto_ServerParsePacket_Internal(), Crypto_StoreHostKey(), and Crypto_UnloadKeys().
|
static |
Definition at line 484 of file crypto.c.
Referenced by Crypto_BuildChallengeAppend(), Crypto_ClientParsePacket(), Crypto_KeyGen_f(), Crypto_Keys_f(), Crypto_LoadKeys(), Crypto_RetrieveLocalKey(), Crypto_SavePubKeyTextFile(), Crypto_ServerParsePacket_Internal(), Crypto_SignData(), Crypto_SignDataDetached(), and Crypto_UnloadKeys().
|
static |
Definition at line 485 of file crypto.c.
Referenced by Crypto_BuildIdString(), Crypto_ClientParsePacket(), Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), Crypto_Keys_f(), Crypto_LoadKeys(), Crypto_RetrieveLocalKey(), Crypto_SavePubKeyTextFile(), Crypto_ServerParsePacket_Internal(), and Crypto_UnloadKeys().
|
static |
Definition at line 486 of file crypto.c.
Referenced by Crypto_BuildIdString(), Crypto_ClientParsePacket(), Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), Crypto_Keys_f(), Crypto_LoadKeys(), Crypto_RetrieveLocalKey(), Crypto_SavePubKeyTextFile(), Crypto_ServerParsePacket_Internal(), and Crypto_UnloadKeys().
|
static |
Definition at line 223 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 224 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 222 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 225 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 201 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 226 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), Crypto_KeyGen_f(), Crypto_LoadKeys(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 208 of file crypto.c.
Referenced by Crypto_LoadKeys().
|
static |
Definition at line 215 of file crypto.c.
Referenced by Crypto_KeyGen_Finished().
|
static |
Definition at line 199 of file crypto.c.
Referenced by Crypto_LoadKeys(), Crypto_ReadPublicKey(), and Crypto_UnloadKeys().
|
static |
Definition at line 213 of file crypto.c.
Referenced by Crypto_KeyGen_f().
|
static |
Definition at line 212 of file crypto.c.
Referenced by Crypto_KeyGen_f().
|
static |
Definition at line 228 of file crypto.c.
Referenced by Crypto_Init().
|
static |
Definition at line 198 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), Crypto_ReadPublicKey(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 218 of file crypto.c.
Referenced by Crypto_AddPrivateKey().
|
static |
Definition at line 210 of file crypto.c.
Referenced by Crypto_ReadPublicKey().
|
static |
Definition at line 205 of file crypto.c.
Referenced by Crypto_ReadPublicKey().
|
static |
Definition at line 227 of file crypto.c.
Referenced by Crypto_ClientParsePacket(), and Crypto_ServerParsePacket_Internal().
|
static |
Definition at line 233 of file crypto.c.
Referenced by Crypto_Init().
|
static |
Definition at line 234 of file crypto.c.
Referenced by Crypto_Init().
Definition at line 229 of file crypto.c.
Referenced by Crypto_Shutdown().
|
static |
Definition at line 231 of file crypto.c.
Referenced by Crypto_SignData().
|
static |
Definition at line 232 of file crypto.c.
Referenced by Crypto_SignDataDetached().
|
static |
Definition at line 236 of file crypto.c.
Referenced by Crypto_KeyGen_f(), and Crypto_LoadKeys().
|
static |
Definition at line 235 of file crypto.c.
Referenced by Crypto_KeyGen_Finished(), and Crypto_LoadKeys().
|
static |
Definition at line 220 of file crypto.c.
Referenced by Crypto_KeyGen_f(), and Crypto_KeyGen_Finished().