test_suite_pkwrite: extend coverage of wrong output buffer sizes in pk_write_check_common()

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
diff --git a/tests/suites/test_suite_pkwrite.function b/tests/suites/test_suite_pkwrite.function
index 3392528..491bc48 100644
--- a/tests/suites/test_suite_pkwrite.function
+++ b/tests/suites/test_suite_pkwrite.function
@@ -73,7 +73,7 @@
     unsigned char *buf = NULL;
     unsigned char *check_buf = NULL;
     unsigned char *start_buf;
-    size_t buf_len, check_buf_len, wrong_buf_len = 1;
+    size_t buf_len, check_buf_len;
     int expected_result;
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
     mbedtls_svc_key_id_t opaque_id = MBEDTLS_SVC_KEY_ID_INIT;
@@ -118,10 +118,10 @@
     }
     /* Intentionally pass a wrong size for the provided output buffer and check
      * that the writing functions fails as expected. */
-    TEST_EQUAL(pk_write_any_key(&key, &start_buf, &wrong_buf_len, is_public_key,
-                                is_der), expected_result);
-    TEST_EQUAL(pk_write_any_key(&key, &start_buf, &buf_len, is_public_key,
-                                is_der), 0);
+    for (size_t i = 1; i < buf_len; i++) {
+        TEST_EQUAL(pk_write_any_key(&key, &start_buf, &i, is_public_key,
+                                    is_der), expected_result);
+    }
     TEST_EQUAL(pk_write_any_key(&key, &start_buf, &buf_len, is_public_key,
                                 is_der), 0);
 
@@ -142,8 +142,10 @@
         buf_len = check_buf_len;
         /* Intentionally pass a wrong size for the provided output buffer and check
          * that the writing functions fails as expected. */
-        TEST_EQUAL(pk_write_any_key(&key, &start_buf, &wrong_buf_len, is_public_key,
-                                    is_der), expected_result);
+        for (size_t i = 1; i < buf_len; i++) {
+            TEST_EQUAL(pk_write_any_key(&key, &start_buf, &i, is_public_key,
+                                        is_der), expected_result);
+        }
         TEST_EQUAL(pk_write_any_key(&key, &start_buf, &buf_len, is_public_key,
                                     is_der), 0);