net/tls: Add support of AES128-CCM based ciphers
Added support for AES128-CCM based record encryption. AES128-CCM is similar to AES128-GCM. Both of them have same salt/iv/mac size. The notable difference between the two is that while invoking AES128-CCM operation, the salt||nonce (which is passed as IV) has to be prefixed with a hardcoded value '2'. Further, CCM implementation in kernel requires IV passed in crypto_aead_request() to be full '16' bytes. Therefore, the record structure 'struct tls_rec' has been modified to reserve '16' bytes for IV. This works for both GCM and CCM based cipher. Signed-off-by: Vakul Garg <vakul.garg@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
6a23c0a6af
commit
f295b3ae9f
@@ -469,27 +469,32 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,
|
||||
|
||||
switch (crypto_info->cipher_type) {
|
||||
case TLS_CIPHER_AES_GCM_128:
|
||||
optsize = sizeof(struct tls12_crypto_info_aes_gcm_128);
|
||||
break;
|
||||
case TLS_CIPHER_AES_GCM_256: {
|
||||
optsize = crypto_info->cipher_type == TLS_CIPHER_AES_GCM_128 ?
|
||||
sizeof(struct tls12_crypto_info_aes_gcm_128) :
|
||||
sizeof(struct tls12_crypto_info_aes_gcm_256);
|
||||
if (optlen != optsize) {
|
||||
rc = -EINVAL;
|
||||
goto err_crypto_info;
|
||||
}
|
||||
rc = copy_from_user(crypto_info + 1, optval + sizeof(*crypto_info),
|
||||
optlen - sizeof(*crypto_info));
|
||||
if (rc) {
|
||||
rc = -EFAULT;
|
||||
goto err_crypto_info;
|
||||
}
|
||||
optsize = sizeof(struct tls12_crypto_info_aes_gcm_256);
|
||||
break;
|
||||
}
|
||||
case TLS_CIPHER_AES_CCM_128:
|
||||
optsize = sizeof(struct tls12_crypto_info_aes_ccm_128);
|
||||
break;
|
||||
default:
|
||||
rc = -EINVAL;
|
||||
goto err_crypto_info;
|
||||
}
|
||||
|
||||
if (optlen != optsize) {
|
||||
rc = -EINVAL;
|
||||
goto err_crypto_info;
|
||||
}
|
||||
|
||||
rc = copy_from_user(crypto_info + 1, optval + sizeof(*crypto_info),
|
||||
optlen - sizeof(*crypto_info));
|
||||
if (rc) {
|
||||
rc = -EFAULT;
|
||||
goto err_crypto_info;
|
||||
}
|
||||
|
||||
if (tx) {
|
||||
#ifdef CONFIG_TLS_DEVICE
|
||||
rc = tls_set_device_offload(sk, ctx);
|
||||
|
||||
Reference in New Issue
Block a user