static int esp_init_state(struct xfrm_state *x, void *args) 
static int esp_init_state(struct xfrm_state *x) 
static int esp_init_state(struct xfrm_state *x, void *args){	struct esp_data *esp = NULL;	/* null auth and encryption can have zero length keys */	if (x->aalg) {		if (x->aalg->alg_key_len > 512)			goto error;	}	if (x->ealg == NULL)		goto error;	esp = kmalloc(sizeof(*esp), GFP_KERNEL);	if (esp == NULL)		return -ENOMEM;	memset(esp, 0, sizeof(*esp));	if (x->aalg) {		struct xfrm_algo_desc *aalg_desc;		esp->auth.key = x->aalg->alg_key;		esp->auth.key_len = (x->aalg->alg_key_len+7)/8;		esp->auth.tfm = crypto_alloc_tfm(x->aalg->alg_name, 0);		if (esp->auth.tfm == NULL)			goto error;		esp->auth.icv = esp_hmac_digest;		aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name, 0);		BUG_ON(!aalg_desc);		if (aalg_desc->uinfo.auth.icv_fullbits/8 !=		    crypto_tfm_alg_digestsize(esp->auth.tfm)) {			NETDEBUG(printk(KERN_INFO "ESP: %s digestsize %u != %hu\n",			       x->aalg->alg_name,			       crypto_tfm_alg_digestsize(esp->auth.tfm),			       aalg_desc->uinfo.auth.icv_fullbits/8));			goto error;		}		esp->auth.icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8;		esp->auth.icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits/8;		esp->auth.work_icv = kmalloc(esp->auth.icv_full_len, GFP_KERNEL);		if (!esp->auth.work_icv)			goto error;	}	esp->conf.key = x->ealg->alg_key;	esp->conf.key_len = (x->ealg->alg_key_len+7)/8;	if (x->props.ealgo == SADB_EALG_NULL)		esp->conf.tfm = crypto_alloc_tfm(x->ealg->alg_name, CRYPTO_TFM_MODE_ECB);	else		esp->conf.tfm = crypto_alloc_tfm(x->ealg->alg_name, CRYPTO_TFM_MODE_CBC);	if (esp->conf.tfm == NULL)		goto error;	esp->conf.ivlen = crypto_tfm_alg_ivsize(esp->conf.tfm);	esp->conf.padlen = 0;	if (esp->conf.ivlen) {		esp->conf.ivec = kmalloc(esp->conf.ivlen, GFP_KERNEL);		if (unlikely(esp->conf.ivec == NULL))			goto error;		get_random_bytes(esp->conf.ivec, esp->conf.ivlen);	}	if (crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len))		goto error;	x->props.header_len = sizeof(struct ip_esp_hdr) + esp->conf.ivlen;	if (x->props.mode)		x->props.header_len += sizeof(struct iphdr);	if (x->encap) {		struct xfrm_encap_tmpl *encap = x->encap;		switch (encap->encap_type) {		default:			goto error;		case UDP_ENCAP_ESPINUDP:			x->props.header_len += sizeof(struct udphdr);			break;		case UDP_ENCAP_ESPINUDP_NON_IKE:			x->props.header_len += sizeof(struct udphdr) + 2 * sizeof(u32);			break;		}	}	x->data = esp;	x->props.trailer_len = esp4_get_max_size(x, 0) - x->props.header_len;	return 0;error:	x->data = esp;	esp_destroy(x);	x->data = NULL;	return -EINVAL;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/72cb6962a91f2af9eef69a06198e1949c10259ae/esp4.c/clean/net/ipv4/esp4.c