diff options
author | jospaeth <spaethj@in.tum.de> | 2020-07-16 13:41:56 +0200 |
---|---|---|
committer | jospaeth <spaethj@in.tum.de> | 2020-07-16 13:41:56 +0200 |
commit | a8b7f94fadb36299b55f15faaa5f4fda143ba9bb (patch) | |
tree | 5641541a01aba222d1131166baca6e33dfd2d4f4 /src/escrow/plugin_escrow_gns.c | |
parent | f6007d417be9f3030dad817151ed39d896d233ba (diff) | |
download | gnunet-a8b7f94fadb36299b55f15faaa5f4fda143ba9bb.tar.gz gnunet-a8b7f94fadb36299b55f15faaa5f4fda143ba9bb.zip |
change plugin functions to support async code
Diffstat (limited to 'src/escrow/plugin_escrow_gns.c')
-rw-r--r-- | src/escrow/plugin_escrow_gns.c | 73 |
1 files changed, 49 insertions, 24 deletions
diff --git a/src/escrow/plugin_escrow_gns.c b/src/escrow/plugin_escrow_gns.c index f8e509651..9e6bbda57 100644 --- a/src/escrow/plugin_escrow_gns.c +++ b/src/escrow/plugin_escrow_gns.c | |||
@@ -50,25 +50,32 @@ struct EscrowPluginHandle ph; | |||
50 | /** | 50 | /** |
51 | * Start the GNS escrow of the key | 51 | * Start the GNS escrow of the key |
52 | * | 52 | * |
53 | * @param h the handle for the escrow component | ||
53 | * @param ego the identity ego containing the private key | 54 | * @param ego the identity ego containing the private key |
54 | * @return the escrow anchor needed to restore the key | 55 | * @param cb function to call with the escrow anchor on completion |
56 | * @param cb_cls closure for @a cb | ||
55 | */ | 57 | */ |
56 | void * | 58 | void |
57 | start_gns_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) | 59 | start_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, |
60 | const struct GNUNET_IDENTITY_Ego *ego, | ||
61 | GNUNET_ESCROW_AnchorContinuation cb, | ||
62 | void *cb_cls) | ||
58 | { | 63 | { |
59 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; | 64 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk; |
60 | sss_Keyshare keyshares; | 65 | sss_Keyshare keyshares; |
61 | void *escrowAnchor; | 66 | struct GNUNET_ESCROW_Anchor *anchor; |
67 | int anchorDataSize; | ||
62 | 68 | ||
63 | if (NULL == ego) | 69 | if (NULL == ego) |
64 | { | 70 | { |
65 | return GNUNET_NO; | 71 | cb (cb_cls, NULL); |
72 | return; | ||
66 | } | 73 | } |
67 | pk = GNUNET_IDENTITY_ego_get_private_key (ego); | 74 | pk = GNUNET_IDENTITY_ego_get_private_key (ego); |
68 | 75 | ||
69 | // split the private key (SSS) | 76 | // split the private key (SSS) |
70 | sss_create_keyshares(keyshares, | 77 | sss_create_keyshares(&keyshares, |
71 | pk, | 78 | (const uint8_t *)pk, |
72 | GNUNET_ESCROW_GNS_NumberOfShares, | 79 | GNUNET_ESCROW_GNS_NumberOfShares, |
73 | GNUNET_ESCROW_GNS_ShareThreshold); | 80 | GNUNET_ESCROW_GNS_ShareThreshold); |
74 | 81 | ||
@@ -78,55 +85,73 @@ start_gns_key_escrow (const struct GNUNET_IDENTITY_Ego *ego) | |||
78 | 85 | ||
79 | 86 | ||
80 | // TODO: implement | 87 | // TODO: implement |
81 | return escrowAnchor; | 88 | anchorDataSize = 0; // TODO! |
89 | anchor = GNUNET_malloc (sizeof (struct GNUNET_ESCROW_Anchor) + anchorDataSize); | ||
90 | cb (cb_cls, anchor); | ||
82 | } | 91 | } |
83 | 92 | ||
84 | 93 | ||
85 | /** | 94 | /** |
86 | * Renew the GNS escrow of the key | 95 | * Renew the GNS escrow of the key |
87 | * | 96 | * |
97 | * @param h the handle for the escrow component | ||
88 | * @param escrowAnchor the the escrow anchor returned by the start method | 98 | * @param escrowAnchor the the escrow anchor returned by the start method |
89 | * @return the escrow anchor needed to restore the key | 99 | * @param cb function to call with the (new) escrow anchor on completion |
100 | * @param cb_cls closure for @a cb | ||
90 | */ | 101 | */ |
91 | void * | 102 | void |
92 | renew_gns_key_escrow (void *escrowAnchor) | 103 | renew_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, |
104 | struct GNUNET_ESCROW_Anchor *escrowAnchor, | ||
105 | GNUNET_ESCROW_AnchorContinuation cb, | ||
106 | void *cb_cls) | ||
93 | { | 107 | { |
94 | // TODO: implement | 108 | // TODO: implement |
95 | return NULL; | 109 | cb (cb_cls, NULL); |
96 | } | 110 | } |
97 | 111 | ||
98 | 112 | ||
99 | /** | 113 | /** |
100 | * Verify the GNS escrow of the key | 114 | * Verify the GNS escrow of the key |
101 | * | 115 | * |
116 | * @param h the handle for the escrow component | ||
102 | * @param ego the identity ego containing the private key | 117 | * @param ego the identity ego containing the private key |
103 | * @param escrowAnchor the escrow anchor needed to restore the key | 118 | * @param escrowAnchor the escrow anchor needed to restore the key |
104 | * @return GNUNET_ESCROW_VALID if the escrow could successfully by restored, | 119 | * @param cb function to call with the verification result on completion, i.e. |
105 | * GNUNET_ESCROW_RENEW_NEEDED if the escrow needs to be renewed, | 120 | * GNUNET_ESCROW_VALID if the escrow could successfully by restored, |
106 | * GNUNET_ESCROW_INVALID otherwise | 121 | * GNUNET_ESCROW_RENEW_NEEDED if the escrow needs to be renewed, |
122 | * GNUNET_ESCROW_INVALID otherwise | ||
123 | * @param cb_cls closure for @a cb | ||
107 | */ | 124 | */ |
108 | int | 125 | void |
109 | verify_gns_key_escrow (const struct GNUNET_IDENTITY_Ego *ego, | 126 | verify_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, |
110 | void *escrowAnchor) | 127 | const struct GNUNET_IDENTITY_Ego *ego, |
128 | struct GNUNET_ESCROW_Anchor *escrowAnchor, | ||
129 | GNUNET_ESCROW_VerifyContinuation cb, | ||
130 | void *cb_cls) | ||
111 | { | 131 | { |
112 | // TODO: implement | 132 | // TODO: implement |
113 | return GNUNET_ESCROW_INVALID; | 133 | cb (cb_cls, GNUNET_ESCROW_INVALID); |
114 | } | 134 | } |
115 | 135 | ||
116 | 136 | ||
117 | /** | 137 | /** |
118 | * Restore the key from GNS escrow | 138 | * Restore the key from GNS escrow |
119 | * | 139 | * |
140 | * @param h the handle for the escrow component | ||
120 | * @param escrowAnchor the escrow anchor needed to restore the key | 141 | * @param escrowAnchor the escrow anchor needed to restore the key |
121 | * @param egoName the name of the ego to restore | 142 | * @param egoName the name of the ego to restore |
122 | * @return the identity ego containing the private key | 143 | * @param cb function to call with the restored ego on completion |
144 | * @param cb_cls closure for @a cb | ||
123 | */ | 145 | */ |
124 | const struct GNUNET_IDENTITY_Ego * | 146 | void |
125 | restore_gns_key_escrow (void *escrowAnchor, | 147 | restore_gns_key_escrow (struct GNUNET_ESCROW_Handle *h, |
126 | char *egoName) | 148 | struct GNUNET_ESCROW_Anchor *escrowAnchor, |
149 | char *egoName, | ||
150 | GNUNET_ESCROW_EgoContinuation cb, | ||
151 | void *cb_cls) | ||
127 | { | 152 | { |
128 | // TODO: implement | 153 | // TODO: implement |
129 | return NULL; | 154 | cb (cb_cls, NULL); |
130 | } | 155 | } |
131 | 156 | ||
132 | 157 | ||