blob: cece5e39ea0469020d13d9b9bc725485caa152a3 [file] [log] [blame]
Benoit Goby2cc19e42012-04-12 12:23:49 -07001/*
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
Dan Albert07c78812015-02-18 00:18:25 -080020#ifdef __cplusplus
21extern "C" {
22#endif
23
Dan Albert432ffe22015-02-18 18:22:45 -080024extern int auth_enabled;
25
Benoit Goby2cc19e42012-04-12 12:23:49 -070026void adb_auth_init(void);
Nick Kralevich6183c962014-11-13 15:17:29 -080027int adb_auth_keygen(const char* filename);
Benoit Goby2cc19e42012-04-12 12:23:49 -070028void adb_auth_verified(atransport *t);
29
Benoit Gobyd592d6c2013-01-15 19:59:14 -080030void send_auth_request(atransport *t);
Dan Albert056ad0e2015-02-18 17:47:33 -080031void send_auth_response(uint8_t *token, size_t token_size, atransport *t);
32void send_auth_publickey(atransport *t);
Benoit Gobyd592d6c2013-01-15 19:59:14 -080033
Benoit Goby2cc19e42012-04-12 12:23:49 -070034/* AUTH packets first argument */
35/* Request */
36#define ADB_AUTH_TOKEN 1
37/* Response */
38#define ADB_AUTH_SIGNATURE 2
39#define ADB_AUTH_RSAPUBLICKEY 3
40
41#if ADB_HOST
42
43int adb_auth_sign(void *key, void *token, size_t token_size, void *sig);
44void *adb_auth_nextkey(void *current);
45int adb_auth_get_userkey(unsigned char *data, size_t len);
46
47static inline int adb_auth_generate_token(void *token, size_t token_size) { return 0; }
48static inline int adb_auth_verify(void *token, void *sig, int siglen) { return 0; }
49static inline void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t) { }
Benoit Goby2cc19e42012-04-12 12:23:49 -070050
51#else // !ADB_HOST
52
53static inline int adb_auth_sign(void* key, void *token, size_t token_size, void *sig) { return 0; }
54static inline void *adb_auth_nextkey(void *current) { return NULL; }
55static inline int adb_auth_get_userkey(unsigned char *data, size_t len) { return 0; }
56
57int adb_auth_generate_token(void *token, size_t token_size);
58int adb_auth_verify(void *token, void *sig, int siglen);
59void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t);
Benoit Goby2cc19e42012-04-12 12:23:49 -070060
61#endif // ADB_HOST
62
Dan Albert07c78812015-02-18 00:18:25 -080063#ifdef __cplusplus
64}
65#endif
66
Benoit Goby2cc19e42012-04-12 12:23:49 -070067#endif // __ADB_AUTH_H