+static qboolean Crypto_SavePubKeyTextFile(int i)
+{
+ qfile_t *f;
+ char vabuf[1024];
+
+ if(!pubkeys_havepriv[i])
+ return false;
+ f = FS_SysOpen(va(vabuf, sizeof(vabuf), "%skey_%d-public-fp%s.txt", *fs_userdir ? fs_userdir : fs_basedir, i, sessionid.string), "w", false);
+ if(!f)
+ return false;
+
+ // we ignore errors for this file, as it's not necessary to have
+ FS_Printf(f, "ID-Fingerprint: %s\n", pubkeys_priv_fp64[i]);
+ FS_Printf(f, "ID-Is-Signed: %s\n", pubkeys_havesig[i] ? "yes" : "no");
+ FS_Printf(f, "ID-Is-For-Key: %s\n", pubkeys_fp64[i]);
+ FS_Printf(f, "\n");
+ FS_Printf(f, "This is a PUBLIC ID file for DarkPlaces.\n");
+ FS_Printf(f, "You are free to share this file or its contents.\n");
+ FS_Printf(f, "\n");
+ FS_Printf(f, "This file will be automatically generated again if deleted.\n");
+ FS_Printf(f, "\n");
+ FS_Printf(f, "However, NEVER share the accompanying SECRET ID file called\n");
+ FS_Printf(f, "key_%d.d0si%s, as doing so would compromise security!\n", i, sessionid.string);
+ FS_Close(f);
+
+ return true;
+}
+
+static void Crypto_BuildIdString(void)
+{
+ int i;
+ char vabuf[1024];
+
+ crypto_idstring = NULL;
+ dpsnprintf(crypto_idstring_buf, sizeof(crypto_idstring_buf), "%d", d0_rijndael_dll ? crypto_aeslevel.integer : 0);
+ for (i = 0; i < MAX_PUBKEYS; ++i)
+ if (pubkeys[i])
+ strlcat(crypto_idstring_buf, va(vabuf, sizeof(vabuf), " %s@%s%s", pubkeys_priv_fp64[i], pubkeys_havesig[i] ? "" : "~", pubkeys_fp64[i]), sizeof(crypto_idstring_buf));
+ crypto_idstring = crypto_idstring_buf;
+}
+