]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
While I'm reworking this anyway: also write a file key_0-public-fp.txt
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 9 Dec 2011 12:53:18 +0000 (12:53 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 9 Dec 2011 13:06:23 +0000 (14:06 +0100)
containing the public key fingerprint for a key when loading/keygenning. Helps
with submitting your key to websites.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11606 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=3cd8dfafcad266bf52a3375a98c65e5c5a8d2792

crypto.c

index 40f905068af017b7941319d6d25b46126f3dfe98..cb7b339d195ec76b98bbc36428e66d281740ce55 100644 (file)
--- a/crypto.c
+++ b/crypto.c
@@ -817,9 +817,19 @@ void Crypto_LoadKeys(void)
                                                if(qd0_blind_id_fingerprint64_public_id(pubkeys[i], pubkeys_priv_fp64[i], &len2)) // keeps final NUL
                                                {
                                                        D0_BOOL status = 0;
+                                                       qfile_t *f;
 
                                                        Con_Printf("Loaded private ID key_%d.d0si%s for key_%d.d0pk (public key fingerprint: %s)\n", i, sessionid.string, i, pubkeys_priv_fp64[i]);
 
+                                                       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)
+                                                       {
+                                                               // we ignore errors for this file, as it's not necessary to have
+                                                               FS_Write(f, pubkeys_priv_fp64[i], FP64_SIZE);
+                                                               FS_Write(f, "\n", 1);
+                                                               FS_Close(f);
+                                                       }
+
                                                        // verify the key we just loaded (just in case)
                                                        if(qd0_blind_id_verify_private_id(pubkeys[i]) && qd0_blind_id_verify_public_id(pubkeys[i], &status))
                                                        {
@@ -1243,6 +1253,15 @@ static void Crypto_KeyGen_f(void)
                FS_Write(f, buf2, buf2size);
                FS_Close(f);
 
+               f = FS_SysOpen(va(vabuf, sizeof(vabuf), "%skey_%d-public-fp%s.txt", *fs_userdir ? fs_userdir : fs_basedir, keygen_i, sessionid.string), "w", false);
+               if(f)
+               {
+                       // we ignore errors for this file, as it's not necessary to have
+                       FS_Write(f, pubkeys_priv_fp64[keygen_i], FP64_SIZE);
+                       FS_Write(f, "\n", 1);
+                       FS_Close(f);
+               }
+
                Con_Printf("Saved unsigned key to key_%d.d0si%s\n", keygen_i, sessionid.string);
        }
        p[0] = buf;