Example #1
0
static int
testsimpel(void)
{
	const char str42[] = "2a";
	MINT *t2;
	char *s;

	mp_madd(c42, c1, t0);
	testmcmp(c43, t0, "madd0");
	mp_madd(t0, c1, t0);
	testmcmp(c44, t0, "madd1");
	mp_msub(t0, c1, t0);
	testmcmp(c43, t0, "msub0");
	mp_msub(t0, c1, t0);
	testmcmp(c42, t0, "msub1");
	mp_move(c42, t0);
	testmcmp(c42, t0, "move0");

	t2 = mp_xtom(str42);
	testmcmp(c42, t2, "xtom");
	s = mp_mtox(t2);
	if (strcmp(str42, s) == 0)
		printf("ok %d - %s\n", ++tnr, "mtox0");
	else
		printf("not ok %d - %s\n", ++tnr, "mtox0");
	mp_mfree(t2);
}
Example #2
0
MINT *xtom(char *key) { return (mp_xtom(key)); }
Example #3
0
                *k++ = r;
        }
	mp_mfree(z);
        mp_mfree(a);
}

/*
 * get common key from my secret key and his public key
 */
void
common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey)
{
        MINT *public;
        MINT *secret;
        MINT *common;
	MINT *modulus = mp_xtom(HEXMODULUS);

        public = mp_xtom(xpublic);
        secret = mp_xtom(xsecret);
        common = mp_itom(0);
        mp_pow(public, secret, modulus, common);
        extractdeskey(common, deskey);
        extractideakey(common, ideakey);
	des_set_odd_parity(deskey);
        mp_mfree(common);
        mp_mfree(secret);
        mp_mfree(public);
	mp_mfree(modulus);
}

/*