identity.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2013 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @author Christian Grothoff
  18. * @file identity/identity.h
  19. *
  20. * @brief Common type definitions for the identity
  21. * service and API.
  22. */
  23. #ifndef IDENTITY_H
  24. #define IDENTITY_H
  25. #include "gnunet_common.h"
  26. GNUNET_NETWORK_STRUCT_BEGIN
  27. /**
  28. * Answer from service to client about last operation;
  29. * GET_DEFAULT maybe answered with this message on failure;
  30. * CREATE and RENAME will always be answered with this message.
  31. */
  32. struct ResultCodeMessage
  33. {
  34. /**
  35. * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
  36. */
  37. struct GNUNET_MessageHeader header;
  38. /**
  39. * Status code for the last operation, in NBO.
  40. * (currently not used).
  41. */
  42. uint32_t result_code GNUNET_PACKED;
  43. /* followed by 0-terminated error message (on error) */
  44. };
  45. /**
  46. * Client informs service about desire to lookup a (single) pseudonym.
  47. */
  48. struct LookupMessage
  49. {
  50. /**
  51. * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP or
  52. * #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX
  53. */
  54. struct GNUNET_MessageHeader header;
  55. /* followed by 0-terminated ego name */
  56. };
  57. /**
  58. * Service informs client about status of a pseudonym.
  59. */
  60. struct UpdateMessage
  61. {
  62. /**
  63. * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
  64. */
  65. struct GNUNET_MessageHeader header;
  66. /**
  67. * Number of bytes in ego name string including 0-termination, in NBO;
  68. * 0 if the ego was deleted.
  69. */
  70. uint16_t name_len GNUNET_PACKED;
  71. /**
  72. * Usually #GNUNET_NO, #GNUNET_YES to signal end of list.
  73. */
  74. uint16_t end_of_list GNUNET_PACKED;
  75. /**
  76. * The private key
  77. */
  78. struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
  79. /* followed by 0-terminated ego name */
  80. };
  81. /**
  82. * Client requests knowledge about default identity for
  83. * a subsystem from identity service.
  84. */
  85. struct GetDefaultMessage
  86. {
  87. /**
  88. * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
  89. */
  90. struct GNUNET_MessageHeader header;
  91. /**
  92. * Number of bytes in service name string including 0-termination, in NBO.
  93. */
  94. uint16_t name_len GNUNET_PACKED;
  95. /**
  96. * Always zero.
  97. */
  98. uint16_t reserved GNUNET_PACKED;
  99. /* followed by 0-terminated service name */
  100. };
  101. /**
  102. * Used from service to client as a result to the GET_DEFAULT
  103. * message, used from client to service to SET_DEFAULT.
  104. */
  105. struct SetDefaultMessage
  106. {
  107. /**
  108. * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
  109. */
  110. struct GNUNET_MessageHeader header;
  111. /**
  112. * Number of bytes in service name string including 0-termination, in NBO.
  113. */
  114. uint16_t name_len GNUNET_PACKED;
  115. /**
  116. * Always zero.
  117. */
  118. uint16_t reserved GNUNET_PACKED;
  119. /**
  120. * The private key
  121. */
  122. struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
  123. /* followed by 0-terminated service name */
  124. };
  125. /**
  126. * Client requests creation of an identity. Service
  127. * will respond with a result code.
  128. */
  129. struct CreateRequestMessage
  130. {
  131. /**
  132. * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
  133. */
  134. struct GNUNET_MessageHeader header;
  135. /**
  136. * Number of bytes in identity name string including 0-termination, in NBO.
  137. */
  138. uint16_t name_len GNUNET_PACKED;
  139. /**
  140. * Always zero.
  141. */
  142. uint16_t reserved GNUNET_PACKED;
  143. /**
  144. * The private key
  145. */
  146. struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
  147. /* followed by 0-terminated identity name */
  148. };
  149. /**
  150. * Client requests renaming of an identity. Service
  151. * will respond with a result code.
  152. */
  153. struct RenameMessage
  154. {
  155. /**
  156. * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
  157. */
  158. struct GNUNET_MessageHeader header;
  159. /**
  160. * Number of characters in the old name including 0-termination, in NBO.
  161. */
  162. uint16_t old_name_len GNUNET_PACKED;
  163. /**
  164. * Number of characters in the new name including 0-termination, in NBO.
  165. */
  166. uint16_t new_name_len GNUNET_PACKED;
  167. /* followed by 0-terminated old name */
  168. /* followed by 0-terminated new name */
  169. };
  170. /**
  171. * Client requests deletion of an identity. Service
  172. * will respond with a result code.
  173. */
  174. struct DeleteMessage
  175. {
  176. /**
  177. * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
  178. */
  179. struct GNUNET_MessageHeader header;
  180. /**
  181. * Number of characters in the name including 0-termination, in NBO.
  182. */
  183. uint16_t name_len GNUNET_PACKED;
  184. /**
  185. * Always zero.
  186. */
  187. uint16_t reserved GNUNET_PACKED;
  188. /* followed by 0-terminated name */
  189. };
  190. GNUNET_NETWORK_STRUCT_END
  191. /**
  192. * Handle for an ego.
  193. */
  194. struct GNUNET_IDENTITY_Ego
  195. {
  196. /**
  197. * Private key associated with this ego.
  198. */
  199. struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
  200. /**
  201. * Current name associated with this ego.
  202. */
  203. char *name;
  204. /**
  205. * Client context associated with this ego.
  206. */
  207. void *ctx;
  208. /**
  209. * Hash of the public key of this ego.
  210. */
  211. struct GNUNET_HashCode id;
  212. };
  213. #endif