Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 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 | |
Dan Albert | 818fb4b | 2015-02-18 00:18:25 -0800 | [diff] [blame^] | 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 24 | void adb_auth_init(void); |
Nick Kralevich | bea3f9c | 2014-11-13 15:17:29 -0800 | [diff] [blame] | 25 | int adb_auth_keygen(const char* filename); |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 26 | void adb_auth_verified(atransport *t); |
| 27 | |
Benoit Goby | 045a4a9 | 2013-01-15 19:59:14 -0800 | [diff] [blame] | 28 | void send_auth_request(atransport *t); |
| 29 | |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 30 | /* AUTH packets first argument */ |
| 31 | /* Request */ |
| 32 | #define ADB_AUTH_TOKEN 1 |
| 33 | /* Response */ |
| 34 | #define ADB_AUTH_SIGNATURE 2 |
| 35 | #define ADB_AUTH_RSAPUBLICKEY 3 |
| 36 | |
| 37 | #if ADB_HOST |
| 38 | |
| 39 | int adb_auth_sign(void *key, void *token, size_t token_size, void *sig); |
| 40 | void *adb_auth_nextkey(void *current); |
| 41 | int adb_auth_get_userkey(unsigned char *data, size_t len); |
| 42 | |
| 43 | static inline int adb_auth_generate_token(void *token, size_t token_size) { return 0; } |
| 44 | static inline int adb_auth_verify(void *token, void *sig, int siglen) { return 0; } |
| 45 | static inline void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t) { } |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 46 | |
| 47 | #else // !ADB_HOST |
| 48 | |
| 49 | static inline int adb_auth_sign(void* key, void *token, size_t token_size, void *sig) { return 0; } |
| 50 | static inline void *adb_auth_nextkey(void *current) { return NULL; } |
| 51 | static inline int adb_auth_get_userkey(unsigned char *data, size_t len) { return 0; } |
| 52 | |
| 53 | int adb_auth_generate_token(void *token, size_t token_size); |
| 54 | int adb_auth_verify(void *token, void *sig, int siglen); |
| 55 | void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t); |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 56 | |
| 57 | #endif // ADB_HOST |
| 58 | |
Dan Albert | 818fb4b | 2015-02-18 00:18:25 -0800 | [diff] [blame^] | 59 | #ifdef __cplusplus |
| 60 | } |
| 61 | #endif |
| 62 | |
Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 63 | #endif // __ADB_AUTH_H |