Esempio n. 1
0
void
main(void)
{

	blf_ctx c;
	char    key[] = "AAAAA";
	char    key2[] = "abcdefghijklmnopqrstuvwxyz";

	u_int32_t data[10];
	u_int32_t data2[] =
	{0x424c4f57l, 0x46495348l};

	u_int16_t i;

	/* First test */
	for (i = 0; i < 10; i++)
		data[i] = i;

	blf_key(&c, (u_int8_t *) key, 5);
	blf_enc(&c, data, 5);
	blf_dec(&c, data, 1);
	blf_dec(&c, data + 2, 4);
	printf("Should read as 0 - 9.\n");
	report(data, 10);

	/* Second test */
	blf_key(&c, (u_int8_t *) key2, strlen(key2));
	blf_enc(&c, data2, 1);
	printf("\nShould read as: 0x324ed0fe 0xf413a203.\n");
	report(data2, 2);
	blf_dec(&c, data2, 1);
	report(data2, 2);
}
Esempio n. 2
0
void wtcc_blowfish(u8 *key, int keylen, int keytable, u8 *data, int datasz, int enc) {
    blf_ctx bfx;
    int     i;

    printf("- use keytable %u and key: ", keytable);
    for(i = 0; i < keylen; i++) {
        printf("%02x", key[i]);
    }
    printf("\n");

    wtcc_blowfish_key(&bfx, key, keylen, keytable);

    // NO padding!
    // datasz = (datasz + 7) & (~7);

    if(debug) {
        printf("- DEBUG wtcc_blowfish before (0x%x bytes):\n", datasz);
        show_dump(data, datasz, stdout);
    }

    if(enc == BF_ENCRYPT) {
        blf_enc(&bfx, (void *)data, datasz / 8);
    } else {
        blf_dec(&bfx, (void *)data, datasz / 8);
    }

    if(debug) {
        printf("- DEBUG wtcc_blowfish after:\n");
        show_dump(data, datasz, stdout);
    }
}
Esempio n. 3
0
long CBlowfish_DeCode(const char* src,char* dest,unsigned long len)
{
	unsigned int i;
	for (i=0;i<len;i++)
	dest[i]=src[i];
	blf_dec(&c,(unsigned long*)dest,len/8);
	return CODE_SUCCESS;

}