CKM: Max chunk size test
[platform/core/test/security-tests.git] / src / ckm / unprivileged / encryption-decryption-env.cpp
index 16017d4..7f43bcb 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <encryption-decryption-env.h>
+#include <ckm-common.h>
 
 using namespace CKM;
 
@@ -151,7 +152,16 @@ int CipherApi::crypt(ckmc_cipher_ctx_h ctx,
                      size_t left,
                      CKM::RawBuffer& output)
 {
+#ifdef TZ_BACKEND
+    ckmc_backend_info_h info;
+    size_t maxSize;
+    // All unexportable keys go to TZ if enabled (and all of them are unexportable)
+    assert_positive(ckmc_get_backend_info, CKMC_BACKEND_TZ, &info);
+    assert_positive(ckmc_backend_get_max_chunk_size, info, &maxSize);
+    const size_t CHUNK_SIZE = 80 < maxSize ? 80 : maxSize;
+#else
     const size_t CHUNK_SIZE = 80;
+#endif
     ckmc_raw_buffer_s* out = nullptr;
     ckmc_raw_buffer_s* in = nullptr;
     size_t size = CHUNK_SIZE;