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
36void adb_auth_init();
37
38int adb_auth_keygen(const char* filename);
39std::string adb_auth_get_userkey();
40std::deque<std::shared_ptr<RSA>> adb_auth_get_private_keys();
41
42void send_auth_response(const char* token, size_t token_size, atransport* t);
43
44#else // !ADB_HOST
45
46extern bool auth_required;
47
48void adbd_auth_init(void);
49void adbd_auth_verified(atransport *t);
50
51void adbd_cloexec_auth_socket();
52bool adbd_auth_verify(const char* token, size_t token_size, const char* sig, int sig_len);
53void adbd_auth_confirm_key(const char* data, size_t len, atransport* t);
54
55void send_auth_request(atransport *t);
56
57#endif // ADB_HOST
58
59#endif // __ADB_AUTH_H
60