Rename our Public and private key globals

This commit is contained in:
NepDisk 2026-03-29 16:50:31 -04:00
parent e79ba678c4
commit a90f2ea2d3
4 changed files with 20 additions and 20 deletions

View file

@ -1019,8 +1019,8 @@ static boolean CL_SendJoin(void)
uint8_t signature[SIGNATURELENGTH]; 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. // 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)); crypto_eddsa_sign(signature, g_secret_key[i], awaitingChallenge, sizeof(awaitingChallenge));
if (crypto_eddsa_check(signature, public_key[i], awaitingChallenge, sizeof(awaitingChallenge)) != 0) 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. 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 #ifdef DEVELOP
@ -1050,7 +1050,7 @@ static boolean CL_SendKey(void)
memset(netbuffer->u.clientkey.key, 0, sizeof(((clientkey_pak *)0)->key)); memset(netbuffer->u.clientkey.key, 0, sizeof(((clientkey_pak *)0)->key));
for (i = 0; i <= splitscreen; i++) 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) ); return HSendPacket(servernode, false, 0, sizeof (clientkey_pak) );
} }
@ -4479,8 +4479,8 @@ boolean SV_SpawnServer(void)
UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities(); UINT8 *availabilitiesbuffer = R_GetSkinAvailabilities();
SINT8 node = 0; SINT8 node = 0;
for (; node < MAXNETNODES; node++) for (; node < MAXNETNODES; node++)
result |= SV_AddWaitingPlayers(node, availabilitiesbuffer, cv_playername[0].zstring, public_key[0], cv_playername[1].zstring, public_key[1], 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, public_key[2], cv_playername[3].zstring, public_key[3]); cv_playername[2].zstring, g_public_key[2], cv_playername[3].zstring, g_public_key[3]);
} }
return result; 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. 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. else // Remote player, gotta check their signature.
{ {
@ -6009,8 +6009,8 @@ static void HandlePacketFromPlayer(SINT8 node)
{ {
uint8_t signature[SIGNATURELENGTH]; uint8_t signature[SIGNATURELENGTH];
crypto_eddsa_sign(signature, secret_key[challengeplayers], lastChallengeAll, sizeof(lastChallengeAll)); crypto_eddsa_sign(signature, g_secret_key[challengeplayers], lastChallengeAll, sizeof(lastChallengeAll));
if (crypto_eddsa_check(signature, public_key[challengeplayers], lastChallengeAll, sizeof(lastChallengeAll)) != 0) 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); I_Error("Couldn't self-verify key associated with player %d.\nKey may be corrupted.", challengeplayers);
#ifdef DEVELOP #ifdef DEVELOP

View file

@ -183,8 +183,8 @@ INT32 eventhead, eventtail;
boolean dedicated = false; boolean dedicated = false;
// For identity negotiation with netgame servers // For identity negotiation with netgame servers
uint8_t public_key[MAXSPLITSCREENPLAYERS][PUBKEYLENGTH]; uint8_t g_public_key[MAXSPLITSCREENPLAYERS][PUBKEYLENGTH];
uint8_t secret_key[MAXSPLITSCREENPLAYERS][PRIVKEYLENGTH]; uint8_t g_secret_key[MAXSPLITSCREENPLAYERS][PRIVKEYLENGTH];
boolean loaded_config = false; boolean loaded_config = false;
@ -1884,10 +1884,10 @@ void D_SRB2Main(void)
{ {
static uint8_t seed[32]; static uint8_t seed[32];
csprng(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 sk_size = sizeof(g_secret_key[snum]);
int pk_size = sizeof(public_key[snum]); int pk_size = sizeof(g_public_key[snum]);
int totalsize = sk_size + pk_size; int totalsize = sk_size + pk_size;
if (FIL_ReadFileOK(keyfile[snum])) if (FIL_ReadFileOK(keyfile[snum]))
@ -1896,14 +1896,14 @@ void D_SRB2Main(void)
UINT16 lengthRead = FIL_ReadFile(keyfile[snum], &readbuffer); UINT16 lengthRead = FIL_ReadFile(keyfile[snum], &readbuffer);
if (readbuffer == NULL || lengthRead != totalsize) if (readbuffer == NULL || lengthRead != totalsize)
I_Error("Malformed keyfile %d", snum); I_Error("Malformed keyfile %d", snum);
memcpy(secret_key[snum], readbuffer, sk_size); memcpy(g_secret_key[snum], readbuffer, sk_size);
memcpy(public_key[snum], readbuffer + sk_size, pk_size); memcpy(g_public_key[snum], readbuffer + sk_size, pk_size);
} }
else else
{ {
uint8_t *keybuffer = (uint8_t *)malloc(totalsize); uint8_t *keybuffer = (uint8_t *)malloc(totalsize);
memcpy(keybuffer, secret_key[snum], sk_size); memcpy(keybuffer, g_secret_key[snum], sk_size);
memcpy(keybuffer + sk_size, public_key[snum], pk_size); memcpy(keybuffer + sk_size, g_public_key[snum], pk_size);
if (!FIL_WriteFile(keyfile[snum], keybuffer, totalsize)) if (!FIL_WriteFile(keyfile[snum], keybuffer, totalsize))
I_Error("Couldn't open keyfile %d", snum); I_Error("Couldn't open keyfile %d", snum);
free(keybuffer); free(keybuffer);

View file

@ -64,8 +64,8 @@ extern char srb2path[256]; //Alam: SRB2's Home
const char *D_GetFancyBranchName(void); const char *D_GetFancyBranchName(void);
extern uint8_t public_key[MAXSPLITSCREENPLAYERS][PUBKEYLENGTH]; extern uint8_t g_public_key[MAXSPLITSCREENPLAYERS][PUBKEYLENGTH];
extern uint8_t secret_key[MAXSPLITSCREENPLAYERS][PRIVKEYLENGTH]; extern uint8_t g_secret_key[MAXSPLITSCREENPLAYERS][PRIVKEYLENGTH];
// the infinite loop of D_SRB2Loop() called from win_main for windows version // the infinite loop of D_SRB2Loop() called from win_main for windows version
void D_SRB2Loop(void) FUNCNORETURN; void D_SRB2Loop(void) FUNCNORETURN;

View file

@ -910,7 +910,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
{ {
const void* message = &netbuffer->u; const void* message = &netbuffer->u;
//CONS_Printf("Signing packet type %d of length %d\n", netbuffer->packettype, packetlength); //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 #ifdef DEVELOP