adb: Create private key with 0600 mode

Changed key name to force generating new pairs.

Bug: 7092477
Change-Id: I680cb9dd1896ae52b2b29d63533f966e033d823f
diff --git a/adb/adb_auth_host.c b/adb/adb_auth_host.c
index 99dcfcb..9039d42 100644
--- a/adb/adb_auth_host.c
+++ b/adb/adb_auth_host.c
@@ -48,7 +48,7 @@
 #define TRACE_TAG TRACE_AUTH
 
 #define ANDROID_PATH   ".android"
-#define ADB_KEY_FILE   "adb_key"
+#define ADB_KEY_FILE   "adbkey"
 
 
 struct adb_private_key {
@@ -176,6 +176,7 @@
     EVP_PKEY* pkey = EVP_PKEY_new();
     BIGNUM* exponent = BN_new();
     RSA* rsa = RSA_new();
+    mode_t old_mask;
     FILE *f = NULL;
     int ret = 0;
 
@@ -190,12 +191,17 @@
     RSA_generate_key_ex(rsa, 2048, exponent, NULL);
     EVP_PKEY_set1_RSA(pkey, rsa);
 
+    old_mask = umask(077);
+
     f = fopen(file, "w");
     if (!f) {
         D("Failed to open '%s'\n", file);
+        umask(old_mask);
         goto out;
     }
 
+    umask(old_mask);
+
     if (!PEM_write_PrivateKey(f, pkey, NULL, NULL, 0, NULL, NULL)) {
         D("Failed to write key\n");
         goto out;