Пример #1
0
void TDES_ECB(unsigned char *inBlk, int len, unsigned char *outBlk,  unsigned char *key, int keyLen, int mode)
{
    int i = 0;

    for (i = 0; i < (len/DES_BLOCK_SIZE); i++) 
    {
        TDES(inBlk, outBlk, key, keyLen, mode);
        inBlk   += DES_BLOCK_SIZE;
        outBlk  += DES_BLOCK_SIZE;
    }

    return;
}
Пример #2
0
int  main(int argc, char* argv[])
{
	unsigned char urandom[BUFFERLENGTH];
	unsigned char uencode[BUFFERLENGTH];
	unsigned char ukey[17];
	unsigned char uclient[16];
	memset(urandom, 0, BUFFERLENGTH);
	memset(uencode, 0, BUFFERLENGTH);
	memset(ukey, 0, 17);

	//process arguments
	if(argc != 4) {
		return 4;			// 2: error number of arguments
	}
	char *client_hex = argv[1];		// length bigger than BUFFERLENGTH
	memcpy(ukey, argv[2], 16);
	memcpy(urandom, argv[3], 16);

	TDES(ukey, 1, uencode, urandom, 16);
	hex2bin(client_hex, uclient);

	return (memcmp(uencode, uclient, 16) == 0 ? 0 : 5);		// 1: error compare
}