diff options
Diffstat (limited to 'net/sctp/auth.c')
| -rw-r--r-- | net/sctp/auth.c | 63 | 
1 files changed, 26 insertions, 37 deletions
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 8c4fa5dec82..0e8529113dc 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c @@ -16,9 +16,8 @@   * See the GNU General Public License for more details.   *   * You should have received a copy of the GNU General Public License - * along with GNU CC; see the file COPYING.  If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * along with GNU CC; see the file COPYING.  If not, see + * <http://www.gnu.org/licenses/>.   *   * Please send any bug reports or fixes you make to the   * email address(es): @@ -42,7 +41,7 @@ static struct sctp_hmac sctp_hmac_list[SCTP_AUTH_NUM_HMACS] = {  	},  	{  		.hmac_id = SCTP_AUTH_HMAC_ID_SHA1, -		.hmac_name="hmac(sha1)", +		.hmac_name = "hmac(sha1)",  		.hmac_len = SCTP_SHA1_SIG_SIZE,  	},  	{ @@ -52,7 +51,7 @@ static struct sctp_hmac sctp_hmac_list[SCTP_AUTH_NUM_HMACS] = {  #if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE)  	{  		.hmac_id = SCTP_AUTH_HMAC_ID_SHA256, -		.hmac_name="hmac(sha256)", +		.hmac_name = "hmac(sha256)",  		.hmac_len = SCTP_SHA256_SIG_SIZE,  	}  #endif @@ -164,7 +163,7 @@ static int sctp_auth_compare_vectors(struct sctp_auth_bytes *vector1,  		 * lead-zero padded.  If it is not, it  		 * is automatically larger numerically.  		 */ -		for (i = 0; i < abs(diff); i++ ) { +		for (i = 0; i < abs(diff); i++) {  			if (longer[i] != 0)  				return diff;  		} @@ -227,9 +226,9 @@ static struct sctp_auth_bytes *sctp_auth_make_local_vector(  				    gfp_t gfp)  {  	return sctp_auth_make_key_vector( -				    (sctp_random_param_t*)asoc->c.auth_random, -				    (sctp_chunks_param_t*)asoc->c.auth_chunks, -				    (sctp_hmac_algo_param_t*)asoc->c.auth_hmacs, +				    (sctp_random_param_t *)asoc->c.auth_random, +				    (sctp_chunks_param_t *)asoc->c.auth_chunks, +				    (sctp_hmac_algo_param_t *)asoc->c.auth_hmacs,  				    gfp);  } @@ -387,14 +386,13 @@ nomem:   */  int sctp_auth_asoc_init_active_key(struct sctp_association *asoc, gfp_t gfp)  { -	struct net *net = sock_net(asoc->base.sk);  	struct sctp_auth_bytes	*secret;  	struct sctp_shared_key *ep_key;  	/* If we don't support AUTH, or peer is not capable  	 * we don't need to do anything.  	 */ -	if (!net->sctp.auth_enable || !asoc->peer.auth_capable) +	if (!asoc->ep->auth_enable || !asoc->peer.auth_capable)  		return 0;  	/* If the key_id is non-zero and we couldn't find an @@ -441,16 +439,16 @@ struct sctp_shared_key *sctp_auth_get_shkey(   */  int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp)  { -	struct net *net = sock_net(ep->base.sk);  	struct crypto_hash *tfm = NULL;  	__u16   id; -	/* if the transforms are already allocted, we are done */ -	if (!net->sctp.auth_enable) { +	/* If AUTH extension is disabled, we are done */ +	if (!ep->auth_enable) {  		ep->auth_hmacs = NULL;  		return 0;  	} +	/* If the transforms are already allocated, we are done */  	if (ep->auth_hmacs)  		return 0; @@ -500,8 +498,7 @@ void sctp_auth_destroy_hmacs(struct crypto_hash *auth_hmacs[])  	if (!auth_hmacs)  		return; -	for (i = 0; i < SCTP_AUTH_NUM_HMACS; i++) -	{ +	for (i = 0; i < SCTP_AUTH_NUM_HMACS; i++) {  		if (auth_hmacs[i])  			crypto_free_hash(auth_hmacs[i]);  	} @@ -539,18 +536,14 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc)  	for (i = 0; i < n_elt; i++) {  		id = ntohs(hmacs->hmac_ids[i]); -		/* Check the id is in the supported range */ -		if (id > SCTP_AUTH_HMAC_ID_MAX) { -			id = 0; -			continue; -		} - -		/* See is we support the id.  Supported IDs have name and -		 * length fields set, so that we can allocated and use +		/* Check the id is in the supported range. And +		 * see if we support the id.  Supported IDs have name and +		 * length fields set, so that we can allocate and use  		 * them.  We can safely just check for name, for without the  		 * name, we can't allocate the TFM.  		 */ -		if (!sctp_hmac_list[id].hmac_name) { +		if (id > SCTP_AUTH_HMAC_ID_MAX || +		    !sctp_hmac_list[id].hmac_name) {  			id = 0;  			continue;  		} @@ -652,15 +645,15 @@ static int __sctp_auth_cid(sctp_cid_t chunk, struct sctp_chunks_param *param)  	 */  	for (i = 0; !found && i < len; i++) {  		switch (param->chunks[i]) { -		    case SCTP_CID_INIT: -		    case SCTP_CID_INIT_ACK: -		    case SCTP_CID_SHUTDOWN_COMPLETE: -		    case SCTP_CID_AUTH: +		case SCTP_CID_INIT: +		case SCTP_CID_INIT_ACK: +		case SCTP_CID_SHUTDOWN_COMPLETE: +		case SCTP_CID_AUTH:  			break; -		    default: +		default:  			if (param->chunks[i] == chunk) -			    found = 1; +				found = 1;  			break;  		}  	} @@ -671,12 +664,10 @@ static int __sctp_auth_cid(sctp_cid_t chunk, struct sctp_chunks_param *param)  /* Check if peer requested that this chunk is authenticated */  int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc)  { -	struct net  *net;  	if (!asoc)  		return 0; -	net = sock_net(asoc->base.sk); -	if (!net->sctp.auth_enable || !asoc->peer.auth_capable) +	if (!asoc->ep->auth_enable || !asoc->peer.auth_capable)  		return 0;  	return __sctp_auth_cid(chunk, asoc->peer.peer_chunks); @@ -685,12 +676,10 @@ int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc)  /* Check if we requested that peer authenticate this chunk. */  int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc)  { -	struct net *net;  	if (!asoc)  		return 0; -	net = sock_net(asoc->base.sk); -	if (!net->sctp.auth_enable) +	if (!asoc->ep->auth_enable)  		return 0;  	return __sctp_auth_cid(chunk,  | 
