/* This option gets or sets the list of HMAC algorithms that the local endpoint requires the peer to use.  */
static int sctp_setsockopt_hmac_ident(struct sock *sk, char __user *optval, unsigned int optlen)
/* This option gets or sets the list of HMAC algorithms that the local endpoint requires the peer to use.  */
static int sctp_setsockopt_hmac_ident(struct sock *sk, char __user *optval, unsigned int optlen)
{
	struct sctp_hmacalgo *hmacs;
	u32 idents;
	int err;
	if (!sctp_auth_enable)
		return -EACCES;
	if (optlen < sizeof(struct sctp_hmacalgo))
		return -EINVAL;
	hmacs = kmalloc(optlen, GFP_KERNEL);
	if (!hmacs)
		return -ENOMEM;
	if (copy_from_user(hmacs, optval, optlen)) {
		err = -EFAULT;
		goto out;
	}
	idents = hmacs->shmac_num_idents;
	if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS ||
	    (idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo))) {
		err = -EINVAL;
		goto out;
	}
	err = sctp_auth_ep_set_hmacs(sctp_sk(sk)->ep, hmacs);
out:
	kfree(hmacs);
	return err;
}