finishing implementation of #3516

This commit is contained in:
Christian Grothoff 2015-06-22 14:36:01 +02:00
parent f0c8858825
commit 3954fbe8c0
2 changed files with 45 additions and 6 deletions

View File

@ -202,12 +202,40 @@ parse_json (json_t *root,
case MAJ_CMD_EDDSA_SIGNATURE: case MAJ_CMD_EDDSA_SIGNATURE:
{ {
/* FIXME: parse the JSON signature struct TALER_CoinSpendSignatureP sig;
and the purpose, then check that the struct GNUNET_CRYPTO_EccSignaturePurpose *purpose;
signature is valid and the size field size_t size;
is also correct; if all checks out, struct MAJ_Specification sig_spec[] = {
return the purpose */ MAJ_spec_fixed_auto ("eddsa_sig", &sig),
GNUNET_break (0); // FIXME: implement! #3516 MAJ_spec_varsize ("eddsa_val", (void**) &purpose, &size),
MAJ_spec_end
};
if (GNUNET_OK !=
MAJ_parse_json (pos,
sig_spec))
{
GNUNET_break_op (0);
MAJ_parse_free (sig_spec);
return i;
}
if (size != ntohl (purpose->size))
{
GNUNET_break_op (0);
MAJ_parse_free (sig_spec);
return i;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (ntohl (purpose->purpose),
purpose,
&sig.eddsa_signature,
spec[i].details.eddsa_signature.pub_key))
{
GNUNET_break_op (0);
MAJ_parse_free (sig_spec);
return i;
}
*spec[i].details.eddsa_signature.purpose_p = purpose;
} }
break; break;

View File

@ -218,6 +218,17 @@ MAJ_parse_free (struct MAJ_Specification *spec);
#define MAJ_spec_fixed_auto(name,obj) { .cmd = MAJ_CMD_BINARY_FIXED, .field = name, .details.fixed_data.dest = obj, .details.fixed_data.dest_size = sizeof (*obj) } #define MAJ_spec_fixed_auto(name,obj) { .cmd = MAJ_CMD_BINARY_FIXED, .field = name, .details.fixed_data.dest = obj, .details.fixed_data.dest_size = sizeof (*obj) }
/**
* Variable size object (in network byte order, encoded using Crockford
* Base32hex encoding).
*
* @param name name of the JSON field
* @param obj_ptr pointer where to write the data (a `void **`)
* @param size where to store the number of bytes allocated for @a obj (of type `size_t *`
*/
#define MAJ_spec_varsize(name,obj,size) { .cmd = MAJ_CMD_BINARY_VARIABLE, .field = name, .details.variable_data.dest_p = obj, .details.variable_data.dest_size_p = size }
/** /**
* Absolute time. * Absolute time.
* *