mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Final fixup for profile-level keys and passing to player_t
This commit is contained in:
parent
4ffae5d862
commit
66c6ba125d
8 changed files with 63 additions and 12 deletions
|
|
@ -2818,6 +2818,8 @@ static void Command_Nodes(void)
|
||||||
CONS_Printf(" - %s", address);
|
CONS_Printf(" - %s", address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONS_Printf(" [RRID-%s] ", GetPrettyRRID(players[i].public_key, true));
|
||||||
|
|
||||||
if (IsPlayerAdmin(i))
|
if (IsPlayerAdmin(i))
|
||||||
CONS_Printf(M_GetText(" (verified admin)"));
|
CONS_Printf(M_GetText(" (verified admin)"));
|
||||||
|
|
||||||
|
|
@ -3714,7 +3716,9 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
|
||||||
|
|
||||||
players[newplayernum].splitscreenindex = splitscreenplayer;
|
players[newplayernum].splitscreenindex = splitscreenplayer;
|
||||||
players[newplayernum].bot = false;
|
players[newplayernum].bot = false;
|
||||||
|
CONS_Printf("Adding player from node %d with ID %s\n", node, GetPrettyRRID(lastReceivedKey[node][splitscreenplayer], true));
|
||||||
memcpy(players[newplayernum].public_key, lastReceivedKey[node][splitscreenplayer], sizeof(players[newplayernum].public_key));
|
memcpy(players[newplayernum].public_key, lastReceivedKey[node][splitscreenplayer], sizeof(players[newplayernum].public_key));
|
||||||
|
CONS_Printf("Node %d now has ID %s\n", node, GetPrettyRRID(players[newplayernum].public_key, true));
|
||||||
|
|
||||||
playerconsole[newplayernum] = console;
|
playerconsole[newplayernum] = console;
|
||||||
splitscreen_original_party_size[console] =
|
splitscreen_original_party_size[console] =
|
||||||
|
|
@ -4186,17 +4190,26 @@ static void HandleConnect(SINT8 node)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node == 0) // Server
|
||||||
|
{
|
||||||
|
memcpy(lastReceivedKey[node][i], PR_GetLocalPlayerProfile(i)->public_key, sizeof(lastReceivedKey[node][i]));
|
||||||
|
CONS_Printf("We're SERVER! Setting lastReceivedKey on node %d to %s\n", node, GetPrettyRRID(lastReceivedKey[node][i], true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CONS_Printf("We're a client. Doing sigcheck for node %d, ID %s\n", node, GetPrettyRRID(lastReceivedKey[node][i], true));
|
||||||
if (memcmp(lastReceivedKey[node], allZero, 32)) // We're a GUEST and the server throws out our keys anyway.
|
if (memcmp(lastReceivedKey[node], allZero, 32)) // We're a GUEST and the server throws out our keys anyway.
|
||||||
sigcheck = 0; // Always succeeds. Yes, this is a success response. C R Y P T O
|
sigcheck = 0; // Always succeeds. Yes, this is a success response. C R Y P T O
|
||||||
else
|
else
|
||||||
sigcheck = crypto_eddsa_check(netbuffer->u.clientcfg.challengeResponse[i], lastReceivedKey[node][i], lastSentChallenge[node][i], 32);
|
sigcheck = crypto_eddsa_check(netbuffer->u.clientcfg.challengeResponse[i], lastReceivedKey[node][i], lastSentChallenge[node][i], 32);
|
||||||
|
|
||||||
if (netgame && node != 0 && sigcheck != 0)
|
if (netgame && sigcheck != 0)
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, M_GetText("Signature verification failed."));
|
SV_SendRefuse(node, M_GetText("Signature verification failed."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(availabilitiesbuffer, netbuffer->u.clientcfg.availabilities, sizeof(availabilitiesbuffer));
|
memcpy(availabilitiesbuffer, netbuffer->u.clientcfg.availabilities, sizeof(availabilitiesbuffer));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,6 @@ extern const char *pandf; //Alam: how to path?
|
||||||
extern char srb2path[256]; //Alam: SRB2's Home
|
extern char srb2path[256]; //Alam: SRB2's Home
|
||||||
extern char addonsdir[MAX_WADPATH]; // Where addons are stored
|
extern char addonsdir[MAX_WADPATH]; // Where addons are stored
|
||||||
|
|
||||||
extern uint8_t public_key[32];
|
|
||||||
extern uint8_t secret_key[64];
|
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1320,6 +1320,8 @@ void PT_ClientKey(INT32 node)
|
||||||
|
|
||||||
memcpy(lastReceivedKey[node], packet->key, sizeof(lastReceivedKey[node]));
|
memcpy(lastReceivedKey[node], packet->key, sizeof(lastReceivedKey[node]));
|
||||||
|
|
||||||
|
CONS_Printf("Got keys from node %d, %s / %s / %s / %s\n", node, GetPrettyRRID(lastReceivedKey[node][0], true), GetPrettyRRID(lastReceivedKey[node][1], true), GetPrettyRRID(lastReceivedKey[node][2], true), GetPrettyRRID(lastReceivedKey[node][3], true));
|
||||||
|
|
||||||
netbuffer->packettype = PT_SERVERCHALLENGE;
|
netbuffer->packettype = PT_SERVERCHALLENGE;
|
||||||
|
|
||||||
csprng(lastSentChallenge[node], sizeof(serverchallenge_pak));
|
csprng(lastSentChallenge[node], sizeof(serverchallenge_pak));
|
||||||
|
|
|
||||||
|
|
@ -723,6 +723,9 @@ struct player_t
|
||||||
roundconditions_t roundconditions;
|
roundconditions_t roundconditions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// WARNING FOR ANYONE ABOUT TO ADD SOMETHING TO THE PLAYER STRUCT, G_PlayerReborn WANTS YOU TO SUFFER
|
||||||
|
// If data on player_t needs to persist between rounds or during the join process, modify G_PlayerReborn to preserve it.
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2436,6 +2436,8 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
|
||||||
|
|
||||||
SINT8 xtralife;
|
SINT8 xtralife;
|
||||||
|
|
||||||
|
uint8_t public_key[32];
|
||||||
|
|
||||||
// SRB2kart
|
// SRB2kart
|
||||||
itemroulette_t itemRoulette;
|
itemroulette_t itemRoulette;
|
||||||
respawnvars_t respawn;
|
respawnvars_t respawn;
|
||||||
|
|
@ -2509,6 +2511,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
|
||||||
// SRB2kart
|
// SRB2kart
|
||||||
memcpy(&itemRoulette, &players[player].itemRoulette, sizeof (itemRoulette));
|
memcpy(&itemRoulette, &players[player].itemRoulette, sizeof (itemRoulette));
|
||||||
memcpy(&respawn, &players[player].respawn, sizeof (respawn));
|
memcpy(&respawn, &players[player].respawn, sizeof (respawn));
|
||||||
|
memcpy(&public_key, &players[player].public_key, sizeof(public_key));
|
||||||
|
|
||||||
if (betweenmaps || leveltime < introtime)
|
if (betweenmaps || leveltime < introtime)
|
||||||
{
|
{
|
||||||
|
|
@ -2678,6 +2681,8 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
|
||||||
memcpy(&p->itemRoulette, &itemRoulette, sizeof (p->itemRoulette));
|
memcpy(&p->itemRoulette, &itemRoulette, sizeof (p->itemRoulette));
|
||||||
memcpy(&p->respawn, &respawn, sizeof (p->respawn));
|
memcpy(&p->respawn, &respawn, sizeof (p->respawn));
|
||||||
|
|
||||||
|
memcpy(&p->public_key, &public_key, sizeof(p->public_key));
|
||||||
|
|
||||||
if (saveroundconditions)
|
if (saveroundconditions)
|
||||||
memcpy(&p->roundconditions, &roundconditions, sizeof (p->roundconditions));
|
memcpy(&p->roundconditions, &roundconditions, sizeof (p->roundconditions));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1768,7 +1768,8 @@ static void M_DrawProfileCard(INT32 x, INT32 y, boolean greyedout, profile_t *p)
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
V_DrawProfileNum(x + 37 + 10, y + 131, 0, PR_GetProfileNum(p));
|
V_DrawProfileNum(x + 37 + 10, y + 131, 0, PR_GetProfileNum(p));
|
||||||
V_DrawCenteredThinString(x, y + 151, V_GRAYMAP|V_6WIDTHSPACE, p->playername);
|
V_DrawCenteredThinString(x, y + 141, V_GRAYMAP|V_6WIDTHSPACE, p->playername);
|
||||||
|
V_DrawCenteredThinString(x, y + 151, V_GRAYMAP|V_6WIDTHSPACE, GetPrettyRRID(p->public_key, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ profile_t* PR_MakeProfile(
|
||||||
|
|
||||||
new->version = PROFILEVER;
|
new->version = PROFILEVER;
|
||||||
|
|
||||||
|
uint8_t secret_key[64];
|
||||||
|
uint8_t public_key[32];
|
||||||
|
|
||||||
memset(new->secret_key, 0, sizeof(secret_key));
|
memset(new->secret_key, 0, sizeof(secret_key));
|
||||||
memset(new->public_key, 0, sizeof(public_key));
|
memset(new->public_key, 0, sizeof(public_key));
|
||||||
|
|
||||||
|
|
@ -573,3 +576,28 @@ profile_t *PR_GetLocalPlayerProfile(INT32 player)
|
||||||
return NULL;
|
return NULL;
|
||||||
return PR_GetProfile(cv_lastprofile[player].value);
|
return PR_GetProfile(cv_lastprofile[player].value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *GetPrettyRRID(const unsigned char *bin, boolean brief)
|
||||||
|
{
|
||||||
|
char *out;
|
||||||
|
size_t i;
|
||||||
|
size_t len = 32;
|
||||||
|
|
||||||
|
if (brief)
|
||||||
|
len = 8;
|
||||||
|
|
||||||
|
if (bin == NULL || len == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
out = malloc(len*2 + 1);
|
||||||
|
|
||||||
|
for (i=0; i<len; i++)
|
||||||
|
{
|
||||||
|
out[i*2] = "0123456789ABCDEF"[bin[i] >> 4];
|
||||||
|
out[i*2+1] = "0123456789ABCDEF"[bin[i] & 0x0F];
|
||||||
|
}
|
||||||
|
|
||||||
|
out[len*2] = '\0';
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
@ -161,6 +161,8 @@ profile_t *PR_GetPlayerProfile(player_t *player);
|
||||||
|
|
||||||
profile_t *PR_GetLocalPlayerProfile(INT32 player);
|
profile_t *PR_GetLocalPlayerProfile(INT32 player);
|
||||||
|
|
||||||
|
char *GetPrettyRRID(const unsigned char *bin, boolean brief);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue