mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
RRID: generate keys for old profiles
Bump PROFILEVER to 3
This commit is contained in:
parent
3c561c564e
commit
4413939e85
2 changed files with 25 additions and 12 deletions
|
|
@ -30,6 +30,13 @@ INT32 PR_GetNumProfiles(void)
|
||||||
return numprofiles;
|
return numprofiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PR_GenerateProfileKeys(profile_t *new)
|
||||||
|
{
|
||||||
|
static uint8_t seed[32];
|
||||||
|
csprng(seed, 32);
|
||||||
|
crypto_eddsa_key_pair(new->secret_key, new->public_key, seed);
|
||||||
|
}
|
||||||
|
|
||||||
profile_t* PR_MakeProfile(
|
profile_t* PR_MakeProfile(
|
||||||
const char *prname,
|
const char *prname,
|
||||||
const char *pname,
|
const char *pname,
|
||||||
|
|
@ -43,17 +50,12 @@ profile_t* PR_MakeProfile(
|
||||||
|
|
||||||
new->version = PROFILEVER;
|
new->version = PROFILEVER;
|
||||||
|
|
||||||
uint8_t secret_key[64];
|
memset(new->secret_key, 0, sizeof(new->secret_key));
|
||||||
uint8_t public_key[32];
|
memset(new->public_key, 0, sizeof(new->public_key));
|
||||||
|
|
||||||
memset(new->secret_key, 0, sizeof(secret_key));
|
|
||||||
memset(new->public_key, 0, sizeof(public_key));
|
|
||||||
|
|
||||||
if (!guest)
|
if (!guest)
|
||||||
{
|
{
|
||||||
static uint8_t seed[32];
|
PR_GenerateProfileKeys(new);
|
||||||
csprng(seed, 32);
|
|
||||||
crypto_eddsa_key_pair(new->secret_key, new->public_key, seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(new->profilename, prname);
|
strcpy(new->profilename, prname);
|
||||||
|
|
@ -348,8 +350,19 @@ void PR_LoadProfiles(void)
|
||||||
|
|
||||||
// Names and keys, all the identity stuff up front
|
// Names and keys, all the identity stuff up front
|
||||||
READSTRINGN(save.p, profilesList[i]->profilename, PROFILENAMELEN);
|
READSTRINGN(save.p, profilesList[i]->profilename, PROFILENAMELEN);
|
||||||
READMEM(save.p, profilesList[i]->public_key, sizeof(((profile_t *)0)->public_key));
|
|
||||||
READMEM(save.p, profilesList[i]->secret_key, sizeof(((profile_t *)0)->secret_key));
|
// Profile update 2-->3: Add profile keys.
|
||||||
|
if (version < 3)
|
||||||
|
{
|
||||||
|
// Generate missing keys.
|
||||||
|
PR_GenerateProfileKeys(profilesList[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
READMEM(save.p, profilesList[i]->public_key, sizeof(((profile_t *)0)->public_key));
|
||||||
|
READMEM(save.p, profilesList[i]->secret_key, sizeof(((profile_t *)0)->secret_key));
|
||||||
|
}
|
||||||
|
|
||||||
READSTRINGN(save.p, profilesList[i]->playername, MAXPLAYERNAME);
|
READSTRINGN(save.p, profilesList[i]->playername, MAXPLAYERNAME);
|
||||||
|
|
||||||
// Character and colour.
|
// Character and colour.
|
||||||
|
|
@ -605,4 +618,4 @@ char *GetPrettyRRID(const unsigned char *bin, boolean brief)
|
||||||
out[len*2] = '\0';
|
out[len*2] = '\0';
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ extern "C" {
|
||||||
#define SKINNAMESIZE 16
|
#define SKINNAMESIZE 16
|
||||||
|
|
||||||
#define PROFILENAMELEN 6
|
#define PROFILENAMELEN 6
|
||||||
#define PROFILEVER 2
|
#define PROFILEVER 3
|
||||||
#define MAXPROFILES 16
|
#define MAXPROFILES 16
|
||||||
#define PROFILESFILE "ringprofiles.prf"
|
#define PROFILESFILE "ringprofiles.prf"
|
||||||
#define PROFILE_GUEST 0
|
#define PROFILE_GUEST 0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue