aboutsummaryrefslogtreecommitdiff
path: root/src/escrow/escrow_api.c
diff options
context:
space:
mode:
authorjospaeth <spaethj@in.tum.de>2020-07-12 19:42:45 +0200
committerjospaeth <spaethj@in.tum.de>2020-07-12 19:42:45 +0200
commit97444379672ac580b2ee3f81f0b6fdbae9d0a3f2 (patch)
tree34272f4e9573cb2e295b8ad007710c847cd10947 /src/escrow/escrow_api.c
parent45016bc5f75a0182db4596df54bf68fe83ecd12a (diff)
downloadgnunet-97444379672ac580b2ee3f81f0b6fdbae9d0a3f2.tar.gz
gnunet-97444379672ac580b2ee3f81f0b6fdbae9d0a3f2.zip
add escrow API
Diffstat (limited to 'src/escrow/escrow_api.c')
-rw-r--r--src/escrow/escrow_api.c114
1 files changed, 101 insertions, 13 deletions
diff --git a/src/escrow/escrow_api.c b/src/escrow/escrow_api.c
index 5a5891a71..4e26c8aba 100644
--- a/src/escrow/escrow_api.c
+++ b/src/escrow/escrow_api.c
@@ -25,35 +25,112 @@
25 * @brief api to interact with the escrow component 25 * @brief api to interact with the escrow component
26 */ 26 */
27 27
28#include "gnunet_util_lib.h"
28#include "gnunet_escrow_lib.h" 29#include "gnunet_escrow_lib.h"
30#include "gnunet_escrow_plugin.h"
29 31
30 32
31/** 33/**
32 * Put some data in escrow using the specified escrow method 34 * Init canary for the plaintext plugin
35 */
36static int plaintext_initialized;
37
38
39/**
40 * Init canary for the GNS plugin
41 */
42static int gns_initialized;
43
44
45/**
46 * Init canary for the Anastasis plugin
47 */
48static int anastasis_initialized;
49
50
51/**
52 * Pointer to the plaintext plugin API
53 */
54static struct GNUNET_ESCROW_KeyPluginFunctions *plaintext_api;
55
56
57/**
58 * Pointer to the GNS plugin API
59 */
60static struct GNUNET_ESCROW_KeyPluginFunctions *gns_api;
61
62
63/**
64 * Pointer to the Anastasis plugin API
65 */
66static struct GNUNET_ESCROW_KeyPluginFunctions *anastasis_api;
67
68
69/**
70 * Initialize an escrow plugin
33 * 71 *
34 * @param ego the identity ego to put in escrow 72 * @param method the escrow method determining the plugin
35 * @param method the escrow method to use
36 * 73 *
37 * @return the escrow anchor needed to get the data back 74 * @return pointer to the escrow plugin API
38 */ 75 */
39void * 76struct GNUNET_ESCROW_KeyPluginFunctions *
40GNUNET_ESCROW_put (const struct GNUNET_IDENTITY_Ego *ego, 77init_plugin (enum GNUNET_ESCROW_Key_Escrow_Method method)
41 enum GNUNET_ESCROW_Key_Escrow_Method method)
42{ 78{
43 switch (method) 79 switch (method)
44 { 80 {
45 case GNUNET_ESCROW_KEY_PLAINTEXT: 81 case GNUNET_ESCROW_KEY_PLAINTEXT:
46 break; 82 if (GNUNET_YES == plaintext_initialized)
83 return plaintext_api;
84 plaintext_initialized = GNUNET_YES;
85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
86 "Loading PLAINTEXT escrow plugin\n");
87 plaintext_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_plaintext",
88 NULL);
89 return plaintext_api;
47 case GNUNET_ESCROW_KEY_GNS: 90 case GNUNET_ESCROW_KEY_GNS:
48 break; 91 if (GNUNET_YES == gns_initialized)
92 return gns_api;
93 gns_initialized = GNUNET_YES;
94 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
95 "Loading GNS escrow plugin\n");
96 gns_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_gns",
97 NULL);
98 return gns_api;
49 case GNUNET_ESCROW_KEY_ANASTASIS: 99 case GNUNET_ESCROW_KEY_ANASTASIS:
50 break; 100 if (GNUNET_YES == anastasis_initialized)
101 return anastasis_api;
102 anastasis_initialized = GNUNET_YES;
103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
104 "Loading ANASTASIS escrow plugin\n");
105 anastasis_api = GNUNET_PLUGIN_load ("libgnunet_plugin_escrow_anastasis",
106 NULL);
107 return anastasis_api;
51 } 108 }
109 // should never be reached
52 return NULL; 110 return NULL;
53} 111}
54 112
55 113
56/** 114/**
115 * Put some data in escrow using the specified escrow method
116 *
117 * @param ego the identity ego to put in escrow
118 * @param method the escrow method to use
119 *
120 * @return the escrow anchor needed to get the data back
121 */
122void *
123GNUNET_ESCROW_put (const struct GNUNET_IDENTITY_Ego *ego,
124 enum GNUNET_ESCROW_Key_Escrow_Method method)
125{
126 struct GNUNET_ESCROW_KeyPluginFunctions *api;
127
128 api = init_plugin (method);
129 return api->start_key_escrow (ego);
130}
131
132
133/**
57 * Renew the escrow of the data related to the given escrow anchor 134 * Renew the escrow of the data related to the given escrow anchor
58 * 135 *
59 * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method 136 * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method
@@ -65,7 +142,10 @@ void *
65GNUNET_ESCROW_renew (void *escrowAnchor, 142GNUNET_ESCROW_renew (void *escrowAnchor,
66 enum GNUNET_ESCROW_Key_Escrow_Method method) 143 enum GNUNET_ESCROW_Key_Escrow_Method method)
67{ 144{
68 return NULL; 145 struct GNUNET_ESCROW_KeyPluginFunctions *api;
146
147 api = init_plugin (method);
148 return api->renew_key_escrow (escrowAnchor);
69} 149}
70 150
71 151
@@ -73,15 +153,20 @@ GNUNET_ESCROW_renew (void *escrowAnchor,
73 * Get the escrowed data back 153 * Get the escrowed data back
74 * 154 *
75 * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method 155 * @param escrowAnchor the escrow anchor returned by the GNUNET_ESCROW_put method
156 * @param egoName the name of the ego to get back
76 * @param method the escrow method to use 157 * @param method the escrow method to use
77 * 158 *
78 * @return a new identity ego restored from the escrow 159 * @return a new identity ego restored from the escrow
79 */ 160 */
80const struct GNUNET_IDENTITY_Ego * 161const struct GNUNET_IDENTITY_Ego *
81GNUNET_ESCROW_get (void *escrowAnchor, 162GNUNET_ESCROW_get (void *escrowAnchor,
163 char *egoName,
82 enum GNUNET_ESCROW_Key_Escrow_Method method) 164 enum GNUNET_ESCROW_Key_Escrow_Method method)
83{ 165{
84 return NULL; 166 struct GNUNET_ESCROW_KeyPluginFunctions *api;
167
168 api = init_plugin (method);
169 return api->restore_key (escrowAnchor, egoName);
85} 170}
86 171
87 172
@@ -99,5 +184,8 @@ GNUNET_ESCROW_verify (const struct GNUNET_IDENTITY_Ego *ego,
99 void *escrowAnchor, 184 void *escrowAnchor,
100 enum GNUNET_ESCROW_Key_Escrow_Method method) 185 enum GNUNET_ESCROW_Key_Escrow_Method method)
101{ 186{
102 return GNUNET_NO; 187 struct GNUNET_ESCROW_KeyPluginFunctions *api;
188
189 api = init_plugin (method);
190 return api->verify_key_escrow (ego, escrowAnchor);
103} 191}