END_TEST START_TEST(check_signet_signature_verification) { char *fp; const char *org_keys = "check_org.keys"; unsigned char signature[ED25519_SIG_SIZE]; ED25519_KEY *orgkey; int res; signet_t *org_signet; _crypto_init(); org_signet = dime_sgnt_signet_create_w_keys(SIGNET_TYPE_ORG, org_keys); ck_assert_msg(org_signet != NULL, "Failure to create signet with keys file.\n"); orgkey = dime_keys_signkey_fetch(org_keys); ck_assert_msg(orgkey != NULL, "Failure to fetch private signing key from keys file.\n"); res = dime_sgnt_sig_crypto_sign(org_signet, orgkey); ck_assert_msg(res == 0, "Failure to create organizational cryptographic signet signature.\n"); fp = dime_sgnt_fingerprint_crypto(org_signet); ck_assert_msg(fp != NULL, "Failed to fingerprint organiational signet.\n"); res = ed25519_sign_data((const unsigned char *)fp, strlen(fp), orgkey, signature); ck_assert_msg(res == 0, "Failed to provided data with ed25519 key.\n"); res = dime_sgnt_msg_sig_verify(org_signet, signature, (const unsigned char *)fp, strlen(fp)); ck_assert_msg(res == 1, "Failed to verify signature using signet.\n"); fprintf(stderr, "Signet signature verification check complete.\n"); }
END_TEST START_TEST(check_ed25519_signatures) { ED25519_KEY *key; ed25519_signature sigbuf; unsigned char *rdata; size_t dlens[] = { 16, 128, 1024, 65535 }; size_t rsize, last_min = 1; int res; res = crypto_init(); ck_assert_msg(!res, "Crypto initialization routine failed.\n"); key = generate_ed25519_keypair(); ck_assert_msg((key != NULL), "ed25519 signature/verification check failed: could not generate key pair.\n"); for (size_t i = 0; i < (sizeof(dlens) / sizeof(dlens[0])); i++) { for (size_t j = 0; j < N_SIGNATURE_TIER_TESTS; j++) { rdata = gen_random_data(last_min, dlens[i], &rsize); memset(sigbuf, 0, sizeof(sigbuf)); ck_assert_msg((rdata != NULL), "ed25519 signature/verification check failed: could not generate random data.\n"); ed25519_sign_data(rdata, rsize, key, sigbuf); res = ed25519_verify_sig(rdata, rsize, key, sigbuf); ck_assert_msg((res == 1), "ed25519 signature/verification check failed: signature verification failed (%d).\n", res); free(rdata); } last_min = dlens[i]; } free_ed25519_key(key); fprintf(stderr, "ed25519 signature/verification check completed.\n"); }