p≡p engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

386 lines
10 KiB

6 years ago
10 months ago
6 years ago
10 months ago
6 years ago
6 years ago
6 years ago
10 months ago
6 years ago
6 years ago
10 months ago
6 years ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. /**
  2. * @file map_asn1.h
  3. * @brief map asn1 to pEp structs and back
  4. * @license GNU General Public License 3.0 - see LICENSE.txt
  5. */
  6. #ifndef MAP_ASN1_H
  7. #define MAP_ASN1_H
  8. #include "message.h"
  9. #include "ASN1Message.h"
  10. #include "Identity.h"
  11. #include "IdentityList.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /* For compatibility reasons we have PIdentity as a distinct struct from
  16. Identity. The difference is that PIdentity has some optional fields, notably
  17. fpr.
  18. Some functionality is replicated for each struct kind. */
  19. /**
  20. * <!-- PIdentity_from_Struct() -->
  21. *
  22. * @brief Convert pEp_identity into ASN.1 PIdentity_t
  23. *
  24. * @param ident[in] pEp_identity to convert
  25. * @param result[in,out] PIdentity_t to update or NULL to alloc a new one
  26. *
  27. * @retval pointer to updated or allocated result
  28. *
  29. * @warning if a new struct is allocated, the ownership goes to the caller
  30. *
  31. */
  32. PIdentity_t *PIdentity_from_Struct(
  33. const pEp_identity *ident,
  34. PIdentity_t *result
  35. );
  36. /**
  37. * <!-- PIdentity_to_Struct() -->
  38. *
  39. * @brief Convert ASN.1 PIdentity_t into pEp_identity
  40. *
  41. * @param ident[in] PIdentity_t to convert
  42. * @param result[inout] pEp_identity to update or NULL to alloc a new one
  43. *
  44. * @retval pointer to updated or allocated result
  45. *
  46. * @warning if a new struct is allocated, the ownership goes to the caller
  47. *
  48. */
  49. pEp_identity *PIdentity_to_Struct(PIdentity_t *ident, pEp_identity *result);
  50. /**
  51. * <!-- PIdentityList_from_identity_list() -->
  52. *
  53. * @brief Convert identity_list_t into ASN.1 PIdentityList_t
  54. *
  55. * @param list[in] identity_list to convert
  56. * @param result[inout] PIdentityList_t to update or NULL to alloc a new one
  57. *
  58. * @retval pointer to updated or allocated result
  59. *
  60. * @warning if a new struct is allocated, the ownership goes to the caller
  61. *
  62. */
  63. PIdentityList_t *PIdentityList_from_identity_list(
  64. const identity_list *list,
  65. PIdentityList_t *result
  66. );
  67. /**
  68. * <!-- PIdentityList_to_identity_list() -->
  69. *
  70. * @brief Convert ASN.1 PIdentityList_t to identity_list_t
  71. *
  72. * @param list[in] ASN.1 PIdentityList_t to convert
  73. * @param result[inout] identity_list_t to update or NULL to alloc a new one
  74. *
  75. * @retval pointer to updated or allocated result
  76. *
  77. * @warning if a new struct is allocated, the ownership goes to the caller
  78. *
  79. */
  80. identity_list *PIdentityList_to_identity_list(PIdentityList_t *list, identity_list *result);
  81. /**
  82. * <!-- Identity_from_Struct() -->
  83. *
  84. * @brief Convert pEp_identity into ASN.1 Identity_t
  85. *
  86. * @param ident[in] pEp_identity to convert
  87. * @param result[in,out] Identity_t to update or NULL to alloc a new one
  88. *
  89. * @retval pointer to updated or allocated result
  90. *
  91. * @warning if a new struct is allocated, the ownership goes to the caller
  92. *
  93. */
  94. Identity_t *Identity_from_Struct(
  95. const pEp_identity *ident,
  96. Identity_t *result
  97. );
  98. /**
  99. * <!-- Identity_to_Struct() -->
  100. *
  101. * @brief Convert ASN.1 Identity_t into pEp_identity
  102. *
  103. * @param ident[in] Identity_t to convert
  104. * @param result[inout] pEp_identity to update or NULL to alloc a new one
  105. *
  106. * @retval pointer to updated or allocated result
  107. *
  108. * @warning if a new struct is allocated, the ownership goes to the caller
  109. *
  110. */
  111. pEp_identity *Identity_to_Struct(Identity_t *ident, pEp_identity *result);
  112. /**
  113. * <!-- IdentityList_from_identity_list() -->
  114. *
  115. * @brief Convert identity_list_t into ASN.1 IdentityList_t
  116. *
  117. * @param list[in] identity_list to convert
  118. * @param result[inout] IdentityList_t to update or NULL to alloc a new one
  119. *
  120. * @retval pointer to updated or allocated result
  121. *
  122. * @warning if a new struct is allocated, the ownership goes to the caller
  123. *
  124. */
  125. IdentityList_t *IdentityList_from_identity_list(
  126. const identity_list *list,
  127. IdentityList_t *result
  128. );
  129. /**
  130. * <!-- IdentityList_to_identity_list() -->
  131. *
  132. * @brief Convert ASN.1 IdentityList_t to identity_list_t
  133. *
  134. * @param list[in] ASN.1 IdentityList_t to convert
  135. * @param result[inout] identity_list_t to update or NULL to alloc a new one
  136. *
  137. * @retval pointer to updated or allocated result
  138. *
  139. * @warning if a new struct is allocated, the ownership goes to the caller
  140. *
  141. */
  142. identity_list *IdentityList_to_identity_list(IdentityList_t *list, identity_list *result);
  143. /**
  144. * <!-- PStringPair_from_Struct() -->
  145. *
  146. * @brief Convert stringpair_t into ASN.1 PStringPair_t
  147. *
  148. * @param value[in] stringpair_t to convert
  149. * @param result[in,out] PStringPair_t to update or NULL to alloc a new one
  150. *
  151. * @retval pointer to updated or allocated result
  152. *
  153. * @warning if a new struct is allocated, the ownership goes to the caller
  154. *
  155. */
  156. PStringPair_t *PStringPair_from_Struct(
  157. const stringpair_t *value,
  158. PStringPair_t *result
  159. );
  160. /**
  161. * <!-- PStringPair_to_Struct() -->
  162. *
  163. * @brief Convert ASN.1 PStringPair_t into stringpair_t
  164. *
  165. * @param value[in] PStringPair_t to convert
  166. *
  167. * @retval pointer to updated or allocated result
  168. *
  169. * @warning a new struct is allocated, the ownership goes to the caller
  170. *
  171. */
  172. stringpair_t *PStringPair_to_Struct(PStringPair_t *value);
  173. /**
  174. * <!-- PStringPairList_from_stringpair_list() -->
  175. *
  176. * @brief Convert stringpair_list_t into ASN.1 PStringPairList_t
  177. *
  178. * @param list[in] stringpair_list to convert
  179. * @param result[inout] PStringPairList_t to update or NULL to alloc a new one
  180. *
  181. * @retval pointer to updated or allocated result
  182. *
  183. * @warning if a new struct is allocated, the ownership goes to the caller
  184. *
  185. */
  186. PStringPairList_t *PStringPairList_from_stringpair_list(
  187. const stringpair_list_t *list,
  188. PStringPairList_t *result
  189. );
  190. /**
  191. * <!-- PStringPairList_to_stringpair_list() -->
  192. *
  193. * @brief Convert ASN.1 PStringPairList_t to stringpair_list_t
  194. *
  195. * @param list[in] ASN.1 PStringPairList_t to convert
  196. * @param result[inout] stringpair_list_t to update or NULL to alloc a new one
  197. *
  198. * @retval pointer to updated or allocated result
  199. *
  200. * @warning if a new struct is allocated, the ownership goes to the caller
  201. *
  202. */
  203. stringpair_list_t *PStringPairList_to_stringpair_list(
  204. PStringPairList_t *list,
  205. stringpair_list_t *result
  206. );
  207. /**
  208. * <!-- PStringList_from_stringlist() -->
  209. *
  210. * @brief Convert stringlist_t into ASN.1 PStringList_t
  211. *
  212. * @param list[in] stringlist to convert
  213. * @param result[inout] PStringList_t to update or NULL to alloc a new one
  214. *
  215. * @retval pointer to updated or allocated result
  216. *
  217. * @warning if a new struct is allocated, the ownership goes to the caller
  218. *
  219. */
  220. PStringList_t *PStringList_from_stringlist(
  221. const stringlist_t *list,
  222. PStringList_t *result
  223. );
  224. /**
  225. * <!-- PStringList_to_stringlist() -->
  226. *
  227. * @brief Convert ASN.1 PStringList_t to stringlist_t
  228. *
  229. * @param list[in] ASN.1 PStringList_t to convert
  230. *
  231. * @retval pointer to updated or allocated result
  232. *
  233. * @warning a new struct is allocated, the ownership goes to the caller
  234. *
  235. */
  236. stringlist_t *PStringList_to_stringlist(PStringList_t *list);
  237. /**
  238. * <!-- PBlobList_from_bloblist() -->
  239. *
  240. * @brief Convert bloblist_t into ASN.1 PBlobList_t
  241. *
  242. * @param list[in] bloblist to convert
  243. * @param result[inout] PBlobList_t to update or NULL to alloc a new one
  244. * @param copy copy data if true, move data otherwise
  245. * @param max_blob_size reject if sum(blob.size) > max_blob_size
  246. * to disable set to 0
  247. *
  248. * @retval pointer to updated or allocated result
  249. *
  250. * @warning if a new struct is allocated, the ownership goes to the caller
  251. *
  252. */
  253. PBlobList_t *PBlobList_from_bloblist(
  254. bloblist_t *list,
  255. PBlobList_t *result,
  256. bool copy,
  257. size_t max_blob_size
  258. );
  259. /**
  260. * <!-- PBlobList_to_bloblist() -->
  261. *
  262. * @brief Convert ASN.1 PBlobList_t to bloblist_t
  263. *
  264. * @param list[in] ASN.1 PBlobList_t to convert
  265. * @param result[inout] bloblist_t to update or NULL to alloc a new one
  266. * @param copy copy data if true, move data otherwise
  267. * @param max_blob_size reject if sum(blob.size) > max_blob_size
  268. * to disable set to 0
  269. *
  270. * @retval pointer to updated or allocated result
  271. *
  272. * @warning if a new struct is allocated, the ownership goes to the caller
  273. *
  274. */
  275. bloblist_t *PBlobList_to_bloblist(
  276. PBlobList_t *list,
  277. bloblist_t *result,
  278. bool copy,
  279. size_t max_blob_size
  280. );
  281. /**
  282. * <!-- ASN1Message_from_message() -->
  283. *
  284. * @brief Convert message into ASN.1 ASN1Message_t
  285. *
  286. * @param msg[in] message to convert
  287. * @param result[inout] ASN1Message_t to update or NULL to alloc a new one
  288. * @param copy copy data if true, move data otherwise
  289. * @param max_blob_size reject if sum(blob.size) > max_blob_size
  290. * to disable set to 0
  291. *
  292. * @retval pointer to updated or allocated result
  293. *
  294. * @warning if a new struct is allocated, the ownership goes to the caller
  295. *
  296. */
  297. ASN1Message_t *ASN1Message_from_message(
  298. message *msg,
  299. ASN1Message_t *result,
  300. bool copy,
  301. size_t max_blob_size
  302. );
  303. /**
  304. * <!-- ASN1Message_to_message() -->
  305. *
  306. * @brief Convert ASN.1 ASN1Message_t to message
  307. *
  308. * @param msg[in] ASN.1 ASN1Message_t to convert
  309. * @param result[inout] message to update or NULL to alloc a new one
  310. * @param copy copy data if true, move data otherwise
  311. * @param max_blob_size reject if sum(blob.size) > max_blob_size
  312. * to disable set to 0
  313. *
  314. * @retval pointer to updated or allocated result
  315. *
  316. * @warning if a new struct is allocated, the ownership goes to the caller
  317. *
  318. */
  319. message *ASN1Message_to_message(
  320. ASN1Message_t *msg,
  321. message *result,
  322. bool copy,
  323. size_t max_blob_size
  324. );
  325. #ifdef __cplusplus
  326. }
  327. #endif
  328. #endif