return test_ipsec_proto_all(&flags);
}
+static int
+test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.icv_corrupt = true;
+
+ return test_ipsec_proto_all(&flags);
+}
+
static int
test_PDCP_PROTO_all(void)
{
"Combined test alg list",
ut_setup_security, ut_teardown,
test_ipsec_proto_display_list),
+ TEST_CASE_NAMED_ST(
+ "Negative test: ICV corruption",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_err_icv_corrupt),
TEST_CASES_END() /**< NULL terminate unit test array */
}
};
memcpy(td_inb[i].output_text.data, td_outb[i].input_text.data,
td_outb[i].input_text.len);
td_inb[i].output_text.len = td_outb->input_text.len;
- }
- RTE_SET_USED(flags);
+ if (flags->icv_corrupt) {
+ int icv_pos = td_inb[i].input_text.len - 4;
+ td_inb[i].input_text.data[icv_pos] += 1;
+ }
+ }
}
void
uint8_t *output_text = rte_pktmbuf_mtod(m, uint8_t *);
uint32_t skip, len = rte_pktmbuf_pkt_len(m);
+ /* For negative tests, no need to do verification */
+ if (flags->icv_corrupt &&
+ td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
+ return TEST_SUCCESS;
+
if (len != td->output_text.len) {
printf("Output length (%d) not matching with expected (%d)\n",
len, td->output_text.len);
return TEST_FAILED;
}
- RTE_SET_USED(flags);
-
return TEST_SUCCESS;
}
{
int ret = TEST_SUCCESS;
- if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
- printf("Security op processing failed\n");
- ret = TEST_FAILED;
+ if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->icv_corrupt) {
+ if (op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
+ printf("ICV corruption test case failed\n");
+ ret = TEST_FAILED;
+ }
+ } else {
+ if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ printf("Security op processing failed\n");
+ ret = TEST_FAILED;
+ }
}
- RTE_SET_USED(flags);
- RTE_SET_USED(dir);
-
return ret;
}