Android-cuttlefish cvd tool
adb_auth.h
Go to the documentation of this file.
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#include <openssl/stack.h>
27
28/* AUTH packets first argument */
29/* Request */
30#define ADB_AUTH_TOKEN 1
31/* Response */
32#define ADB_AUTH_SIGNATURE 2
33#define ADB_AUTH_RSAPUBLICKEY 3
34
35#if ADB_HOST
36
37void adb_auth_init();
38
39int adb_auth_keygen(const char* filename);
40int adb_auth_pubkey(const char* filename);
41std::string adb_auth_get_userkey();
42bssl::UniquePtr<EVP_PKEY> adb_auth_get_user_privkey();
43std::deque<std::shared_ptr<RSA>> adb_auth_get_private_keys();
44
45void send_auth_response(const char* token, size_t token_size, atransport* t);
46
47int adb_tls_set_certificate(SSL* ssl);
49
50// Return the location where the host stores its keys
51std::string adb_auth_get_userkey_path();
52
53#else // !ADB_HOST
54
55extern bool auth_required;
56extern bool socket_access_allowed;
57
60
62bool adbd_auth_verify(const char* token, size_t token_size, const std::string& sig,
63 std::string* auth_key);
66
68
70int adbd_tls_verify_cert(X509_STORE_CTX* ctx, std::string* auth_key);
71bssl::UniquePtr<STACK_OF(X509_NAME)> adbd_tls_client_ca_list();
72
73#endif // ADB_HOST
74
75#endif // __ADB_AUTH_H
void adbd_auth_tls_handshake(atransport *t)
bool socket_access_allowed
void adbd_cloexec_auth_socket()
void adbd_auth_verified(atransport *t)
bssl::UniquePtr< STACK_OF(X509_NAME)> adbd_tls_client_ca_list()
bool adbd_auth_verify(const char *token, size_t token_size, const std::string &sig, std::string *auth_key)
int adbd_tls_verify_cert(X509_STORE_CTX *ctx, std::string *auth_key)
void adbd_auth_confirm_key(atransport *t)
void adbd_notify_framework_connected_key(atransport *t)
void send_auth_request(atransport *t)
bool auth_required
void adbd_auth_init()
std::string adb_auth_get_userkey()
Definition: auth.cpp:313
int adb_tls_set_certificate(SSL *ssl)
Definition: auth.cpp:514
void send_auth_response(const char *token, size_t token_size, atransport *t)
Definition: auth.cpp:460
int adb_auth_keygen(const char *filename)
Definition: auth.cpp:327
std::deque< std::shared_ptr< RSA > > adb_auth_get_private_keys()
Definition: auth.cpp:245
bssl::UniquePtr< EVP_PKEY > adb_auth_get_user_privkey()
Definition: auth.cpp:291
int adb_auth_pubkey(const char *filename)
Definition: auth.cpp:331
void adb_auth_init()
Definition: auth.cpp:417
void adb_auth_tls_handshake(atransport *t)
Definition: auth.cpp:487
std::string adb_auth_get_userkey_path()
Definition: auth.cpp:205
Definition: transport.h:261