blob: 54dd537316e2b60024436b6c852c5129fc3c47a1 [file] [log] [blame]
Benoit Gobyd5fcafa2012-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
20void adb_auth_init(void);
Nick Kralevichbea3f9c2014-11-13 15:17:29 -080021int adb_auth_keygen(const char* filename);
Benoit Gobyd5fcafa2012-04-12 12:23:49 -070022void adb_auth_verified(atransport *t);
23
Benoit Goby045a4a92013-01-15 19:59:14 -080024void send_auth_request(atransport *t);
25
Benoit Gobyd5fcafa2012-04-12 12:23:49 -070026/* AUTH packets first argument */
27/* Request */
28#define ADB_AUTH_TOKEN 1
29/* Response */
30#define ADB_AUTH_SIGNATURE 2
31#define ADB_AUTH_RSAPUBLICKEY 3
32
33#if ADB_HOST
34
35int adb_auth_sign(void *key, void *token, size_t token_size, void *sig);
36void *adb_auth_nextkey(void *current);
37int adb_auth_get_userkey(unsigned char *data, size_t len);
38
39static inline int adb_auth_generate_token(void *token, size_t token_size) { return 0; }
40static inline int adb_auth_verify(void *token, void *sig, int siglen) { return 0; }
41static inline void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t) { }
Benoit Gobyd5fcafa2012-04-12 12:23:49 -070042
43#else // !ADB_HOST
44
45static inline int adb_auth_sign(void* key, void *token, size_t token_size, void *sig) { return 0; }
46static inline void *adb_auth_nextkey(void *current) { return NULL; }
47static inline int adb_auth_get_userkey(unsigned char *data, size_t len) { return 0; }
48
49int adb_auth_generate_token(void *token, size_t token_size);
50int adb_auth_verify(void *token, void *sig, int siglen);
51void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t);
Benoit Gobyd5fcafa2012-04-12 12:23:49 -070052
53#endif // ADB_HOST
54
55#endif // __ADB_AUTH_H