Rename our Public and private key globals
This commit is contained in:
parent
e79ba678c4
commit
a90f2ea2d3
4 changed files with 20 additions and 20 deletions
|
|
@ -1019,8 +1019,8 @@ static boolean CL_SendJoin(void)
|
|||
uint8_t signature[SIGNATURELENGTH];
|
||||
|
||||
// If our keys are garbage (corrupted profile?), fail here instead of when the server boots us, so the player knows what's going on.
|
||||
crypto_eddsa_sign(signature, secret_key[i], awaitingChallenge, sizeof(awaitingChallenge));
|
||||
if (crypto_eddsa_check(signature, public_key[i], awaitingChallenge, sizeof(awaitingChallenge)) != 0)
|
||||
crypto_eddsa_sign(signature, g_secret_key[i], awaitingChallenge, sizeof(awaitingChallenge));
|
||||
if (crypto_eddsa_check(signature, g_public_key[i], awaitingChallenge, sizeof(awaitingChallenge)) != 0)
|
||||
I_Error("Couldn't self-verify key associated with player %d.\nKey may be corrupted.\n", i); // I guess this is the most reasonable way to catch a malformed key.
|
||||
|
||||
#ifdef DEVELOP
|
||||
|
|
@ -1050,7 +1050,7 @@ static boolean CL_SendKey(void)
|
|||
memset(netbuffer->u.clientkey.key, 0, sizeof(((clientkey_pak *)0)->key));
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
memcpy(netbuffer->u.clientkey.key[i], public_key[i], 32);
|
||||
memcpy(netbuffer->u.clientkey.key[i], g_public_key[i], 32);
|
||||
}
|
||||
return HSendPacket(servernode, false, 0, sizeof (clientkey_pak) );
|
||||
}
|
||||
|
|
@ -4479,8 +4479,8 @@ boolean SV_SpawnServer(void)
|
|||
UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities();
|
||||
SINT8 node = 0;
|
||||
for (; node < MAXNETNODES; node++)
|
||||
result |= SV_AddWaitingPlayers(node, availabilitiesbuffer, cv_playername[0].zstring, public_key[0], cv_playername[1].zstring, public_key[1],
|
||||
cv_playername[2].zstring, public_key[2], cv_playername[3].zstring, public_key[3]);
|
||||
result |= SV_AddWaitingPlayers(node, availabilitiesbuffer, cv_playername[0].zstring, g_public_key[0], cv_playername[1].zstring, g_public_key[1],
|
||||
cv_playername[2].zstring, g_public_key[2], cv_playername[3].zstring, g_public_key[3]);
|
||||
|
||||
}
|
||||
return result;
|
||||
|
|
@ -4702,7 +4702,7 @@ static void HandleConnect(SINT8 node)
|
|||
|
||||
if (node == 0) // Hey, that's us. We're always allowed to do what we want.
|
||||
{
|
||||
memcpy(lastReceivedKey[node][i], public_key[i], sizeof(lastReceivedKey[node][i]));
|
||||
memcpy(lastReceivedKey[node][i], g_public_key[i], sizeof(lastReceivedKey[node][i]));
|
||||
}
|
||||
else // Remote player, gotta check their signature.
|
||||
{
|
||||
|
|
@ -6009,8 +6009,8 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
{
|
||||
uint8_t signature[SIGNATURELENGTH];
|
||||
|
||||
crypto_eddsa_sign(signature, secret_key[challengeplayers], lastChallengeAll, sizeof(lastChallengeAll));
|
||||
if (crypto_eddsa_check(signature, public_key[challengeplayers], lastChallengeAll, sizeof(lastChallengeAll)) != 0)
|
||||
crypto_eddsa_sign(signature, g_secret_key[challengeplayers], lastChallengeAll, sizeof(lastChallengeAll));
|
||||
if (crypto_eddsa_check(signature, g_public_key[challengeplayers], lastChallengeAll, sizeof(lastChallengeAll)) != 0)
|
||||
I_Error("Couldn't self-verify key associated with player %d.\nKey may be corrupted.", challengeplayers);
|
||||
|
||||
#ifdef DEVELOP
|
||||
|
|
|
|||
|
|
@ -183,8 +183,8 @@ INT32 eventhead, eventtail;
|
|||
boolean dedicated = false;
|
||||
|
||||
// For identity negotiation with netgame servers
|
||||
uint8_t public_key[MAXSPLITSCREENPLAYERS][PUBKEYLENGTH];
|
||||
uint8_t secret_key[MAXSPLITSCREENPLAYERS][PRIVKEYLENGTH];
|
||||
uint8_t g_public_key[MAXSPLITSCREENPLAYERS][PUBKEYLENGTH];
|
||||
uint8_t g_secret_key[MAXSPLITSCREENPLAYERS][PRIVKEYLENGTH];
|
||||
|
||||
boolean loaded_config = false;
|
||||
|
||||
|
|
@ -1884,10 +1884,10 @@ void D_SRB2Main(void)
|
|||
{
|
||||
static uint8_t seed[32];
|
||||
csprng(seed, 32);
|
||||
crypto_eddsa_key_pair(secret_key[snum], public_key[snum], seed);
|
||||
crypto_eddsa_key_pair(g_secret_key[snum], g_public_key[snum], seed);
|
||||
|
||||
int sk_size = sizeof(secret_key[snum]);
|
||||
int pk_size = sizeof(public_key[snum]);
|
||||
int sk_size = sizeof(g_secret_key[snum]);
|
||||
int pk_size = sizeof(g_public_key[snum]);
|
||||
int totalsize = sk_size + pk_size;
|
||||
|
||||
if (FIL_ReadFileOK(keyfile[snum]))
|
||||
|
|
@ -1896,14 +1896,14 @@ void D_SRB2Main(void)
|
|||
UINT16 lengthRead = FIL_ReadFile(keyfile[snum], &readbuffer);
|
||||
if (readbuffer == NULL || lengthRead != totalsize)
|
||||
I_Error("Malformed keyfile %d", snum);
|
||||
memcpy(secret_key[snum], readbuffer, sk_size);
|
||||
memcpy(public_key[snum], readbuffer + sk_size, pk_size);
|
||||
memcpy(g_secret_key[snum], readbuffer, sk_size);
|
||||
memcpy(g_public_key[snum], readbuffer + sk_size, pk_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t *keybuffer = (uint8_t *)malloc(totalsize);
|
||||
memcpy(keybuffer, secret_key[snum], sk_size);
|
||||
memcpy(keybuffer + sk_size, public_key[snum], pk_size);
|
||||
memcpy(keybuffer, g_secret_key[snum], sk_size);
|
||||
memcpy(keybuffer + sk_size, g_public_key[snum], pk_size);
|
||||
if (!FIL_WriteFile(keyfile[snum], keybuffer, totalsize))
|
||||
I_Error("Couldn't open keyfile %d", snum);
|
||||
free(keybuffer);
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ extern char srb2path[256]; //Alam: SRB2's Home
|
|||
|
||||
const char *D_GetFancyBranchName(void);
|
||||
|
||||
extern uint8_t public_key[MAXSPLITSCREENPLAYERS][PUBKEYLENGTH];
|
||||
extern uint8_t secret_key[MAXSPLITSCREENPLAYERS][PRIVKEYLENGTH];
|
||||
extern uint8_t g_public_key[MAXSPLITSCREENPLAYERS][PUBKEYLENGTH];
|
||||
extern uint8_t g_secret_key[MAXSPLITSCREENPLAYERS][PRIVKEYLENGTH];
|
||||
|
||||
// the infinite loop of D_SRB2Loop() called from win_main for windows version
|
||||
void D_SRB2Loop(void) FUNCNORETURN;
|
||||
|
|
|
|||
|
|
@ -910,7 +910,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
|
|||
{
|
||||
const void* message = &netbuffer->u;
|
||||
//CONS_Printf("Signing packet type %d of length %d\n", netbuffer->packettype, packetlength);
|
||||
crypto_eddsa_sign(netbuffer->signature[i], secret_key[i], message, packetlength);
|
||||
crypto_eddsa_sign(netbuffer->signature[i], g_secret_key[i], message, packetlength);
|
||||
}
|
||||
|
||||
#ifdef DEVELOP
|
||||
|
|
|
|||
Loading…
Reference in a new issue