p = hash_tv[i].plaintext; sg[0].page = virt_to_page(p); sg[0].offset = offset_in_page(p); sg[0].length = hash_tv[i].psize; 
sg_set_buf(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); 
static void test_hash(char *algo, struct hash_testvec *template,		      unsigned int tcount){	char *p;	unsigned int i, j, k, temp;	struct scatterlist sg[8];	char result[64];	struct crypto_tfm *tfm;	struct hash_testvec *hash_tv;	unsigned int tsize;	printk("\ntesting %s\n", algo);	tsize = sizeof(struct hash_testvec);	tsize *= tcount;	if (tsize > TVMEMSIZE) {		printk("template (%u) too big for tvmem (%u)\n", tsize, TVMEMSIZE);		return;	}	memcpy(tvmem, template, tsize);	hash_tv = (void *)tvmem;	tfm = crypto_alloc_tfm(algo, 0);	if (tfm == NULL) {		printk("failed to load transform for %s\n", algo);		return;	}	for (i = 0; i < tcount; i++) {		printk("test %u:\n", i + 1);		memset(result, 0, 64);		p = hash_tv[i].plaintext;		sg[0].page = virt_to_page(p);		sg[0].offset = offset_in_page(p);		sg[0].length = hash_tv[i].psize;		crypto_digest_init(tfm);		if (tfm->crt_u.digest.dit_setkey) {			crypto_digest_setkey(tfm, hash_tv[i].key,					     hash_tv[i].ksize);		}		crypto_digest_update(tfm, sg, 1);		crypto_digest_final(tfm, result);		hexdump(result, crypto_tfm_alg_digestsize(tfm));		printk("%s\n",		       memcmp(result, hash_tv[i].digest,			      crypto_tfm_alg_digestsize(tfm)) ?		       "fail" : "pass");	}	printk("testing %s across pages\n", algo);	/* setup the dummy buffer first */	memset(xbuf, 0, XBUFSIZE);	j = 0;	for (i = 0; i < tcount; i++) {		if (hash_tv[i].np) {			j++;			printk("test %u:\n", j);			memset(result, 0, 64);			temp = 0;			for (k = 0; k < hash_tv[i].np; k++) {				memcpy(&xbuf[IDX[k]],				       hash_tv[i].plaintext + temp,				       hash_tv[i].tap[k]);				temp += hash_tv[i].tap[k];				p = &xbuf[IDX[k]];				sg[k].page = virt_to_page(p);				sg[k].offset = offset_in_page(p);				sg[k].length = hash_tv[i].tap[k];			}			crypto_digest_digest(tfm, sg, hash_tv[i].np, result);			hexdump(result, crypto_tfm_alg_digestsize(tfm));			printk("%s\n",			       memcmp(result, hash_tv[i].digest,				      crypto_tfm_alg_digestsize(tfm)) ?			       "fail" : "pass");		}	}	crypto_free_tfm(tfm);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/378f058cc49bcda7fa63d3cd86d2f9a0a5188b1c/tcrypt.c/clean/crypto/tcrypt.c