X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fcrypto%2Fvirtio%2Fvirtio_cryptodev.c;h=e7fb71a64c6646a70edfab38c00b8e33fb24609a;hb=d33fb7f939e6fb9c7882b57e9c3c0fab68c16874;hp=4bae3b865797b6c01f038406545f8ac80e946d4f;hpb=725d2a7fbf717d9a6189ac9b49bad2b4f5391a60;p=dpdk.git diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c index 4bae3b8657..e7fb71a64c 100644 --- a/drivers/crypto/virtio/virtio_cryptodev.c +++ b/drivers/crypto/virtio/virtio_cryptodev.c @@ -514,7 +514,6 @@ static struct rte_cryptodev_ops virtio_crypto_dev_ops = { .queue_pair_setup = virtio_crypto_qp_setup, .queue_pair_release = virtio_crypto_qp_release, - .queue_pair_count = NULL, /* Crypto related operations */ .sym_session_get_size = virtio_crypto_sym_get_session_private_size, @@ -1210,7 +1209,7 @@ static int virtio_crypto_sym_pad_op_ctrl_req( struct virtio_crypto_op_ctrl_req *ctrl, struct rte_crypto_sym_xform *xform, bool is_chainned, - uint8_t **cipher_key_data, uint8_t **auth_key_data, + uint8_t *cipher_key_data, uint8_t *auth_key_data, struct virtio_crypto_session *session) { int ret; @@ -1220,6 +1219,12 @@ virtio_crypto_sym_pad_op_ctrl_req( /* Get cipher xform from crypto xform chain */ cipher_xform = virtio_crypto_get_cipher_xform(xform); if (cipher_xform) { + if (cipher_xform->key.length > VIRTIO_CRYPTO_MAX_KEY_SIZE) { + VIRTIO_CRYPTO_SESSION_LOG_ERR( + "cipher key size cannot be longer than %u", + VIRTIO_CRYPTO_MAX_KEY_SIZE); + return -1; + } if (cipher_xform->iv.length > VIRTIO_CRYPTO_MAX_IV_SIZE) { VIRTIO_CRYPTO_SESSION_LOG_ERR( "cipher IV size cannot be longer than %u", @@ -1241,7 +1246,8 @@ virtio_crypto_sym_pad_op_ctrl_req( return -1; } - *cipher_key_data = cipher_xform->key.data; + memcpy(cipher_key_data, cipher_xform->key.data, + cipher_xform->key.length); session->iv.offset = cipher_xform->iv.offset; session->iv.length = cipher_xform->iv.length; @@ -1254,13 +1260,20 @@ virtio_crypto_sym_pad_op_ctrl_req( struct virtio_crypto_alg_chain_session_para *para = &(ctrl->u.sym_create_session.u.chain.para); if (auth_xform->key.length) { + if (auth_xform->key.length > + VIRTIO_CRYPTO_MAX_KEY_SIZE) { + VIRTIO_CRYPTO_SESSION_LOG_ERR( + "auth key size cannot be longer than %u", + VIRTIO_CRYPTO_MAX_KEY_SIZE); + return -1; + } para->hash_mode = VIRTIO_CRYPTO_SYM_HASH_MODE_AUTH; para->u.mac_param.auth_key_len = (uint32_t)auth_xform->key.length; para->u.mac_param.hash_result_len = auth_xform->digest_length; - - *auth_key_data = auth_xform->key.data; + memcpy(auth_key_data, auth_xform->key.data, + auth_xform->key.length); } else { para->hash_mode = VIRTIO_CRYPTO_SYM_HASH_MODE_PLAIN; para->u.hash_param.hash_result_len = @@ -1310,8 +1323,8 @@ virtio_crypto_sym_configure_session( struct virtio_crypto_session *session; struct virtio_crypto_op_ctrl_req *ctrl_req; enum virtio_crypto_cmd_id cmd_id; - uint8_t *cipher_key_data = NULL; - uint8_t *auth_key_data = NULL; + uint8_t cipher_key_data[VIRTIO_CRYPTO_MAX_KEY_SIZE] = {0}; + uint8_t auth_key_data[VIRTIO_CRYPTO_MAX_KEY_SIZE] = {0}; struct virtio_crypto_hw *hw; struct virtqueue *control_vq; @@ -1355,7 +1368,7 @@ virtio_crypto_sym_configure_session( = VIRTIO_CRYPTO_SYM_OP_ALGORITHM_CHAINING; ret = virtio_crypto_sym_pad_op_ctrl_req(ctrl_req, - xform, true, &cipher_key_data, &auth_key_data, session); + xform, true, cipher_key_data, auth_key_data, session); if (ret < 0) { VIRTIO_CRYPTO_SESSION_LOG_ERR( "padding sym op ctrl req failed"); @@ -1373,7 +1386,7 @@ virtio_crypto_sym_configure_session( ctrl_req->u.sym_create_session.op_type = VIRTIO_CRYPTO_SYM_OP_CIPHER; ret = virtio_crypto_sym_pad_op_ctrl_req(ctrl_req, xform, - false, &cipher_key_data, &auth_key_data, session); + false, cipher_key_data, auth_key_data, session); if (ret < 0) { VIRTIO_CRYPTO_SESSION_LOG_ERR( "padding sym op ctrl req failed"); @@ -1427,7 +1440,7 @@ crypto_virtio_pci_probe( { struct rte_cryptodev_pmd_init_params init_params = { .name = "", - .socket_id = rte_socket_id(), + .socket_id = pci_dev->device.numa_node, .private_data_size = sizeof(struct virtio_crypto_hw) }; char name[RTE_CRYPTODEV_NAME_MAX_LEN];