aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/plugin_gnsrecord_reclaim.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-11 20:25:11 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 10:01:23 +0200
commit94f8e5437da8cc1c5ee38a333da2e1c68b3289f1 (patch)
tree8f56950954baccbc7e1867f9ac01144b419a4798 /src/reclaim/plugin_gnsrecord_reclaim.c
parent61625d4834bc7a599446486c9d16f2451527f989 (diff)
downloadgnunet-94f8e5437da8cc1c5ee38a333da2e1c68b3289f1.tar.gz
gnunet-94f8e5437da8cc1c5ee38a333da2e1c68b3289f1.zip
RECLAIM: Start move to GNS encryption
Diffstat (limited to 'src/reclaim/plugin_gnsrecord_reclaim.c')
-rw-r--r--src/reclaim/plugin_gnsrecord_reclaim.c94
1 files changed, 11 insertions, 83 deletions
diff --git a/src/reclaim/plugin_gnsrecord_reclaim.c b/src/reclaim/plugin_gnsrecord_reclaim.c
index 9be0e7632..d4d937f7e 100644
--- a/src/reclaim/plugin_gnsrecord_reclaim.c
+++ b/src/reclaim/plugin_gnsrecord_reclaim.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -44,39 +44,16 @@ value_to_string (void *cls,
44 const void *data, 44 const void *data,
45 size_t data_size) 45 size_t data_size)
46{ 46{
47 const struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey;
48 const struct GNUNET_CRYPTO_EcdsaPublicKey *audience_pubkey;
49 const char *scopes;
50 char *ecdhe_str;
51 char *aud_str;
52 char *result;
53
54 switch (type) 47 switch (type)
55 { 48 {
56 case GNUNET_GNSRECORD_TYPE_ID_ATTR: 49 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
57 return GNUNET_STRINGS_data_to_string_alloc (data, data_size); 50 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
58 case GNUNET_GNSRECORD_TYPE_ID_TOKEN: //DEPRECATED
59 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: 51 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
60 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: 52 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
61 return GNUNET_strndup (data, data_size); 53 return GNUNET_strndup (data, data_size);
62 case GNUNET_GNSRECORD_TYPE_ABE_KEY: 54 case GNUNET_GNSRECORD_TYPE_RECLAIM_AUTHZ:
63 case GNUNET_GNSRECORD_TYPE_ABE_MASTER: 55 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
64 return GNUNET_STRINGS_data_to_string_alloc (data, data_size); 56 return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
65 case GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA: //DEPRECATED
66 ecdhe_privkey = data;
67 audience_pubkey = data+sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey);
68 scopes = (char*) audience_pubkey+(sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
69 ecdhe_str = GNUNET_STRINGS_data_to_string_alloc (ecdhe_privkey,
70 sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey));
71 aud_str = GNUNET_STRINGS_data_to_string_alloc (audience_pubkey,
72 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
73 GNUNET_asprintf (&result,
74 "%s;%s;%s",
75 ecdhe_str, aud_str, scopes);
76 GNUNET_free (aud_str);
77 GNUNET_free (ecdhe_str);
78 return result;
79
80 default: 57 default:
81 return NULL; 58 return NULL;
82 } 59 }
@@ -101,73 +78,26 @@ string_to_value (void *cls,
101 void **data, 78 void **data,
102 size_t *data_size) 79 size_t *data_size)
103{ 80{
104 char* ecdhe_str;
105 char* aud_keystr;
106 char* write_ptr;
107 char* tmp_tok;
108 char* str;
109
110 if (NULL == s) 81 if (NULL == s)
111 return GNUNET_SYSERR; 82 return GNUNET_SYSERR;
112 switch (type) 83 switch (type)
113 { 84 {
114 case GNUNET_GNSRECORD_TYPE_ID_ATTR: 85 case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR:
115 return GNUNET_STRINGS_string_to_data (s, 86 return GNUNET_STRINGS_string_to_data (s,
116 strlen (s), 87 strlen (s),
117 *data, 88 *data,
118 *data_size); 89 *data_size);
119 case GNUNET_GNSRECORD_TYPE_ID_TOKEN:
120 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: 90 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
121 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: 91 case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
122 *data = GNUNET_strdup (s); 92 *data = GNUNET_strdup (s);
123 *data_size = strlen (s); 93 *data_size = strlen (s);
124 return GNUNET_OK; 94 return GNUNET_OK;
125 case GNUNET_GNSRECORD_TYPE_ABE_KEY: 95 case GNUNET_GNSRECORD_TYPE_RECLAIM_AUTHZ:
126 case GNUNET_GNSRECORD_TYPE_ABE_MASTER: 96 case GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER:
127 return GNUNET_STRINGS_string_to_data (s, 97 return GNUNET_STRINGS_string_to_data (s,
128 strlen (s), 98 strlen (s),
129 *data, 99 *data,
130 *data_size); 100 *data_size);
131 case GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA:
132 tmp_tok = GNUNET_strdup (s);
133 ecdhe_str = strtok (tmp_tok, ";");
134 if (NULL == ecdhe_str)
135 {
136 GNUNET_free (tmp_tok);
137 return GNUNET_SYSERR;
138 }
139 aud_keystr = strtok (NULL, ";");
140 if (NULL == aud_keystr)
141 {
142 GNUNET_free (tmp_tok);
143 return GNUNET_SYSERR;
144 }
145 str = strtok (NULL, ";");
146 if (NULL == str)
147 {
148 GNUNET_free (tmp_tok);
149 return GNUNET_SYSERR;
150 }
151 *data_size = strlen (str) + 1
152 +sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey)
153 +sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
154 *data = GNUNET_malloc (*data_size);
155
156 write_ptr = *data;
157 GNUNET_STRINGS_string_to_data (ecdhe_str,
158 strlen (ecdhe_str),
159 write_ptr,
160 sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey));
161 write_ptr += sizeof (struct GNUNET_CRYPTO_EcdhePrivateKey);
162 GNUNET_STRINGS_string_to_data (aud_keystr,
163 strlen (aud_keystr),
164 write_ptr,
165 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
166 write_ptr += sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
167 GNUNET_memcpy (write_ptr, str, strlen (str) + 1); //with 0-Terminator
168 GNUNET_free (tmp_tok);
169 return GNUNET_OK;
170
171 default: 101 default:
172 return GNUNET_SYSERR; 102 return GNUNET_SYSERR;
173 } 103 }
@@ -182,11 +112,9 @@ static struct {
182 const char *name; 112 const char *name;
183 uint32_t number; 113 uint32_t number;
184} name_map[] = { 114} name_map[] = {
185 { "ID_ATTR", GNUNET_GNSRECORD_TYPE_ID_ATTR }, 115 { "RECLAIM_ATTR", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR },
186 { "ID_TOKEN", GNUNET_GNSRECORD_TYPE_ID_TOKEN }, 116 { "RECLAIM_AUTHZ", GNUNET_GNSRECORD_TYPE_RECLAIM_AUTHZ },
187 { "ABE_KEY", GNUNET_GNSRECORD_TYPE_ABE_KEY }, 117 { "RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER },
188 { "ABE_MASTER", GNUNET_GNSRECORD_TYPE_ABE_MASTER },
189 { "ID_TOKEN_METADATA", GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA },
190 { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT }, 118 { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT },
191 { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT }, 119 { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT },
192 { NULL, UINT32_MAX } 120 { NULL, UINT32_MAX }