|
|
@@ -41,34 +41,44 @@ void vectors_keygen(uint32_t oid, json_object *jreq, json_object *jres, uint32_t |
|
|
|
xmss_parse_oid(¶ms, oid); |
|
|
|
|
|
|
|
unsigned char seed[params.n * 3]; |
|
|
|
unsigned char pk[params.pk_bytes]; |
|
|
|
unsigned char sk[params.sk_bytes]; |
|
|
|
unsigned char pk[params.pk_bytes + XMSS_OID_LEN]; |
|
|
|
unsigned char sk[params.sk_bytes + XMSS_OID_LEN]; |
|
|
|
char *sbuf; |
|
|
|
unsigned i; |
|
|
|
|
|
|
|
tcs_req = json_object_new_array(); |
|
|
|
tcs_res = json_object_new_array(); |
|
|
|
|
|
|
|
for (i = 0; i < XMSS_OID_LEN; i++) { |
|
|
|
pk[XMSS_OID_LEN - i - 1] = (oid >> (8 * i)) & 0xFF; |
|
|
|
sk[XMSS_OID_LEN - i - 1] = (oid >> (8 * i)) & 0xFF; |
|
|
|
} |
|
|
|
|
|
|
|
for (size_t i=0; i<n_samples; i++) { |
|
|
|
tc_req = json_object_new_object(); |
|
|
|
tc_res = json_object_new_object(); |
|
|
|
|
|
|
|
getentropy(seed, 3*params.n); |
|
|
|
xmssmt_core_seed_keypair(¶ms, pk, sk, seed); |
|
|
|
xmssmt_core_seed_keypair(¶ms, &pk[XMSS_OID_LEN], &sk[XMSS_OID_LEN], seed); |
|
|
|
|
|
|
|
json_object_object_add(tc_req, "tcId", json_object_new_int(i+1)); |
|
|
|
sbuf = malloc(2*3*params.n + 1); |
|
|
|
sprint_hex(sbuf, seed, 3*params.n); |
|
|
|
json_object_object_add(tc_req, "seed", json_object_new_string(sbuf)); |
|
|
|
sbuf = malloc(2*params.n + 1); |
|
|
|
sprint_hex(sbuf, seed, params.n); |
|
|
|
json_object_object_add(tc_req, "S_XMSS", json_object_new_string(sbuf)); |
|
|
|
sprint_hex(sbuf, &seed[params.n], params.n); |
|
|
|
json_object_object_add(tc_req, "SK_PRF", json_object_new_string(sbuf)); |
|
|
|
sprint_hex(sbuf, &seed[2*params.n], params.n); |
|
|
|
json_object_object_add(tc_req, "I", json_object_new_string(sbuf)); |
|
|
|
free(sbuf); |
|
|
|
|
|
|
|
json_object_object_add(tc_res, "tcId", json_object_new_int(i+1)); |
|
|
|
sbuf = malloc(2*params.pk_bytes + 1); |
|
|
|
sprint_hex(sbuf, pk, params.pk_bytes); |
|
|
|
sprint_hex(sbuf, pk, params.pk_bytes + XMSS_OID_LEN); |
|
|
|
json_object_object_add(tc_res, "publicKey", json_object_new_string(sbuf)); |
|
|
|
free(sbuf); |
|
|
|
|
|
|
|
sbuf = malloc(2*params.sk_bytes + 1); |
|
|
|
sprint_hex(sbuf, sk, params.sk_bytes); |
|
|
|
sprint_hex(sbuf, sk, params.sk_bytes + XMSS_OID_LEN); |
|
|
|
json_object_object_add(tc_res, "secretKey", json_object_new_string(sbuf)); |
|
|
|
free(sbuf); |
|
|
|
|
|
|
@@ -194,8 +204,8 @@ void siggen_KAT(const struct param_t *h) { |
|
|
|
|
|
|
|
char buf[256], *sbuf; |
|
|
|
unsigned char seed[params.n * 3]; |
|
|
|
unsigned char pk[params.pk_bytes]; |
|
|
|
unsigned char sk[params.sk_bytes]; |
|
|
|
unsigned char pk[params.pk_bytes + XMSS_OID_LEN]; |
|
|
|
unsigned char sk[params.sk_bytes + XMSS_OID_LEN]; |
|
|
|
|
|
|
|
jreq = json_object_new_object(); |
|
|
|
jres = json_object_new_object(); |
|
|
@@ -219,19 +229,23 @@ void siggen_KAT(const struct param_t *h) { |
|
|
|
json_object_object_add(tg_req, "OID", json_object_new_int(h->oid)); |
|
|
|
|
|
|
|
getentropy(seed, 3*params.n); |
|
|
|
xmssmt_core_seed_keypair(¶ms, pk, sk, seed); |
|
|
|
|
|
|
|
sbuf = malloc(2*3*params.n + 1); |
|
|
|
sprint_hex(sbuf, seed, 3*params.n); |
|
|
|
json_object_object_add(tg_req, "seed", json_object_new_string(sbuf)); |
|
|
|
xmssmt_core_seed_keypair(¶ms, pk + XMSS_OID_LEN, sk + XMSS_OID_LEN, seed); |
|
|
|
|
|
|
|
sbuf = malloc(2*params.n + 1); |
|
|
|
sprint_hex(sbuf, seed, params.n); |
|
|
|
json_object_object_add(tg_req, "S_XMSS", json_object_new_string(sbuf)); |
|
|
|
sprint_hex(sbuf, &seed[params.n], params.n); |
|
|
|
json_object_object_add(tg_req, "SK_PRF", json_object_new_string(sbuf)); |
|
|
|
sprint_hex(sbuf, &seed[2*params.n], params.n); |
|
|
|
json_object_object_add(tg_req, "I", json_object_new_string(sbuf)); |
|
|
|
free(sbuf); |
|
|
|
|
|
|
|
sbuf = malloc(2*params.pk_bytes + 1); |
|
|
|
sprint_hex(sbuf, pk, params.pk_bytes); |
|
|
|
sprint_hex(sbuf, pk, params.pk_bytes + XMSS_OID_LEN); |
|
|
|
json_object_object_add(tg_res, "publicKey", json_object_new_string(sbuf)); |
|
|
|
free(sbuf); |
|
|
|
|
|
|
|
vectors_siggen(h->oid, sk, tg_req, tg_res, h->n_samples); |
|
|
|
vectors_siggen(h->oid, sk + XMSS_OID_LEN, tg_req, tg_res, h->n_samples); |
|
|
|
|
|
|
|
json_object_array_add(tgs_req, tg_req); |
|
|
|
json_object_array_add(tgs_res, tg_res); |
|
|
|