OSDN Git Service

Merge "sdcard: Turn on noatime for fuse mounted sdcard"
[android-x86/system-core.git] / adb / adb_auth.h
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 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 extern int auth_enabled;
27
28 int adb_auth_keygen(const char* filename);
29 void adb_auth_verified(atransport *t);
30
31 void send_auth_request(atransport *t);
32 void send_auth_response(uint8_t *token, size_t token_size, atransport *t);
33 void send_auth_publickey(atransport *t);
34
35 /* AUTH packets first argument */
36 /* Request */
37 #define ADB_AUTH_TOKEN         1
38 /* Response */
39 #define ADB_AUTH_SIGNATURE     2
40 #define ADB_AUTH_RSAPUBLICKEY  3
41
42 #if ADB_HOST
43
44 void adb_auth_init(void);
45 int adb_auth_sign(void *key, const unsigned char* token, size_t token_size,
46                   unsigned char* sig);
47 void *adb_auth_nextkey(void *current);
48 int adb_auth_get_userkey(unsigned char *data, size_t len);
49
50 static inline int adb_auth_generate_token(void *token, size_t token_size) { return 0; }
51 static inline int adb_auth_verify(void *token, void *sig, int siglen) { return 0; }
52 static inline void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t) { }
53
54 #else // !ADB_HOST
55
56 static inline int adb_auth_sign(void* key, const unsigned char* token,
57                                 size_t token_size, unsigned char* sig) {
58     return 0;
59 }
60 static inline void *adb_auth_nextkey(void *current) { return NULL; }
61 static inline int adb_auth_get_userkey(unsigned char *data, size_t len) { return 0; }
62
63 void adbd_auth_init(void);
64 void adbd_cloexec_auth_socket();
65 int adb_auth_generate_token(void *token, size_t token_size);
66 int adb_auth_verify(uint8_t* token, uint8_t* sig, int siglen);
67 void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t);
68
69 #endif // ADB_HOST
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif // __ADB_AUTH_H