/* xfrm_user.c: User interface to configure xfrm engine. * * Copyright (C) 2002 David S. Miller (davem@redhat.com) * * Changes: * Mitsuru KANDA @USAGI * Kazunori MIYAZAWA @USAGI * Kunihiro Ishiguro <kunihiro@ipinfusion.com> * IPv6 support * */#include<linux/module.h>#include<linux/kernel.h>#include<linux/types.h>#include<linux/slab.h>#include<linux/socket.h>#include<linux/string.h>#include<linux/net.h>#include<linux/skbuff.h>#include<linux/netlink.h>#include<linux/rtnetlink.h>#include<linux/pfkeyv2.h>#include<linux/ipsec.h>#include<linux/init.h>#include<linux/security.h>#include<net/sock.h>#include<net/xfrm.h>#include<asm/uaccess.h>staticstructsock*xfrm_nl;staticintverify_one_alg(structrtattr**xfrma,enumxfrm_attr_type_ttype){structrtattr*rt=xfrma[type-1];structxfrm_algo*algp;intlen;if(!rt)return0;len=(rt->rta_len-sizeof(*rt))-sizeof(*algp);if(len<0)return-EINVAL;algp=RTA_DATA(rt);len-=(algp->alg_key_len+7U)/8;if(len<0)return-EINVAL;switch(type){caseXFRMA_ALG_AUTH:if(!algp->alg_key_len&&strcmp(algp->alg_name,"digest_null")!=0)return-EINVAL;break;caseXFRMA_ALG_CRYPT:if(!algp->alg_key_len&&strcmp(algp->alg_name,"cipher_null")!=0)return-EINVAL;break;caseXFRMA_ALG_COMP:/* Zero length keys are legal. */break;default:return-EINVAL;};algp->alg_name[CRYPTO_MAX_ALG_NAME-1]='\0';return0;}staticintverify_encap_tmpl(structrtattr**xfrma){structrtattr*rt=xfrma[XFRMA_ENCAP-1];structxfrm_encap_tmpl*encap;if(!rt)return0;if((rt->rta_len-sizeof(*rt))<sizeof(*encap))return-EINVAL;return0;}staticintverify_newsa_info(structxfrm_usersa_info*p,structrtattr**xfrma){interr;err=-EINVAL;switch(p->family){case