Compare commits
No commits in common. "db1d6a1eda4b42762b3128b97840cabe1fd41827" and "b2310900795892713b7ed4b2fa1706f96d73dea0" have entirely different histories.
db1d6a1eda
...
b231090079
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
struct param_t {
|
struct param_t {
|
||||||
uint8_t oid;
|
uint8_t oid;
|
||||||
const char *name;
|
|
||||||
const char *hash;
|
const char *hash;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned n_samples;
|
unsigned n_samples;
|
||||||
@ -42,44 +41,34 @@ void vectors_keygen(uint32_t oid, json_object *jreq, json_object *jres, uint32_t
|
|||||||
xmss_parse_oid(¶ms, oid);
|
xmss_parse_oid(¶ms, oid);
|
||||||
|
|
||||||
unsigned char seed[params.n * 3];
|
unsigned char seed[params.n * 3];
|
||||||
unsigned char pk[params.pk_bytes + XMSS_OID_LEN];
|
unsigned char pk[params.pk_bytes];
|
||||||
unsigned char sk[params.sk_bytes + XMSS_OID_LEN];
|
unsigned char sk[params.sk_bytes];
|
||||||
char *sbuf;
|
char *sbuf;
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
tcs_req = json_object_new_array();
|
tcs_req = json_object_new_array();
|
||||||
tcs_res = 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++) {
|
for (size_t i=0; i<n_samples; i++) {
|
||||||
tc_req = json_object_new_object();
|
tc_req = json_object_new_object();
|
||||||
tc_res = json_object_new_object();
|
tc_res = json_object_new_object();
|
||||||
|
|
||||||
getentropy(seed, 3*params.n);
|
getentropy(seed, 3*params.n);
|
||||||
xmssmt_core_seed_keypair(¶ms, &pk[XMSS_OID_LEN], &sk[XMSS_OID_LEN], seed);
|
xmssmt_core_seed_keypair(¶ms, pk, sk, seed);
|
||||||
|
|
||||||
json_object_object_add(tc_req, "tcId", json_object_new_int(i+1));
|
json_object_object_add(tc_req, "tcId", json_object_new_int(i+1));
|
||||||
sbuf = malloc(2*params.n + 1);
|
sbuf = malloc(2*3*params.n + 1);
|
||||||
sprint_hex(sbuf, seed, params.n);
|
sprint_hex(sbuf, seed, 3*params.n);
|
||||||
json_object_object_add(tc_req, "S_XMSS", json_object_new_string(sbuf));
|
json_object_object_add(tc_req, "seed", 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);
|
free(sbuf);
|
||||||
|
|
||||||
json_object_object_add(tc_res, "tcId", json_object_new_int(i+1));
|
json_object_object_add(tc_res, "tcId", json_object_new_int(i+1));
|
||||||
sbuf = malloc(2*params.pk_bytes + 1);
|
sbuf = malloc(2*params.pk_bytes + 1);
|
||||||
sprint_hex(sbuf, pk, params.pk_bytes + XMSS_OID_LEN);
|
sprint_hex(sbuf, pk, params.pk_bytes);
|
||||||
json_object_object_add(tc_res, "publicKey", json_object_new_string(sbuf));
|
json_object_object_add(tc_res, "publicKey", json_object_new_string(sbuf));
|
||||||
free(sbuf);
|
free(sbuf);
|
||||||
|
|
||||||
sbuf = malloc(2*params.sk_bytes + 1);
|
sbuf = malloc(2*params.sk_bytes + 1);
|
||||||
sprint_hex(sbuf, sk, params.sk_bytes + XMSS_OID_LEN);
|
sprint_hex(sbuf, sk, params.sk_bytes);
|
||||||
json_object_object_add(tc_res, "secretKey", json_object_new_string(sbuf));
|
json_object_object_add(tc_res, "secretKey", json_object_new_string(sbuf));
|
||||||
free(sbuf);
|
free(sbuf);
|
||||||
|
|
||||||
@ -118,7 +107,6 @@ void keygen_KAT(const struct param_t *h) {
|
|||||||
json_object_object_add(tg_req, "tgId", json_object_new_int(1));
|
json_object_object_add(tg_req, "tgId", json_object_new_int(1));
|
||||||
json_object_object_add(tg_req, "testType", json_object_new_string("AFT"));
|
json_object_object_add(tg_req, "testType", json_object_new_string("AFT"));
|
||||||
json_object_object_add(tg_req, "OID", json_object_new_int(h->oid));
|
json_object_object_add(tg_req, "OID", json_object_new_int(h->oid));
|
||||||
json_object_object_add(tg_req, "param", json_object_new_string(h->name));
|
|
||||||
|
|
||||||
// Response file
|
// Response file
|
||||||
json_object_object_add(tg_res, "tgId", json_object_new_int(1));
|
json_object_object_add(tg_res, "tgId", json_object_new_int(1));
|
||||||
@ -206,8 +194,8 @@ void siggen_KAT(const struct param_t *h) {
|
|||||||
|
|
||||||
char buf[256], *sbuf;
|
char buf[256], *sbuf;
|
||||||
unsigned char seed[params.n * 3];
|
unsigned char seed[params.n * 3];
|
||||||
unsigned char pk[params.pk_bytes + XMSS_OID_LEN];
|
unsigned char pk[params.pk_bytes];
|
||||||
unsigned char sk[params.sk_bytes + XMSS_OID_LEN];
|
unsigned char sk[params.sk_bytes];
|
||||||
|
|
||||||
jreq = json_object_new_object();
|
jreq = json_object_new_object();
|
||||||
jres = json_object_new_object();
|
jres = json_object_new_object();
|
||||||
@ -225,30 +213,25 @@ void siggen_KAT(const struct param_t *h) {
|
|||||||
json_object_object_add(tg_req, "tgId", json_object_new_int(1));
|
json_object_object_add(tg_req, "tgId", json_object_new_int(1));
|
||||||
json_object_object_add(tg_req, "testType", json_object_new_string("AFT"));
|
json_object_object_add(tg_req, "testType", json_object_new_string("AFT"));
|
||||||
json_object_object_add(tg_req, "OID", json_object_new_int(h->oid));
|
json_object_object_add(tg_req, "OID", json_object_new_int(h->oid));
|
||||||
json_object_object_add(tg_req, "param", json_object_new_string(h->name));
|
|
||||||
|
|
||||||
// Response file
|
// Response file
|
||||||
json_object_object_add(tg_res, "tgId", json_object_new_int(1));
|
json_object_object_add(tg_res, "tgId", json_object_new_int(1));
|
||||||
json_object_object_add(tg_res, "OID", json_object_new_int(h->oid));
|
json_object_object_add(tg_req, "OID", json_object_new_int(h->oid));
|
||||||
|
|
||||||
getentropy(seed, 3*params.n);
|
getentropy(seed, 3*params.n);
|
||||||
xmssmt_core_seed_keypair(¶ms, pk + XMSS_OID_LEN, sk + XMSS_OID_LEN, seed);
|
xmssmt_core_seed_keypair(¶ms, pk, sk, seed);
|
||||||
|
|
||||||
sbuf = malloc(2*params.n + 1);
|
sbuf = malloc(2*3*params.n + 1);
|
||||||
sprint_hex(sbuf, seed, params.n);
|
sprint_hex(sbuf, seed, 3*params.n);
|
||||||
json_object_object_add(tg_req, "S_XMSS", json_object_new_string(sbuf));
|
json_object_object_add(tg_req, "seed", 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);
|
free(sbuf);
|
||||||
|
|
||||||
sbuf = malloc(2*params.pk_bytes + 1);
|
sbuf = malloc(2*params.pk_bytes + 1);
|
||||||
sprint_hex(sbuf, pk, params.pk_bytes + XMSS_OID_LEN);
|
sprint_hex(sbuf, pk, params.pk_bytes);
|
||||||
json_object_object_add(tg_res, "publicKey", json_object_new_string(sbuf));
|
json_object_object_add(tg_res, "publicKey", json_object_new_string(sbuf));
|
||||||
free(sbuf);
|
free(sbuf);
|
||||||
|
|
||||||
vectors_siggen(h->oid, sk + XMSS_OID_LEN, tg_req, tg_res, h->n_samples);
|
vectors_siggen(h->oid, sk, tg_req, tg_res, h->n_samples);
|
||||||
|
|
||||||
json_object_array_add(tgs_req, tg_req);
|
json_object_array_add(tgs_req, tg_req);
|
||||||
json_object_array_add(tgs_res, tg_res);
|
json_object_array_add(tgs_res, tg_res);
|
||||||
@ -269,20 +252,20 @@ void siggen_KAT(const struct param_t *h) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
const struct param_t OIDs[] = {
|
const struct param_t OIDs[] = {
|
||||||
{0x01, "XMSS-SHA2_10_256", "SHA256-N32", 10, 10}, // H10
|
{0x01, "SHA256-N32", 10, 10}, // H10
|
||||||
{0x0D, "XMSS-SHA2_10_192", "SHA256-N24", 10, 10}, // H10
|
{0x0D, "SHA256-N24", 10, 10}, // H10
|
||||||
{0x10, "XMSS-SHAKE256_10_256", "SHAKE256-N32", 10, 10}, // H10
|
{0x10, "SHAKE256-N32", 10, 10}, // H10
|
||||||
{0x13, "XMSS-SHAKE256_10_192", "SHA2KE56-N24", 10, 10}, // H10
|
{0x13, "SHAKE256-N24", 10, 10}, // H10
|
||||||
|
|
||||||
{0x02, "XMSS-SHA2_16_256", "SHA256-N32", 16, 5}, // H16
|
{0x02, "SHA256-N32", 16, 5}, // H16
|
||||||
{0x0E, "XMSS-SHA2_16_192", "SHA256-N24", 16, 5}, // H16
|
{0x0E, "SHA256-N24", 16, 5}, // H16
|
||||||
{0x11, "XMSS-SHAKE256_16_256", "SHAKE256-N32", 16, 5}, // H16
|
{0x11, "SHAKE256-N32", 16, 5}, // H16
|
||||||
{0x14, "XMSS-SHAKE256_16_192", "SHAKE256-N24", 16, 5}, // H16
|
{0x14, "SHAKE256-N24", 16, 5}, // H16
|
||||||
|
|
||||||
{0x03, "XMSS-SHA2_20_256", "SHA256-N32", 20, 3}, // H20
|
{0x03, "SHA256-N32", 20, 3}, // H20
|
||||||
{0x0F, "XMSS-SHA2_20_192", "SHA256-N24", 20, 3}, // H20
|
{0x0F, "SHA256-N24", 20, 3}, // H20
|
||||||
{0x12, "XMSS-SHAKE256_20_256", "SHAKE256-N32", 20, 3}, // H20
|
{0x12, "SHAKE256-N32", 20, 3}, // H20
|
||||||
{0x15, "XMSS-SHAKE256_20_192", "SHAKE256-N24", 20, 3} // H20
|
{0x15, "SHAKE256-N24", 20, 3} // H20
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i=0; i<12; i++) {
|
for (size_t i=0; i<12; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user