| 1770 | } |
| 1771 | |
| 1772 | static int |
| 1773 | sym_crypto_apply(struct sym_crypto_data *data, |
| 1774 | struct rte_table_action_sym_crypto_config *cfg, |
| 1775 | struct rte_table_action_sym_crypto_params *p) |
| 1776 | { |
| 1777 | const struct rte_crypto_cipher_xform *cipher_xform = NULL; |
| 1778 | const struct rte_crypto_auth_xform *auth_xform = NULL; |
| 1779 | const struct rte_crypto_aead_xform *aead_xform = NULL; |
| 1780 | struct rte_crypto_sym_xform *xform = p->xform; |
| 1781 | struct rte_cryptodev_sym_session *session; |
| 1782 | int ret; |
| 1783 | |
| 1784 | memset(data, 0, sizeof(*data)); |
| 1785 | |
| 1786 | while (xform) { |
| 1787 | if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) { |
| 1788 | cipher_xform = &xform->cipher; |
| 1789 | |
| 1790 | if (cipher_xform->iv.length > |
| 1791 | RTE_TABLE_ACTION_SYM_CRYPTO_IV_SIZE_MAX) |
| 1792 | return -ENOMEM; |
| 1793 | if (cipher_xform->iv.offset != |
| 1794 | RTE_TABLE_ACTION_SYM_CRYPTO_IV_OFFSET) |
| 1795 | return -EINVAL; |
| 1796 | |
| 1797 | ret = get_block_size(xform, cfg->cryptodev_id); |
| 1798 | if (ret < 0) |
| 1799 | return -1; |
| 1800 | data->block_size = (uint16_t)ret; |
| 1801 | data->op_mask |= CRYPTO_OP_MASK_CIPHER; |
| 1802 | |
| 1803 | data->cipher_auth.cipher_iv_len = |
| 1804 | cipher_xform->iv.length; |
| 1805 | data->cipher_auth.cipher_iv_data_offset = (uint16_t) |
| 1806 | p->cipher_auth.cipher_iv_update.offset; |
| 1807 | data->cipher_auth.cipher_iv_update_len = (uint16_t) |
| 1808 | p->cipher_auth.cipher_iv_update.length; |
| 1809 | |
| 1810 | rte_memcpy(data->iv_aad_data, |
| 1811 | p->cipher_auth.cipher_iv.val, |
| 1812 | p->cipher_auth.cipher_iv.length); |
| 1813 | |
| 1814 | data->direction = cipher_xform->op; |
| 1815 | |
| 1816 | } else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) { |
| 1817 | auth_xform = &xform->auth; |
| 1818 | if (auth_xform->iv.length > |
| 1819 | RTE_TABLE_ACTION_SYM_CRYPTO_IV_SIZE_MAX) |
| 1820 | return -ENOMEM; |
| 1821 | data->op_mask |= CRYPTO_OP_MASK_AUTH; |
| 1822 | |
| 1823 | data->cipher_auth.auth_iv_len = auth_xform->iv.length; |
| 1824 | data->cipher_auth.auth_iv_data_offset = (uint16_t) |
| 1825 | p->cipher_auth.auth_iv_update.offset; |
| 1826 | data->cipher_auth.auth_iv_update_len = (uint16_t) |
| 1827 | p->cipher_auth.auth_iv_update.length; |
| 1828 | data->digest_len = auth_xform->digest_length; |
| 1829 |
no test coverage detected