Ported mbedtls library for ardupilot firmware, need help with some restart issue

Hi, I am using px4 2.4.8 with ardupilot firmware. we have some requirment where we need mbedtls support for ardupilot firmware to genarate RSA 2048 keys. Porting is completed library is working properly in ardupilot firmware.

I am using this library in Scheduler.cpp file. created new task for RSA key genaration using chThdCreateStatic().
Problem is that RSA key genaration loop takes 3-5 min that is ok, but i am only able to genarae RSA key when I start key genaration imidiate after ardupilot start followed by while (!sched->_hal_initialized). if I go to key genaration after some time(1-2min, or some time its triggered from custome mavlink command) of ardupilot start, its restart the firmware while prime number calculations.
I am using st link v2 for debugging, but not getting inside any handler when firmware restart.
There is no issue with library as it is working properly and tested may times.
what I am thinking about my problem:
-is watchdog restart controller if I am spending some time in same thread (mostly doing prime number calculation)?
-is there any issue if I conssume more ram?
-is fail safe controller restart main controller?