| 3864 | } |
| 3865 | |
| 3866 | static struct rte_crypto_sym_xform * |
| 3867 | parse_table_action_aead(struct rte_table_action_sym_crypto_params *p, |
| 3868 | uint8_t *key, uint32_t max_key_len, char **tokens, |
| 3869 | uint32_t n_tokens, uint32_t encrypt, uint32_t *used_n_tokens) |
| 3870 | { |
| 3871 | struct rte_crypto_sym_xform *xform_aead; |
| 3872 | int status; |
| 3873 | size_t len; |
| 3874 | |
| 3875 | if (n_tokens < 11 || strcmp(tokens[1], "aead_algo") || |
| 3876 | strcmp(tokens[3], "aead_key") || |
| 3877 | strcmp(tokens[5], "aead_iv") || |
| 3878 | strcmp(tokens[7], "aead_aad") || |
| 3879 | strcmp(tokens[9], "digest_size")) |
| 3880 | return NULL; |
| 3881 | |
| 3882 | xform_aead = calloc(1, sizeof(*xform_aead)); |
| 3883 | if (xform_aead == NULL) |
| 3884 | return NULL; |
| 3885 | |
| 3886 | xform_aead->type = RTE_CRYPTO_SYM_XFORM_AEAD; |
| 3887 | xform_aead->aead.op = encrypt ? RTE_CRYPTO_AEAD_OP_ENCRYPT : |
| 3888 | RTE_CRYPTO_AEAD_OP_DECRYPT; |
| 3889 | |
| 3890 | /* aead_algo */ |
| 3891 | status = rte_cryptodev_get_aead_algo_enum(&xform_aead->aead.algo, |
| 3892 | tokens[2]); |
| 3893 | if (status < 0) |
| 3894 | goto error_exit; |
| 3895 | |
| 3896 | /* aead_key */ |
| 3897 | len = strlen(tokens[4]); |
| 3898 | if (len / 2 > max_key_len) { |
| 3899 | status = -ENOMEM; |
| 3900 | goto error_exit; |
| 3901 | } |
| 3902 | |
| 3903 | status = parse_hex_string(tokens[4], key, (uint32_t *)&len); |
| 3904 | if (status < 0) |
| 3905 | goto error_exit; |
| 3906 | |
| 3907 | xform_aead->aead.key.data = key; |
| 3908 | xform_aead->aead.key.length = (uint16_t)len; |
| 3909 | |
| 3910 | /* aead_iv */ |
| 3911 | len = strlen(tokens[6]); |
| 3912 | p->aead.iv.val = calloc(1, len / 2 + 1); |
| 3913 | if (p->aead.iv.val == NULL) |
| 3914 | goto error_exit; |
| 3915 | |
| 3916 | status = parse_hex_string(tokens[6], p->aead.iv.val, |
| 3917 | (uint32_t *)&len); |
| 3918 | if (status < 0) |
| 3919 | goto error_exit; |
| 3920 | |
| 3921 | xform_aead->aead.iv.length = (uint16_t)len; |
| 3922 | xform_aead->aead.iv.offset = RTE_TABLE_ACTION_SYM_CRYPTO_IV_OFFSET; |
| 3923 | p->aead.iv.length = (uint32_t)len; |
no test coverage detected