Clean up key handling in adb.
This includes the locking we need to be able to re-load the keys at runtime.
We should rename "adb_auth_client.cpp" to "adb_auth_adbd.cpp" or
"adbd_auth.cpp" in a later change.
Change-Id: I9e1d5b6b7d0497d6f6e5d9c4fb660118cdff05a8
Test: "adb devices" works against a non-AOSP device with $ADB_VENDOR_KEYS set, says "unauthorized" without.
Bug: http://b/29273531
diff --git a/adb/transport.h b/adb/transport.h
index 46d472b..d41c8bd 100644
--- a/adb/transport.h
+++ b/adb/transport.h
@@ -19,12 +19,15 @@
#include <sys/types.h>
+#include <deque>
#include <list>
#include <string>
#include <unordered_set>
#include "adb.h"
+#include <openssl/rsa.h>
+
typedef std::unordered_set<std::string> FeatureSet;
const FeatureSet& supported_features();
@@ -104,7 +107,8 @@
return type == kTransportLocal && local_port_for_emulator_ == -1;
}
- void* key = nullptr;
+ RSA* NextKey();
+
unsigned char token[TOKEN_SIZE] = {};
size_t failed_auth_attempts = 0;
@@ -156,6 +160,8 @@
// A list of adisconnect callbacks called when the transport is kicked.
std::list<adisconnect*> disconnects_;
+ std::deque<RSA*> keys_;
+
DISALLOW_COPY_AND_ASSIGN(atransport);
};