Esempio n. 1
0
int main(int argc, char *argv[])
{
	struct pluto_crypto_req r;
	struct pcr_skeycalc_v2_r *skr = &r.pcr_d.dhv2;
	struct pcr_skeyid_q    *skq = &r.pcr_d.dhq;
	char *story;

	progname = argv[0];
	cur_debugging = DBG_CRYPT;

	/* initialize list of moduli */
	init_crypto();

	INIT_WIRE_ARENA(*skq);

	skq->auth = tc2_auth;
	skq->prf_hash = tc2_hash;
	skq->integ_hash = tc2_hash;
	skq->oakley_group = tc2_oakleygroup;
	skq->init = tc2_init;
	skq->keysize = tc2_encrypter->keydeflen / BITS_PER_BYTE;

#define copydatlen(field, data, len) { \
		chunk_t tchunk;           \
		setchunk(tchunk, data, len); \
		WIRE_CLONE_CHUNK(*skq, field, tchunk); \
	}

	copydatlen(ni, tc2_ni, tc2_ni_len);
	copydatlen(nr, tc2_nr, tc2_nr_len);
	copydatlen(gi, tc2_gi, tc2_gi_len);
	copydatlen(gr, tc2_gr, tc2_gr_len);
	copydatlen(secret, tc2_secret, tc2_secret_len);
	copydatlen(icookie, tc2_icookie, tc2_icookie_len);
	copydatlen(rcookie, tc2_rcookie, tc2_rcookie_len);

#define dumpdat(field) \
	libreswan_DBG_dump(#field,      \
			   WIRE_CHUNK_PTR(*skq, field), \
			   skq->field.len);

	dumpdat(icookie);
	dumpdat(rcookie);
	dumpdat(ni);
	dumpdat(nr);
	dumpdat(gi);
	dumpdat(gr);
	dumpdat(secret);

	fflush(stdout);
	fflush(stderr);

	calc_dh_v2(&r, &story);

	printf("\noutput: %s\n", story);

	fflush(stdout);
	fflush(stderr);

#define dumpskr(FOO) { void *FOO = WIRE_CHUNK_PTR(*skr, FOO); \
		       libreswan_DBG_dump(#FOO, FOO, skr->FOO.len); \
}

	dumpskr(shared);
	dumpskr(skeyseed);
	dumpskr(skeyid_d);
	dumpskr(skeyid_ai);
	dumpskr(skeyid_ar);
	dumpskr(skeyid_ei);
	dumpskr(skeyid_er);
	dumpskr(skeyid_pi);
	dumpskr(skeyid_pr);
	exit(0);
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
	struct pluto_crypto_req r;
	struct pcr_skeycalc_v2 *skr = &r.pcr_d.dhv2;
	struct pcr_skeyid_q    *skq = &r.pcr_d.dhq;

	progname = argv[0];
	cur_debugging = DBG_CRYPT;
	
	/* initialize list of moduli */
	init_crypto();

	skq->thespace.start = 0;
	skq->thespace.len   = sizeof(skq->space);
	skq->auth = tc2_auth;
	skq->prf_hash = tc2_hash;
	skq->integ_hash = tc2_hash;
	skq->oakley_group = tc2_oakleygroup;
	skq->init = tc2_init;
	skq->keysize = tc2_encrypter->keydeflen/BITS_PER_BYTE;

#define copydatlen(field, data, len) do { \
		chunk_t tchunk;           \
		setchunk(tchunk, data, len); \
		pluto_crypto_copychunk(&skq->thespace, skq->space \
				       , &skq->field, tchunk); }   \
		while(0)

	copydatlen(ni, tc2_ni, tc2_ni_len);
	copydatlen(nr, tc2_nr, tc2_nr_len);
	copydatlen(gi, tc2_gi, tc2_gi_len);
	copydatlen(gr, tc2_gr, tc2_gr_len);
	copydatlen(secret, tc2_secret, tc2_secret_len);
	copydatlen(icookie, tc2_icookie, tc2_icookie_len);
	copydatlen(rcookie, tc2_rcookie, tc2_rcookie_len);

#define dumpdat(field) \
	libreswan_DBG_dump(#field,	\
			  wire_chunk_ptr(skq, &skq->field), \
			  skq->field.len);

	dumpdat(icookie);
	dumpdat(rcookie);
	dumpdat(ni);
	dumpdat(nr);
	dumpdat(gi);
	dumpdat(gr);
	dumpdat(secret);

	fflush(stdout);
	fflush(stderr);
	
	calc_dh_v2(&r);

	printf("\noutput:\n");

	fflush(stdout);
	fflush(stderr);

#define dumpskr(FOO) { void *FOO = wire_chunk_ptr(skr, &skr->FOO);\
		libreswan_DBG_dump(#FOO, FOO, skr->FOO.len); \
	}

	dumpskr(shared);
	dumpskr(skeyseed);
	dumpskr(skeyid_d);
	dumpskr(skeyid_ai);
	dumpskr(skeyid_ar);
	dumpskr(skeyid_ei);
	dumpskr(skeyid_er);
	dumpskr(skeyid_pi);
	dumpskr(skeyid_pr);
	exit(0);
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
	struct pluto_crypto_req r;
	struct pcr_skeyid_r *skr = &r.pcr_d.dhr;
	struct pcr_skeyid_q *skq = &r.pcr_d.dhq;

	progname = argv[0];

	/* initialize list of moduli */
	init_crypto();

	INIT_WIRE_ARENA(*skq);

	skq->auth     = tc2_auth;
	skq->prf_hash = tc2_hash;
	skq->oakley_group = tc2_oakleygroup;
	skq->init = tc2_init;
	skq->keysize = tc2_encrypter->keydeflen / BITS_PER_BYTE;

#define copydatlen(field, data, len) { \
		chunk_t tchunk;           \
		setchunk(tchunk, data, len); \
		WIRE_CLONE_CHUNK(*skq, field, tchunk); \
	}

	copydatlen(ni, tc2_ni, tc2_ni_len);
	copydatlen(nr, tc2_nr, tc2_nr_len);
	copydatlen(gi, tc2_gi, tc2_gi_len);
	copydatlen(gr, tc2_gr, tc2_gr_len);
	copydatlen(secret, tc2_secret, tc2_secret_len);
	copydatlen(icookie, tc2_icookie, tc2_icookie_len);
	copydatlen(rcookie, tc2_rcookie, tc2_rcookie_len);

#define dumpdat(field) \
	libreswan_DBG_dump(#field,      \
			   WIRE_CHUNK_PTR(*skq, field), \
			   skq->field.len);

	dumpdat(icookie);
	dumpdat(rcookie);
	dumpdat(ni);
	dumpdat(nr);
	dumpdat(gi);
	dumpdat(gr);
	dumpdat(secret);

	fflush(stdout);
	fflush(stderr);

	calc_dh_iv(&r);	/* ??? NSS may fail */

	printf("\noutput:\n");

	{
		void *shared = WIRE_CHUNK_PTR(*skr, shared);

		libreswan_DBG_dump("shared", shared, skr->shared.len);
	}

	exit(4);
}