Diff

Differences From Artifact [6a8716cb4e]:

To Artifact [ca961d2702]:


186
187
188
189
190
191
192

193
194
195
196
197
198
199
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200







+







}

static int nano_tcl_verify_detached(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) {
	int cso_ret;
	unsigned char *signature, *data, *signed_data, *public_key;
	int signature_length, data_length, signed_data_length, public_key_length;
	unsigned long long data_length_nacl;
	int result;

	if (objc != 4) {
		Tcl_WrongNumArgs(interp, 1, objv, "data signature publicKey");

		return(TCL_ERROR);
	}

221
222
223
224
225
226
227

228

229
230

231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
222
223
224
225
226
227
228
229

230


231



232
233
234
235

236
237
238
239
240
241
242
243







+
-
+
-
-
+
-
-
-




-
+







	}

	memcpy(signed_data, signature, signature_length);
	memcpy(signed_data + signature_length, data, data_length);

	data_length_nacl = data_length;
	cso_ret = crypto_sign_open(data, &data_length_nacl, signed_data, signed_data_length, public_key);
	result = 0;
	if (cso_ret != 0) {
	if (cso_ret == 0) {
		Tcl_Free((char *) signed_data);

		result = 1;
		Tcl_SetResult(interp, "crypto_sign_open failed", NULL);

		return(TCL_ERROR);
	}

	Tcl_Free((char *) signed_data);

	/* XXX:TODO: Validate */
	Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));

	return(TCL_OK);

	/* NOTREACH */
	clientData = clientData;
}