1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __ADB_AUTH_H 18 #define __ADB_AUTH_H 19 20 #include "adb.h" 21 22 #include <deque> 23 #include <memory> 24 25 #include <openssl/rsa.h> 26 27 /* AUTH packets first argument */ 28 /* Request */ 29 #define ADB_AUTH_TOKEN 1 30 /* Response */ 31 #define ADB_AUTH_SIGNATURE 2 32 #define ADB_AUTH_RSAPUBLICKEY 3 33 34 #if ADB_HOST 35 36 void adb_auth_init(); 37 38 int adb_auth_keygen(const char* filename); 39 int adb_auth_pubkey(const char* filename); 40 std::string adb_auth_get_userkey(); 41 std::deque<std::shared_ptr<RSA>> adb_auth_get_private_keys(); 42 43 void send_auth_response(const char* token, size_t token_size, atransport* t); 44 45 #else // !ADB_HOST 46 47 extern bool auth_required; 48 49 void adbd_auth_init(void); 50 void adbd_auth_verified(atransport *t); 51 52 void adbd_cloexec_auth_socket(); 53 bool adbd_auth_verify(const char* token, size_t token_size, const std::string& sig, 54 std::string* auth_key); 55 void adbd_auth_confirm_key(atransport* t); 56 void adbd_notify_framework_connected_key(atransport* t); 57 58 void send_auth_request(atransport *t); 59 60 #endif // ADB_HOST 61 62 #endif // __ADB_AUTH_H 63