crypto: qat - add RSA support to qat driver
PATCH v2 1/3 crypto: qat - add support for MMP FW
In reply to Tadeusz StrukFrom: Pingchao Yang <[email protected]>
Load Modular Math Processor(MMP) firmware into QAT devices to support public key algorithm acceleration.
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 1 + drivers/crypto/qat/qat_common/adf_common_drv.h | 2 + drivers/crypto/qat/qat_common/qat_hal.c | 13 ++++++---- drivers/crypto/qat/qat_common/qat_uclo.c | 27 ++++---------------- .../crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 6 ++++ .../crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h | 1 + 6 files changed, 24 insertions(+), 26 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -0
@@ -135,6 +135,7 @@ struct adf_hw_device_data {struct adf_hw_device_class *dev_class;uint32_t (*get_accel_mask)(uint32_t fuse);uint32_t (*get_ae_mask)(uint32_t fuse); +uint32_t (*get_sram_bar_id)(struct adf_hw_device_data *self);uint32_t (*get_misc_bar_id)(struct adf_hw_device_data *self);uint32_t (*get_etr_bar_id)(struct adf_hw_device_data *self);uint32_t (*get_num_aes)(struct adf_hw_device_data *self);
drivers/crypto/qat/qat_common/adf_common_drv.h +2 -0
@@ -196,4 +196,6 @@ int qat_uclo_wr_all_uimage(struct icp_qat_fw_loader_handle *handle);void qat_uclo_del_uof_obj (struct icp_qat_fw_loader_handle *handle);int qat_uclo_map_uof_obj (struct icp_qat_fw_loader_handle *handle,void *addr_ptr,int mem_size); +void qat_uclo_wr_mimage (struct icp_qat_fw_loader_handle *handle, +void *addr_ptr,int mem_size);#endif
drivers/crypto/qat/qat_common/qat_hal.c +8 -5
@@ -679,21 +679,24 @@ int qat_hal_init(struct adf_accel_dev *accel_dev)struct icp_qat_fw_loader_handle *handle;struct adf_accel_pci *pci_info = &accel_dev->accel_pci_dev;struct adf_hw_device_data *hw_data = accel_dev->hw_device; -struct adf_bar *bar = +struct adf_bar *misc_bar = &pci_info->pci_bars[hw_data->get_misc_bar_id (hw_data)]; +struct adf_bar *sram_bar = + &pci_info->pci_bars[hw_data->get_sram_bar_id (hw_data)]; handle =kzalloc (sizeof (*handle),GFP_KERNEL );if (!handle)return -ENOMEM ; - handle->hal_cap_g_ctl_csr_addr_v = bar->virt_addr + + handle->hal_cap_g_ctl_csr_addr_v = misc_bar->virt_addr +ICP_DH895XCC_CAP_OFFSET ; - handle->hal_cap_ae_xfer_csr_addr_v = bar->virt_addr + + handle->hal_cap_ae_xfer_csr_addr_v = misc_bar->virt_addr +ICP_DH895XCC_AE_OFFSET ; - handle->hal_ep_csr_addr_v = bar->virt_addr +ICP_DH895XCC_EP_OFFSET ; + handle->hal_ep_csr_addr_v = misc_bar->virt_addr + +ICP_DH895XCC_EP_OFFSET ; handle->hal_cap_ae_local_csr_addr_v = handle->hal_cap_ae_xfer_csr_addr_v +LOCAL_TO_XFER_REG_OFFSET ; - + handle->hal_sram_addr_v = sram_bar->virt_addr; handle->hal_handle =kzalloc (sizeof (*handle->hal_handle),GFP_KERNEL );if (!handle->hal_handle) goto out_hal_handle;
drivers/crypto/qat/qat_common/qat_uclo.c +6 -21
@@ -359,28 +359,7 @@ static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle,static int qat_uclo_init_ae_memory (struct icp_qat_fw_loader_handle *handle,struct icp_qat_uof_initmem *init_mem) { -unsigned int i; -struct icp_qat_uof_memvar_attr *mem_val_attr; - - mem_val_attr = - (struct icp_qat_uof_memvar_attr *)((unsigned long )init_mem + -sizeof (struct icp_qat_uof_initmem )); -switch (init_mem->region) { -case ICP_QAT_UOF_SRAM_REGION : -if ((init_mem->addr + init_mem->num_in_bytes) > -ICP_DH895XCC_PESRAM_BAR_SIZE ) { -pr_err ("QAT: initmem on SRAM is out of range" ); -return -EINVAL ; - } -for (i =0 ; i < init_mem->val_attr_num; i++) { -qat_uclo_wr_sram_by_words (handle, - init_mem->addr + - mem_val_attr->offset_in_byte, - &mem_val_attr->value,4 ); - mem_val_attr++; - } -break ;case ICP_QAT_UOF_LMEM_REGION :if (qat_uclo_init_lmem_seg (handle, init_mem))return -EINVAL ;
@@ -990,6 +969,12 @@ out_err:return -EFAULT ; } +void qat_uclo_wr_mimage (struct icp_qat_fw_loader_handle *handle, +void *addr_ptr,int mem_size) +{ +qat_uclo_wr_sram_by_words (handle,0 , addr_ptr,ALIGN (mem_size,4 )); +} +int qat_uclo_map_uof_obj (struct icp_qat_fw_loader_handle *handle,void *addr_ptr,int mem_size) {
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +6 -0
@@ -117,6 +117,11 @@ static uint32_t get_etr_bar_id(struct adf_hw_device_data *self)return ADF_DH895XCC_ETR_BAR ; } +static uint32_t get_sram_bar_id (struct adf_hw_device_data *self) +{ +return ADF_DH895XCC_SRAM_BAR ; +} +static enum dev_sku_info get_sku (struct adf_hw_device_data *self) {int sku = (self->fuses &ADF_DH895XCC_FUSECTL_SKU_MASK )
@@ -219,6 +224,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->get_num_aes = get_num_aes; hw_data->get_etr_bar_id = get_etr_bar_id; hw_data->get_misc_bar_id = get_misc_bar_id; + hw_data->get_sram_bar_id = get_sram_bar_id; hw_data->get_sku = get_sku; hw_data->fw_name =ADF_DH895XCC_FW ; hw_data->init_admin_comms = adf_init_admin_comms;
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h +1 -0
@@ -48,6 +48,7 @@#define ADF_DH895x_HW_DATA_H_/* PCIe configuration space */ +#define ADF_DH895XCC_SRAM_BAR 0#define ADF_DH895XCC_PMISC_BAR 1#define ADF_DH895XCC_ETR_BAR 2#define ADF_DH895XCC_RX_RINGS_OFFSET 8
v2 cover crypto: qat - add RSA support to qat driver
This series adds RSA support to the qat driver.
First patch adds the logic in FW loader to load the Modular Math Processor(MMP) firmware to the device's internal memory.
Second patch adds logic to load MMP firmware from disk.
Third patch adds the actual RSA implementation.
It also contains minor cleanup - namely removes unused TRNG rings.
Once this is accepted updated version of qat_895xcc.bin firmware and the new mmp firmware will follow.
changes in v2:
- add fallback to software for unsupported key lengths.
---
Pingchao Yang (1):
crypto: qat - add support for MMP FW
Tadeusz Struk (2):
crypto: qat - add MMP FW support to accel engine
crypto: qat - Add support for RSA algorithm
drivers/crypto/qat/Kconfig | 2 drivers/crypto/qat/qat_common/Makefile | 1 drivers/crypto/qat/qat_common/adf_accel_devices.h | 3 drivers/crypto/qat/qat_common/adf_accel_engine.c | 42 + drivers/crypto/qat/qat_common/adf_common_drv.h | 10 drivers/crypto/qat/qat_common/adf_init.c | 4 drivers/crypto/qat/qat_common/icp_qat_fw.h | 2 drivers/crypto/qat/qat_common/icp_qat_fw_pke.h | 112 ++++ drivers/crypto/qat/qat_common/qat_algs.c | 5 drivers/crypto/qat/qat_common/qat_asym_algs.c | 583 ++++++++++++++++++++ drivers/crypto/qat/qat_common/qat_crypto.c | 19 - drivers/crypto/qat/qat_common/qat_crypto.h | 2 drivers/crypto/qat/qat_common/qat_hal.c | 13 drivers/crypto/qat/qat_common/qat_uclo.c | 27 - .../crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 7 .../crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h | 2 drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 12 17 files changed, 777 insertions(+), 69 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/icp_qat_fw_pke.h create mode 100644 drivers/crypto/qat/qat_common/qat_asym_algs.c
--
PATCH v2 3/3 crypto: qat - Add support for RSA algorithm
Add RSA support to QAT driver.
Removed unused RNG rings.
--- drivers/crypto/qat/Kconfig | 2 drivers/crypto/qat/qat_common/Makefile | 1 drivers/crypto/qat/qat_common/adf_common_drv.h | 10 drivers/crypto/qat/qat_common/adf_init.c | 4 drivers/crypto/qat/qat_common/icp_qat_fw.h | 2 drivers/crypto/qat/qat_common/icp_qat_fw_pke.h | 112 ++++ drivers/crypto/qat/qat_common/qat_algs.c | 5 drivers/crypto/qat/qat_common/qat_asym_algs.c | 613 ++++++++++++++++++++++++ drivers/crypto/qat/qat_common/qat_crypto.c | 19 - drivers/crypto/qat/qat_common/qat_crypto.h | 2 drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 12 11 files changed, 743 insertions(+), 39 deletions(-) create mode 100644 drivers/crypto/qat/qat_common/icp_qat_fw_pke.h create mode 100644 drivers/crypto/qat/qat_common/qat_asym_algs.c
drivers/crypto/qat/Kconfig +2 -0
@@ -3,6 +3,8 @@ config CRYPTO_DEV_QAT select CRYPTO_AEAD select CRYPTO_AUTHENC select CRYPTO_BLKCIPHER + select CRYPTO_AKCIPHER + select CRYPTO_RSA select CRYPTO_HMAC select CRYPTO_SHA1 select CRYPTO_SHA256
drivers/crypto/qat/qat_common/Makefile +1 -0
@@ -8,6 +8,7 @@ intel_qat-objs := adf_cfg.o \ adf_transport.o \ qat_crypto.o \ qat_algs.o \ + qat_asym_algs.o \ qat_uclo.o \ qat_hal.o
drivers/crypto/qat/qat_common/adf_common_drv.h +9 -1
@@ -55,7 +55,7 @@#define ADF_MAJOR_VERSION 0#define ADF_MINOR_VERSION 1 -#define ADF_BUILD_VERSION 3 +#define ADF_BUILD_VERSION 4#define ADF_DRV_VERSION __stringify(ADF_MAJOR_VERSION) "." \ __stringify(ADF_MINOR_VERSION) "." \ __stringify(ADF_BUILD_VERSION)
@@ -94,6 +94,11 @@ struct service_hndl {int admin; }; +static inline int get_current_node (void ) +{ +return cpu_data (current_thread_info ()->cpu).phys_proc_id; +} +int adf_service_register (struct service_hndl *service);int adf_service_unregister (struct service_hndl *service);
@@ -141,10 +146,13 @@ int qat_crypto_unregister(void);struct qat_crypto_instance *qat_crypto_get_instance_node (int node);void qat_crypto_put_instance (struct qat_crypto_instance *inst);void qat_alg_callback (void *resp); +void qat_alg_asym_callback (void *resp);int qat_algs_init (void );void qat_algs_exit (void );int qat_algs_register (void );int qat_algs_unregister (void ); +int qat_asym_algs_register (void ); +void qat_asym_algs_unregister (void );int qat_hal_init (struct adf_accel_dev *accel_dev);void qat_hal_deinit (struct icp_qat_fw_loader_handle *handle);
drivers/crypto/qat/qat_common/adf_init.c +3 -1
@@ -257,7 +257,7 @@ int adf_dev_start(struct adf_accel_dev *accel_dev)clear_bit (ADF_STATUS_STARTING , &accel_dev->status);set_bit (ADF_STATUS_STARTED , &accel_dev->status); -if (qat_algs_register ()) { +if (qat_algs_register () ||qat_asym_algs_register ()) {dev_err (&GET_DEV (accel_dev),"Failed to register crypto algs\n" );set_bit (ADF_STATUS_STARTING , &accel_dev->status);
@@ -296,6 +296,8 @@ int adf_dev_stop(struct adf_accel_dev *accel_dev)dev_err (&GET_DEV (accel_dev),"Failed to unregister crypto algs\n" ); +qat_asym_algs_unregister (); +list_for_each (list_itr, &service_table) { service = list_entry(list_itr, struct service_hndl, list);if (service->admin)
drivers/crypto/qat/qat_common/icp_qat_fw.h +2 -0
@@ -249,6 +249,8 @@ struct icp_qat_fw_comn_resp {#define QAT_COMN_RESP_CRYPTO_STATUS_BITPOS 7#define QAT_COMN_RESP_CRYPTO_STATUS_MASK 0x1 +#define QAT_COMN_RESP_PKE_STATUS_BITPOS 6 +#define QAT_COMN_RESP_PKE_STATUS_MASK 0x1#define QAT_COMN_RESP_CMP_STATUS_BITPOS 5#define QAT_COMN_RESP_CMP_STATUS_MASK 0x1#define QAT_COMN_RESP_XLAT_STATUS_BITPOS 4
drivers/crypto/qat/qat_common/icp_qat_fw_pke.h new file +112 -0
112 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_algs.c +0 -5
@@ -129,11 +129,6 @@ struct qat_alg_ablkcipher_ctx {spinlock_t lock;/* protects qat_alg_ablkcipher_ctx struct */ }; -static int get_current_node (void ) -{ -return cpu_data (current_thread_info ()->cpu).phys_proc_id; -} -static int qat_get_inter_state_size (enum icp_qat_hw_auth_algo qat_hash_alg) {switch (qat_hash_alg) {
drivers/crypto/qat/qat_common/qat_asym_algs.c new file +613 -0
613 lines not on this page · raw message
drivers/crypto/qat/qat_common/qat_crypto.c +1 -18
@@ -88,12 +88,6 @@ static int qat_crypto_free_instances(struct adf_accel_dev *accel_dev)if (inst->pke_rx)adf_remove_ring (inst->pke_rx); -if (inst->rnd_tx) -adf_remove_ring (inst->rnd_tx); - -if (inst->rnd_rx) -adf_remove_ring (inst->rnd_rx); -list_del (list_ptr);kfree (inst); }
@@ -202,11 +196,6 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev) msg_size, key, NULL, 0, &inst->sym_tx)) goto err; -snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_RND_TX , i); -if (adf_create_ring (accel_dev,SEC , bank, num_msg_asym, - msg_size, key,NULL ,0 , &inst->rnd_tx)) - goto err; - msg_size = msg_size >>1 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_TX , i); if (adf_create_ring(accel_dev, SEC, bank, num_msg_asym,
@@ -220,15 +209,9 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev) &inst->sym_rx)) goto err; -snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_RND_RX , i); -if (adf_create_ring (accel_dev,SEC , bank, num_msg_asym, - msg_size, key, qat_alg_callback,0 , - &inst->rnd_rx)) - goto err; -snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_RX , i);if (adf_create_ring (accel_dev,SEC , bank, num_msg_asym, - msg_size, key, qat_alg_callback,0 , + msg_size, key, qat_alg_asym_callback,0 , &inst->pke_rx)) goto err; }
drivers/crypto/qat/qat_common/qat_crypto.h +0 -2
@@ -57,8 +57,6 @@ struct qat_crypto_instance {struct adf_etr_ring_data *sym_rx;struct adf_etr_ring_data *pke_tx;struct adf_etr_ring_data *pke_rx; -struct adf_etr_ring_data *rnd_tx; -struct adf_etr_ring_data *rnd_rx;struct adf_accel_dev *accel_dev;struct list_head list;unsigned long state;
drivers/crypto/qat/qat_dh895xcc/adf_drv.c +0 -12
@@ -167,12 +167,6 @@ static int adf_dev_configure(struct adf_accel_dev *accel_dev) key, (void *)&val, ADF_DEC)) goto err; - val =4 ; -snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_RND_TX , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) - goto err; - val =8 ;snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_ASYM_RX , i); if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
@@ -185,12 +179,6 @@ static int adf_dev_configure(struct adf_accel_dev *accel_dev) key, (void *)&val, ADF_DEC)) goto err; - val =12 ; -snprintf (key,sizeof (key),ADF_CY "%d" ADF_RING_RND_RX , i); -if (adf_cfg_add_key_value_param (accel_dev,ADF_KERNEL_SEC , - key, (void *)&val,ADF_DEC )) - goto err; - val =ADF_COALESCING_DEF_TIME ;snprintf (key,sizeof (key),ADF_ETRMGR_COALESCE_TIMER_FORMAT , i); if (adf_cfg_add_key_value_param(accel_dev, "Accelerator0",
PATCH v2 2/3 crypto: qat - add MMP FW support to accel engine
In reply to Tadeusz StrukAdd code that loads the MMP firmware
--- drivers/crypto/qat/qat_common/adf_accel_devices.h | 2 + drivers/crypto/qat/qat_common/adf_accel_engine.c | 42 ++++++++++++++++++-- .../crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 .../crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h | 2 + 4 files changed, 42 insertions(+), 5 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +2 -0
@@ -152,6 +152,7 @@ struct adf_hw_device_data {void (*exit_arb)(struct adf_accel_dev *accel_dev);void (*enable_ints)(struct adf_accel_dev *accel_dev);const char *fw_name; +const char *fw_mmp_name;uint32_t pci_dev_id;uint32_t fuses;uint32_t accel_capabilities_mask;
@@ -185,6 +186,7 @@ struct icp_qat_fw_loader_handle;struct adf_fw_loader_data {struct icp_qat_fw_loader_handle *fw_loader;const struct firmware *uof_fw; +const struct firmware *mmp_fw; };struct adf_accel_dev {
drivers/crypto/qat/qat_common/adf_accel_engine.c +37 -5
96 lines not on this page · raw message
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -0
@@ -227,6 +227,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data) hw_data->get_sram_bar_id = get_sram_bar_id; hw_data->get_sku = get_sku; hw_data->fw_name =ADF_DH895XCC_FW ; + hw_data->fw_mmp_name =ADF_DH895XCC_MMP ; hw_data->init_admin_comms = adf_init_admin_comms; hw_data->exit_admin_comms = adf_exit_admin_comms; hw_data->init_arb = adf_init_arb;
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h +2 -0
@@ -85,5 +85,7 @@#define ADF_DH895XCC_ADMINMSGLR_OFFSET (0x3A000 + 0x578)#define ADF_DH895XCC_MAILBOX_BASE_OFFSET 0x20970#define ADF_DH895XCC_MAILBOX_STRIDE 0x1000 +/* FW names */ #define ADF_DH895XCC_FW "qat_895xcc.bin" +#define ADF_DH895XCC_MMP "qat_mmp.bin"#endif
Herbert Xu
maintainerRe: [PATCH v2 3/3] crypto: qat - Add support for RSA algorithm
In reply to Tadeusz Strukdrivers/crypto/qat/qat_common/qat_asym_algs.c line 115
Quoted 5 lines · Tadeusz Struk
drivers/crypto/qat/qat_common/qat_asym_algs.c new file +4
-0+static void qat_rsa_cb (struct icp_qat_fw_pke_resp *resp) +{ +struct akcipher_request *areq = (void *)(__force long )resp->opaque; +struct qat_rsa_request *req =PTR_ALIGN (akcipher_request_ctx (areq),64 );
You need to include the extra alignment space in reqsize.
drivers/crypto/qat/qat_common/qat_asym_algs.c line 487
Quoted 11 lines
drivers/crypto/qat/qat_common/qat_asym_algs.c new file +11
-0+ ctx->key_sz =mpi_get_size (pkey->n); +if (!qat_rsa_enc_fn_id (ctx->key_sz)) { +/* invalid key size provided falling back to sw */ +rsa_free_key (pkey); + ctx->key_sz =0 ; + ctx->n =NULL ; + ctx->e =NULL ; + ctx->d =NULL ; + +pr_info ("QAT: RSA key size not supported by hardware.\n" ); +pr_info ("Falling back to software" );
That's way too verbose for something that could in future be triggered from user-space. Either remove them or use dev_debug.
drivers/crypto/qat/qat_common/qat_asym_algs.c line 488
Quoted 1 line
drivers/crypto/qat/qat_common/qat_asym_algs.c new file +1
-0+ ctx->fallback =crypto_alloc_akcipher ("rsa-generic" ,0 ,0 );
You need to set CRYPTO_ALG_NEED_FALLBACK in the mask here. You should also set it in your cra_flags. Then you can have rsa here instead of rsa-generic.
There is also an issue with reqsize since your fallback's reqsize may be bigger than yours. You'll need to change akcipher first to move the reqsize field into crypto_akcipher. Then you can set the reqsize here.
drivers/crypto/qat/qat_common/qat_asym_algs.c line 517
Quoted 3 lines
drivers/crypto/qat/qat_common/qat_asym_algs.c new file +3
-0+ ret =mpi_read_buffer (pkey->n, ctx->n, ctx->key_sz, &len,NULL ); +if (ret) + goto free_d;
Huh? Why are you converting in and out of MPI? If the hardware wants raw integers, then you should just give the raw numbers to it.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH v2 3/3] crypto: qat - Add support for RSA algorithm
Quoted 9 lines · Herbert Xu
drivers/crypto/qat/qat_common/qat_asym_algs.c line 488
Quoted 1 line
drivers/crypto/qat/qat_common/qat_asym_algs.c new file +1
-0+ ctx->fallback =crypto_alloc_akcipher ("rsa-generic" ,0 ,0 );You need to set
CRYPTO_ALG_NEED_FALLBACKin the mask here. You should also set it in yourcra_flags. Then you can have rsa here instead of rsa-generic.There is also an issue with reqsize since your fallback's reqsize may be bigger than yours. You'll need to change akcipher first to move the reqsize field into
crypto_akcipher. Then you can set the reqsize here.
This is even more complicated because the user can first allocate request and then call setkey causing fallback. I'm now thinking about adding the limitation to rsa generic or I can still use rsa-generic which I know that its ctx is smaller than mine. What do you think?
Quoted 6 lines
Quoted 4 lines
drivers/crypto/qat/qat_common/qat_asym_algs.c line 517
Quoted 4 lines
drivers/crypto/qat/qat_common/qat_asym_algs.c new file +3
-0+ ret =mpi_read_buffer (pkey->n, ctx->n, ctx->key_sz, &len,NULL ); +if (ret) + goto free_d;Huh? Why are you converting in and out of MPI? If the hardware wants raw integers, then you should just give the raw numbers to it.
The rsa_parse_key helper in the rsa generic that parses the key in BER format produces the MPIs.I didn't want to add yet another BER parser here. Should I?
Herbert Xu
maintainerRe: [PATCH v2 3/3] crypto: qat - Add support for RSA algorithm
Quoted 5 lines · Tadeusz Struk
This is even more complicated because the user can first allocate request and then call setkey causing fallback. I'm now thinking about adding the limitation to rsa generic or I can still use rsa-generic which I know that its ctx is smaller than mine. What do you think?
This would preclude any future assembly implementations from being used. Besides this is how we implement fallbacks everywhere else in the crypto API so I don't see why this one should be different.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
drivers/crypto/qat/qat_common/qat_asym_algs.c line 517
Quoted 4 lines
drivers/crypto/qat/qat_common/qat_asym_algs.c new file +3
-0+ ret =mpi_read_buffer (pkey->n, ctx->n, ctx->key_sz, &len,NULL ); +if (ret) + goto free_d;Huh? Why are you converting in and out of MPI? If the hardware wants raw integers, then you should just give the raw numbers to it.
The
rsa_parse_keyhelper in the rsa generic that parses the key in BER format produces the MPIs.I didn't want to add yet another BER parser here. Should I?
I don't see why not. Certainly beats having to go in and out of MPIs.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH v2 3/3] crypto: qat - Add support for RSA algorithm
Quoted 7 lines · Herbert Xu
Quoted 4 lines
This is even more complicated because the user can first allocate request
Quoted 3 lines
and then call setkey causing fallback. I'm now thinking about adding the limitation to rsa generic or I can still use rsa-generic which I know that its ctx is smaller than mine. What do you think?
This would preclude any future assembly implementations from being used. Besides this is how we implement fallbacks everywhere else in the crypto API so I don't see why this one should be different.
Are you ok if I just add the same constrains to rsa-generic?
Quoted 5 lines
Quoted 3 lines
The
rsa_parse_keyhelper in the rsa generic that parses the key in BER formatQuoted 1 line
produces the MPIs.I didn't want to add yet another BER parser here. Should I?
I don't see why not. Certainly beats having to go in and out of MPIs.
Ok will do that.
Thanks,
T
Herbert Xu
maintainerRe: [PATCH v2 3/3] crypto: qat - Add support for RSA algorithm
Quoted 10 lines · Tadeusz Struk
Quoted 7 lines · Herbert Xu
Quoted 4 lines
This is even more complicated because the user can first allocate request
Quoted 3 lines
and then call setkey causing fallback. I'm now thinking about adding the limitation to rsa generic or I can still use rsa-generic which I know that its ctx is smaller than mine. What do you think?
This would preclude any future assembly implementations from being used. Besides this is how we implement fallbacks everywhere else in the crypto API so I don't see why this one should be different.
Are you ok if I just add the same constrains to rsa-generic?
Yes that would work. Of course if any future hardware implementation wanted to support other key sizes we'd have to add a fallback to qat.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH v2 3/3] crypto: qat - Add support for RSA algorithm
Quoted 3 lines · Herbert Xu
Quoted 1 line
Are you ok if I just add the same constrains to rsa-generic?
Yes that would work. Of course if any future hardware implementation wanted to support other key sizes we'd have to add a fallback to qat.
That's ok. I like the lazy approach for now.
Thanks Herbert.