iproute2: allow to specify truncation bits on auth algo
Subsystems (2)
PATCH 1/1 iproute2: allow to specify truncation bits on auth algo
Hi,
here is a patch against iproute2 to allow user to set a state with a specific auth length.
Example:
$ ip xfrm state add src 10.16.0.72 dst 10.16.0.121 proto ah spi 0x10000000 auth-trunc "sha256" "azertyuiopqsdfghjklmwxcvbn123456" 96 mode tunnel
$ ip xfrm state
src 10.16.0.72 dst 10.16.0.121
proto ah spi 0x10000000 reqid 0 mode tunnel
replay-window 0
auth-trunc hmac(sha256)
0x617a6572747975696f707173646667686a6b6c6d77786376626e313233343536 96
sel src 0.0.0.0/0 dst 0.0.0.0/0Regards,
Nicolas
Quoted 1 line
From
522ed7348cdf3b6f501af2a5a5d989de1696565aMon Sep 17 00:00:00 2001
From: Nicolas Dichtel <[email protected]>
Date: Thu, 23 Dec 2010 06:48:12 -0500
Subject: [PATCH] iproute2: allow to specify truncation bits on auth algo
Attribute XFRMA_ALG_AUTH_TRUNC can be used to specify truncation bits, so we add a new algo type: auth-trunc.
Signed-off-by Nicolas Dichtel <[email protected]>
--- ip/ipxfrm.c | 28 +++++++++++++++++++++++++++- ip/xfrm_state.c | 48 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 59 insertions(+), 17 deletions(-)
ip/ipxfrm.c +27 -1
@@ -155,6 +155,7 @@ const char *strxf_xfrmproto(__u8 proto)static const struct typeent algo_types[]= { {"enc" ,XFRMA_ALG_CRYPT }, {"auth" ,XFRMA_ALG_AUTH }, {"comp" ,XFRMA_ALG_COMP }, {"aead" ,XFRMA_ALG_AEAD }, + {"auth-trunc" ,XFRMA_ALG_AUTH_TRUNC }, {NULL ,-1 } };
@@ -570,6 +571,25 @@ static void xfrm_aead_print(struct xfrm_algo_aead *algo, int len,fprintf (fp,"%s" , _SL_); } +static void xfrm_auth_trunc_print (struct xfrm_algo_auth *algo,int len, +FILE *fp,const char *prefix) +{ +struct { +struct xfrm_algo algo; +char key[algo->alg_key_len /8 ]; + } base; + +memcpy (base.algo.alg_name, algo->alg_name,sizeof (base.algo.alg_name)); + base.algo.alg_key_len = algo->alg_key_len; +memcpy (base.algo.alg_key, algo->alg_key, algo->alg_key_len /8 ); + +__xfrm_algo_print (&base.algo,XFRMA_ALG_AUTH_TRUNC , len, fp, prefix,0 ); + +fprintf (fp," %d" , algo->alg_trunc_len); + +fprintf (fp,"%s" , _SL_); +} +static void xfrm_tmpl_print (struct xfrm_user_tmpl *tmpls,int len,__u16 family,FILE *fp,const char *prefix) {
@@ -677,12 +697,18 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family,fprintf (fp,"\tmark %d/0x%x\n" , m->v, m->m); } -if (tb[XFRMA_ALG_AUTH ]) { +if (tb[XFRMA_ALG_AUTH ] && !tb[XFRMA_ALG_AUTH_TRUNC ]) {struct rtattr *rta = tb[XFRMA_ALG_AUTH ];xfrm_algo_print ((struct xfrm_algo *)RTA_DATA (rta),XFRMA_ALG_AUTH ,RTA_PAYLOAD (rta), fp, prefix); } +if (tb[XFRMA_ALG_AUTH_TRUNC ]) { +struct rtattr *rta = tb[XFRMA_ALG_AUTH_TRUNC ]; +xfrm_auth_trunc_print ((struct xfrm_algo_auth *)RTA_DATA (rta), +RTA_PAYLOAD (rta), fp, prefix); + } +if (tb[XFRMA_ALG_AEAD ]) {struct rtattr *rta = tb[XFRMA_ALG_AEAD ]; xfrm_aead_print((struct xfrm_algo_aead *)RTA_DATA(rta),
ip/xfrm_state.c +32 -16
87 lines not on this page · raw message
Signature · 1 line
1.5.6.5