Skip to content

Commit

Permalink
MIP6: modified handling authenticator length
Browse files Browse the repository at this point in the history
      reported by Yukio.Akisada@jp.yokogawa.com
  • Loading branch information
t-momose committed Aug 27, 2002
1 parent b43f1d1 commit d93755c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
20 changes: 12 additions & 8 deletions kame/sys/netinet6/mip6.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $KAME: mip6.c,v 1.159 2002/08/26 12:59:13 keiichi Exp $ */
/* $KAME: mip6.c,v 1.160 2002/08/27 03:31:39 t-momose Exp $ */

/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
Expand Down Expand Up @@ -2659,7 +2659,7 @@ mip6_is_valid_bu(ip6, ip6mu, ip6mulen, mopt, hoa_sa, coa_sa)
mip6_nodekey_t home_nodekey, coa_nodekey;
mip6_home_cookie_t home_cookie;
mip6_careof_cookie_t careof_cookie;
u_int8_t key_bu[SHA1_RESULTLEN]; /* Stated as 'Kbu' in the spec */
u_int8_t key_bu[MIP6_KBU_LEN]; /* Stated as 'Kbu' in the spec */
u_int8_t authdata[SHA1_RESULTLEN];
u_int16_t cksum_backup;
HMAC_CTX hmac_ctx;
Expand Down Expand Up @@ -2748,13 +2748,14 @@ mip6_hexdump("CN: Auth: ", sizeof(ip6->ip6_dst), &ip6->ip6_dst);
#ifdef RR_DBG
mip6_hexdump("CN: Auth: ", (u_int8_t *)mopt->mopt_auth - (u_int8_t *)ip6mu, ip6mu);
#endif
restlen = ip6mulen - (((u_int8_t *)mopt->mopt_auth - (u_int8_t *)ip6mu) + ((struct ip6m_opt_authdata *)mopt->mopt_auth)->ip6moau_len + 2);

/* Must exclude authentication option */
restlen = ip6mulen - (((u_int8_t *)mopt->mopt_auth - (u_int8_t *)ip6mu) + MOPT_AUTH_LEN(mopt) + 2);
if (restlen > 0) {
hmac_loop(&hmac_ctx,
mopt->mopt_auth
+ ((struct ip6m_opt_authdata *)mopt->mopt_auth)->ip6moau_len + 2, restlen);
mopt->mopt_auth + MOPT_AUTH_LEN(mopt) + 2, restlen);
#ifdef RR_DBG
mip6_hexdump("CN: Auth: ", restlen, mopt->mopt_auth + ((struct ip6m_opt_authdata *)mopt->mopt_auth)->ip6moau_len + 2);
mip6_hexdump("CN: Auth: ", restlen, mopt->mopt_auth + MOPT_AUTH_LEN(mopt) + 2);
#endif
}
bzero(authdata, sizeof(authdata));
Expand All @@ -2764,7 +2765,7 @@ mip6_hexdump("CN: Auth Data: ", sizeof(authdata), authdata);
#endif
ip6mu->ip6mu_cksum = cksum_backup;

return (bcmp(mopt->mopt_auth + 2, authdata, sizeof(authdata)));
return (bcmp(mopt->mopt_auth + 2, authdata, MOPT_AUTH_LEN(mopt)));
}

int
Expand Down Expand Up @@ -2866,10 +2867,13 @@ mip6_calculate_kbu(home_cookie, careof_cookie, key_bu)
u_int8_t *key_bu; /* needs at least SHA1_RESULTLEN bytes */
{
SHA1_CTX sha1_ctx;
u_int8_t result[SHA1_RESULTLEN];

SHA1Init(&sha1_ctx);
SHA1Update(&sha1_ctx, (caddr_t)home_cookie, sizeof(*home_cookie));
SHA1Update(&sha1_ctx, (caddr_t)careof_cookie, sizeof(*careof_cookie));
SHA1Final(key_bu, &sha1_ctx);
SHA1Final(result, &sha1_ctx);
/* First 96 bit */
bcopy(result, key_bu, MIP6_KBU_LEN);
}
#endif /* MIP6_DRAFT18 */
10 changes: 6 additions & 4 deletions kame/sys/netinet6/mip6_pktproc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $KAME: mip6_pktproc.c,v 1.43 2002/08/26 12:59:13 keiichi Exp $ */
/* $KAME: mip6_pktproc.c,v 1.44 2002/08/27 03:31:39 t-momose Exp $ */

/*
* Copyright (C) 2002 WIDE Project. All rights reserved.
Expand Down Expand Up @@ -1354,7 +1354,7 @@ mip6_ip6mci_create(pktopt_mobility, mbu)
return (0);
}

#define AUTH_SIZE (sizeof(struct ip6m_opt_authdata) + SHA1_RESULTLEN)
#define AUTH_SIZE (sizeof(struct ip6m_opt_authdata) + MIP6_KBU_LEN)

int
mip6_ip6mu_create(pktopt_mobility, src, dst, sc)
Expand All @@ -1370,7 +1370,8 @@ mip6_ip6mu_create(pktopt_mobility, src, dst, sc)
struct mip6_bu *mbu, *hrmbu;
int need_rr = 0;
HMAC_CTX hmac_ctx;
u_int8_t key_bu[SHA1_RESULTLEN]; /* Stated as 'Kbu' in the spec */
u_int8_t key_bu[MIP6_KBU_LEN]; /* Stated as 'Kbu' in the spec */
u_int8_t result[SHA1_RESULTLEN];
#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
long time_second = time.tv_sec;
#endif
Expand Down Expand Up @@ -1575,7 +1576,8 @@ mip6_hexdump("MN: Auth: ", bu_size + nonce_size, ip6mu);
mip6_hexdump("MN: Auth: ", auth_size - AUTH_SIZE, (u_int8_t *)ip6mu + bu_size + nonce_size + AUTH_SIZE);
#endif
}
hmac_result(&hmac_ctx, (u_int8_t *)(mopt_auth + 1));
hmac_result(&hmac_ctx, result);
bcopy(result, (u_int8_t *)(mopt_auth + 1), MIP6_KBU_LEN);
#ifdef RR_DBG
mip6_hexdump("MN: Authdata: ", SHA1_RESULTLEN, (u_int8_t *)(mopt_auth + 1));
#endif
Expand Down
6 changes: 4 additions & 2 deletions kame/sys/netinet6/mip6_var.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $KAME: mip6_var.h,v 1.49 2002/08/26 12:59:13 keiichi Exp $ */
/* $KAME: mip6_var.h,v 1.50 2002/08/27 03:31:39 t-momose Exp $ */

/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
Expand Down Expand Up @@ -64,7 +64,7 @@ typedef u_int8_t mip6_nodekey_t[MIP6_NODEKEY_SIZE];
typedef u_int8_t mip6_cookie_t[MIP6_COOKIE_SIZE];
typedef u_int8_t mip6_home_cookie_t[HOME_COOKIE_SIZE];
typedef u_int8_t mip6_careof_cookie_t[CAREOF_COOKIE_SIZE];

#define MIP6_KBU_LEN 16

/* Callout table for MIP6 structures */
struct mip6_timeout {
Expand Down Expand Up @@ -271,6 +271,8 @@ struct mip6_mobility_options {
#define MOPT_AUTHDATA 0x0008
#define MOPT_REFRESH 0x0010

#define MOPT_AUTH_LEN(mopt) (int)(*(mopt->mopt_auth + 1))

/*
* the list entry to hold the destination addresses which do not use a
* home address as a source address when communicating.
Expand Down

0 comments on commit d93755c

Please sign in to comment.