| 3783 | } |
| 3784 | |
| 3785 | static struct rte_crypto_sym_xform * |
| 3786 | parse_table_action_cipher_auth(struct rte_table_action_sym_crypto_params *p, |
| 3787 | uint8_t *key, uint32_t max_key_len, char **tokens, |
| 3788 | uint32_t n_tokens, uint32_t encrypt, uint32_t *used_n_tokens) |
| 3789 | { |
| 3790 | struct rte_crypto_sym_xform *xform_cipher; |
| 3791 | struct rte_crypto_sym_xform *xform_auth; |
| 3792 | int status; |
| 3793 | size_t len; |
| 3794 | |
| 3795 | if (n_tokens < 13 || |
| 3796 | strcmp(tokens[7], "auth_algo") || |
| 3797 | strcmp(tokens[9], "auth_key") || |
| 3798 | strcmp(tokens[11], "digest_size")) |
| 3799 | return NULL; |
| 3800 | |
| 3801 | xform_auth = calloc(1, sizeof(*xform_auth)); |
| 3802 | if (xform_auth == NULL) |
| 3803 | return NULL; |
| 3804 | |
| 3805 | xform_auth->type = RTE_CRYPTO_SYM_XFORM_AUTH; |
| 3806 | xform_auth->auth.op = encrypt ? RTE_CRYPTO_AUTH_OP_GENERATE : |
| 3807 | RTE_CRYPTO_AUTH_OP_VERIFY; |
| 3808 | |
| 3809 | /* auth_algo */ |
| 3810 | status = rte_cryptodev_get_auth_algo_enum(&xform_auth->auth.algo, |
| 3811 | tokens[8]); |
| 3812 | if (status < 0) |
| 3813 | goto error_exit; |
| 3814 | |
| 3815 | /* auth_key */ |
| 3816 | len = strlen(tokens[10]); |
| 3817 | if (len / 2 > max_key_len) { |
| 3818 | status = -ENOMEM; |
| 3819 | goto error_exit; |
| 3820 | } |
| 3821 | |
| 3822 | status = parse_hex_string(tokens[10], key, (uint32_t *)&len); |
| 3823 | if (status < 0) |
| 3824 | goto error_exit; |
| 3825 | |
| 3826 | xform_auth->auth.key.data = key; |
| 3827 | xform_auth->auth.key.length = (uint16_t)len; |
| 3828 | |
| 3829 | key += xform_auth->auth.key.length; |
| 3830 | max_key_len -= xform_auth->auth.key.length; |
| 3831 | |
| 3832 | if (strcmp(tokens[11], "digest_size")) |
| 3833 | goto error_exit; |
| 3834 | |
| 3835 | status = parser_read_uint16(&xform_auth->auth.digest_length, |
| 3836 | tokens[12]); |
| 3837 | if (status < 0) |
| 3838 | goto error_exit; |
| 3839 | |
| 3840 | xform_cipher = parse_table_action_cipher(p, key, max_key_len, tokens, |
| 3841 | 7, encrypt, used_n_tokens); |
| 3842 | if (xform_cipher == NULL) |
no test coverage detected