LibTestApp: Added AES CFB direct API invalid param tests
@@ -551,6 +551,46 @@ test_hash_api(struct MB_MGR *mgr)
return 0;
}
+/*
+ * @brief Performs direct AES API invalid param tests
+ */
+static int
+test_aes_api(struct MB_MGR *mgr)
+{
+ const uint32_t text_len = BUF_SIZE;
+ uint8_t out_buf[BUF_SIZE];
+ uint8_t zero_buf[BUF_SIZE];
+ int seg_err; /* segfault flag */
+
+ seg_err = setjmp(env);
+ if (seg_err) {
+ printf("%s: segfault occured!\n", __func__);
+ return 1;
+ }
+
+ memset(out_buf, 0, text_len);
+ memset(zero_buf, 0, text_len);
+
+ /**
+ * API are generally tested twice:
+ * 1. test with all invalid params
+ * 2. test with some valid params (in, out, len)
+ * and verify output buffer is not modified
+ */
+
+ IMB_AES128_CFB_ONE(mgr, NULL, NULL, NULL, NULL, -1);
+ IMB_AES128_CFB_ONE(mgr, out_buf, NULL, NULL, NULL, -1);
+ if (memcmp(out_buf, zero_buf, text_len) != 0) {
+ printf("%s: IMB_AES128_CFB_ONE, invalid "
+ "param test failed!\n", __func__);
+ return 1;
+ }
+ printf(".");
+
+ printf("\n");
+ return 0;
+}
+
int
direct_api_test(const enum arch_type arch, struct MB_MGR *mb_mgr)
{
@@ -576,6 +616,7 @@ direct_api_test(const enum arch_type arch, struct MB_MGR *mb_mgr)
errors += test_gcm_api(mb_mgr);
errors += test_key_exp_gen_api(mb_mgr);
errors += test_hash_api(mb_mgr);
+ errors += test_aes_api(mb_mgr);
if (0 == errors)
printf("...Pass\n");
