I want to use Termux or a Termux derivative like AutoPie to run Python Scripts or .jar files (written in Kotlin) and use their standard modules for secure randomness, which is .secrets in Python and java.security.SecureRandom for JVM applications.
On Linux/Windows/MacOS, these modules use the operating systems secure randomness source.
Does this also work if they run inside a Linux terminal inside an Android app?
Will Termux/AutoPie forwards the request to the operating system to generate secure entropy?
I am not that experienced in this, so take my answer with a grain of salt, but my guess would be yes. Termux is ‘just’ a linux user environment that runs as a standard android application in the android user space. It is not a virtual machine and shares the same linux kernel as the rest of the system.
As you already mentioned these libraries read from the kernels CSPRNG. Thus, assuming the builds of python or JVM are not modified, any request for entropy made by them inside termux should be passed directly to the android kernel.
I don’t know AutoPie or other termux derivatives, so I am not sure if this also applies to them.
If we assume that the Kernel is the same, then there would still be the question whether you get goof entropy on Android by using the standard functions of a programming language or if you need to use Android specific APIs via an Android framework?