简体   繁体   English

Android NDK原生代码真正原生?

[英]Android NDK native code true native?

I'm wondering if it is more secure to do the cryptographic functions in native code. 我想知道在本机代码中执行加密功能是否更安全。 Using Java you can't be sure if the GC re-sorts the memory and leaves shallow copies of your keys in the memory, even if you zero out the key immediately after en/decryption. 使用Java,您无法确定GC是否重新排序内存并将密钥的浅拷贝留在内存中,即使您在en / decryption之后立即将密钥清零也是如此。

Maybe this is a stupid question, but I couldn't find any information. 也许这是一个愚蠢的问题,但我找不到任何信息。 The native code is still running sandboxed and within the VM, so could the GC/VM/system re-sort the memory and therefore leave a shallow copy? 本机代码仍然在沙盒中运行并且在VM中,因此GC / VM /系统可以重新排序内存,因此留下浅层副本吗? So are the stack and heap static or can they be moved? 堆栈和堆是静态的还是可以移动? AFAIK they have virtual addresses, so this could be done. AFAIK他们有虚拟地址,所以这可以做到。

Thank you and best regards 感谢你并致以真诚的问候

The Native code is compiled for ARM (and now intel I think), not Dalvik VM, and it runs directly on the processor, it is loaded and invoked by the Dalvik, yet it is not directly controlled by it. Native代码是为ARM(现在我认为是英特尔)编译的,而不是Dalvik VM,它直接在处理器上运行,它由Dalvik加载和调用,但它不是由它直接控制的。 The stack and heap of the native code are real. 本机代码的堆栈和堆是真实的。 calling memcpy/memset will change the memory for good. 调用memcpy / memset会改变内存。

All modern systems have virtual memory too, so this is as far as you'll probably get regarding security. 所有现代系统都有虚拟内存,因此就安全问题而言,这可能就此而言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM