简体   繁体   English

Android中现有的OpenSSL库

[英]OpenSSL existing library in Android

I'm building AOSP, so lets say i have root for all module in Android. 我正在构建AOSP,因此可以说我对Android中的所有模块都有root用户。 Sure there is OpenSSL library which building and reusing in other modules. 确保有OpenSSL库可以在其他模块中构建和重用。

And we have base application (system, external, whatever), which also communicate with native code. 我们有基础应用程序(系统,外部或其他),也可以与本机代码通信。 And my question is: How to include in local project, existing Android OpenSSL library, to work with it? 我的问题是:如何在本地项目中包含现有的Android OpenSSL库,以使用它?

Another say, how i can get active instance of OpenSSL/BoringSSL in native code. 换句话说,我如何在本机代码中获得OpenSSL / BoringSSL的活动实例。 And also, how to get instance of Android Keystore engine and work with it? 而且,如何获取Android Keystore引擎实例并使用它?

Thanks! 谢谢!

From the release notes of Android 6.0 : 根据Android 6.0发行说明

If you're using the Android NDK in your app, don't link against cryptographic libraries that are not a part of the NDK API, such as libcrypto.so and libssl.so . 如果您在应用程序中使用的是Android NDK, 请不要链接到不属于NDK API的加密库​​,例如libcrypto.so和libssl.so These libraries are not public APIs, and may change or break without notice across releases and devices. 这些库不是公共API,并且可能会在不同版本和设备之间更改或中断而不会另行通知。 In addition, you may expose yourself to security vulnerabilities. 此外,您可能会面临安全漏洞。 Instead, modify your native code to call the Java cryptography APIs via JNI or to statically link against a cryptography library of your choice. 相反,修改您的本机代码以通过JNI调用Java加密API或静态链接到您选择的加密库。

In your native code besides the C/native API you have access to the Java API as well. 在C / native API之外的本地代码中,您也可以访问Java API。 Therefore you can write C code that calls the regular Java API for accessing the AndroidKeyStore. 因此,您可以编写C代码来调用常规Java API来访问AndroidKeyStore。 You just have to translate the Java code into C code. 您只需要将Java代码转换为C代码即可。 Accessing the Java API this way is a bit complicated, however it is the safest way (regarding compatibility). 以这种方式访问​​Java API有点复杂,但是它是最安全的方式(关于兼容性)。

See also 也可以看看

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

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