adb_auth.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef __ADB_AUTH_H
  17. #define __ADB_AUTH_H
  18. void adb_auth_init(void);
  19. void adb_auth_verified(atransport *t);
  20. /* AUTH packets first argument */
  21. /* Request */
  22. #define ADB_AUTH_TOKEN 1
  23. /* Response */
  24. #define ADB_AUTH_SIGNATURE 2
  25. #define ADB_AUTH_RSAPUBLICKEY 3
  26. #if ADB_HOST
  27. int adb_auth_sign(void *key, void *token, size_t token_size, void *sig);
  28. void *adb_auth_nextkey(void *current);
  29. int adb_auth_get_userkey(unsigned char *data, size_t len);
  30. static inline int adb_auth_generate_token(void *token, size_t token_size) { return 0; }
  31. static inline int adb_auth_verify(void *token, void *sig, int siglen) { return 0; }
  32. static inline void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t) { }
  33. static inline void adb_auth_reload_keys(void) { }
  34. #else // !ADB_HOST
  35. static inline int adb_auth_sign(void* key, void *token, size_t token_size, void *sig) { return 0; }
  36. static inline void *adb_auth_nextkey(void *current) { return NULL; }
  37. static inline int adb_auth_get_userkey(unsigned char *data, size_t len) { return 0; }
  38. int adb_auth_generate_token(void *token, size_t token_size);
  39. int adb_auth_verify(void *token, void *sig, int siglen);
  40. void adb_auth_confirm_key(unsigned char *data, size_t len, atransport *t);
  41. void adb_auth_reload_keys(void);
  42. #endif // ADB_HOST
  43. #endif // __ADB_AUTH_H