for (start = jiffies, bcount = 0; ((jiffies - start) / HZ) < sec; bcount++) { sg[0].page = virt_to_page(p); sg[0].offset = offset_in_page(p); sg[0].length = speed[i].blen; 
if (sec) ret = test_cipher_jiffies(tfm, enc, p, speed[i].blen, sec); else ret = test_cipher_cycles(tfm, enc, p, speed[i].blen); 
static void test_cipher_speed(char *algo, int mode, int enc, unsigned int sec,			      struct cipher_testvec *template,			      unsigned int tcount, struct cipher_speed *speed){	unsigned int ret, i, j, iv_len;	unsigned char *key, *p, iv[128];	struct crypto_tfm *tfm;	struct scatterlist sg[8];	unsigned long start, bcount;	const char *e, *m;	if (enc == ENCRYPT)	        e = "encryption";	else		e = "decryption";	if (mode == MODE_ECB)		m = "ECB";	else		m = "CBC";	printk("\ntesting speed of %s %s %s\n", algo, m, e);	if (mode)		tfm = crypto_alloc_tfm(algo, 0);	else		tfm = crypto_alloc_tfm(algo, CRYPTO_TFM_MODE_CBC);	if (tfm == NULL) {		printk("failed to load transform for %s %s\n", algo, m);		return;	}	for (i = 0; speed[i].klen != 0; i++) {		if ((speed[i].blen + speed[i].klen) > TVMEMSIZE) {			printk("template (%u) too big for tvmem (%u)\n",			       speed[i].blen + speed[i].klen, TVMEMSIZE);			goto out;		}		printk("test %u (%d bit key, %d byte blocks): ", i,		       speed[i].klen * 8, speed[i].blen);		memset(tvmem, 0xff, speed[i].klen + speed[i].blen);		/* set key, plain text and IV */		key = (unsigned char *)tvmem;		for (j = 0; j < tcount; j++) {			if (template[j].klen == speed[i].klen) {				key = template[j].key;				break;			}		}		p = (unsigned char *)tvmem + speed[i].klen;		ret = crypto_cipher_setkey(tfm, key, speed[i].klen);		if (ret) {			printk("setkey() failed flags=%x\n", tfm->crt_flags);			goto out;		}		if (!mode) {			iv_len = crypto_tfm_alg_ivsize(tfm);			memset(&iv, 0xff, iv_len);			crypto_cipher_set_iv(tfm, iv, iv_len);		}		for (start = jiffies, bcount = 0;		    ((jiffies - start) / HZ) < sec; bcount++) {			sg[0].page = virt_to_page(p);			sg[0].offset = offset_in_page(p);			sg[0].length = speed[i].blen;			if (enc)				ret = crypto_cipher_encrypt(tfm, sg, sg, speed[i].blen);			else				ret = crypto_cipher_decrypt(tfm, sg, sg, speed[i].blen);			if (ret) {				printk("%s () failed flags=%x\n", e, tfm->crt_flags);				goto out;			}		}		printk("%lu operations in %u seconds (%lu bytes)\n",		       bcount, sec, bcount * speed[i].blen);	}out:	crypto_free_tfm(tfm);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/6a17944ca12229036a6d8d48be1b5eb51204fcf8/tcrypt.c/buggy/crypto/tcrypt.c