1. Linux install openssl library
See "Mastering PKI security authentication technology and network programming," OpenSSL development environment set up under section 2.3.2 Linux
Linux unpack tar.bz2 file below: tar jxvf android-ndk-r5c-linux-x86.tar.bz2
Configuring NDK environment variables
In ~ / bashrc file added at the end:
NDK = ~ / android-ndk-r4b
export NDK
Execute source ~ /. Bashrc
If the terminal is already running, you need to restart the terminal NDK variables to
3. JNI introduced
JNI main function is to be able to call to the C library, where we need to use C or C + + library implementation calls openssl signature features such as encryption, and then compiled into a database so arm the system, the interface provided by java call.
For details, see the book: " TheJava Native Interface: Programmer's Guide and Specification "
4 download android version of openssl, compiled
Now I have seen three kinds of online versions of android-openssl, fries version, eighthave version and guardianproject version, the first two versions have been tested but no attempt is successful, guardianproject version compiled into a static library to give android JNI dynamic library calls of the words will not find a way, do not know why, but directly to the JNI program works in conjunction with the openssl compilation can be achieved.
The following blog has said static library to compile openssl android with, but he does not know what version of Openssl, I try to follow his methods without success.
http://blog.csdn.net/someonea/article/details/6312213
guardianproject original version download address:
https://github.com/guardianproject/openssl-android
I modified version:
http://download.csdn.net/source/3408214
In my revised version of the program can be written directly in the JNI folder myAPP file packaged with Openssl compiled into a dynamic library on the line.
May occur when compiling some of the undefined reference, most probably did not add link library, in some cases it may be NDK version of the problem, it is best to use the latest version of the NDK (I use r5c), note that there is not, add the following two static library < br />
LOCAL_LDLIBS: =-lz-ldl
Reply:
5 would be finished so the compiler to place the library android project directory libs / armeabi directory
6. JAVA dynamic library calls
Here is a test I wrote that adds two numbers:
native method:
public native int add (int a, int b);
load library:
static {
System.loadLibrary ("add") ;/ / compiler are finished with the Lib beginning, do not add
here Load
}
7 android call log of the c program, recording operating information
Will not use gdb debugging said this stuff, had to use a step by step log records .....
view plainprint?
# include
# Define LOG_TAG "show infomation" / / This is the log tab, set up their own
content
# Define LOGW (a) __ android_log_write (ANDROID_LOG_WARN, LOG_TAG, a) / / In addition to this method there __android_log_print method, with printf like concrete can see android / log.h inside
Makefile in LOCAL_LDLIBS: =-L $ (SYSROOT) / usr / lib-llog
8. BouncyCastle combined openssl key management
See this blog's introduction
http://blog.csdn.net/zhenyongyuan123/article/details/5558562
I have tried successfully generated keystore and key pair with bouncyCastle on android,
It should be noted that the Android itself bouncyCastle package, an error
directly into the package if you can not find the run times etc.
We need to download bouncyCastle source, modify the package name such org.bouncyCastle2 etc. compiled packaged into jar
Build Path-> Add External Archives added package will not find the type of error reported otherwise run, this may be because there is no package into the apk in the jar.
Reply:
9. Openssl and cryptoAPI symmetric encryption compatibility issues
cryptoAPI itself does not support pass into the clear key, Key needs to get a handle,
by genKey or DeriveKey
And this is not just on the inside pass into the key hash algorithm, specifically refer to MSDN
http://msdn.microsoft.com/en -us/library/aa379916% 28v = VS.85% 29.aspx
Remarks inside
If the hash is not a member of the SHA-2 family and therequired key is for either 3DES or AES, the key is derived as follows: The following six steps.
We can through public-key encryption, private key to decrypt view to cryptoAPI symmetric session key encryption, there has been a complete code:
http://www.codeproject.com/KB/security/plaintextsessionkey.aspx
When using the openssl evp packaged symmetric encryption looks like a problem, I might use the wrong, this way you can use the following
encrypted with the matching cryptoAPI
http://blog.csdn.net/lyjinger/article/details/1722570
10 Some time may only need NDK compile a static library, but if you do not add a dynamic library compiled
nothing
Here compile only need to create a static library in JNI Application.mk below, you need to add that in the file:
APP_MODULES: = libexample (module name)
11 In addition, Android has a certificate installed above functions, there is no real machine, do not understand what purpose,
In the setting can be found inside the android emulator Location & security bar, which can install from SD card to install encrypted certificates, p12 format, with a private key. After installation you can find the corresponding certificates, keys and other documents in the Data / misc / keystore, code operation without permission.
System / etc / security presence following cacerts.bks, BouncyCastle key database integrity check fails when reading tips, this document should also be no access to the
Reply:
Thanks for sharing ~ ~ ~ ~
Reply:
Insights relatively simple welcome Twins correction

Reply:
Nice!
Thank you for sharing, must plus fine !
Reply:
Learning, thank you
Reply:
Good, thank you
Reply:
National Electronic contest harass
Reply:
Good answer
Reply:
Good, thank you
Reply:
Witness ~ ~ ~ ~
Reply:
Good stuff ~ ~
Reply:
Study, collection!
Reply:
Well, learn
Reply:
Very good
Reply:
Looks good
Reply:
xuexi
Reply:
KANKANASDASDASD
Reply:
Enjoy the brilliant idea
Reply:
Reply:
Thank you for sharing
Reply:
To this Collection
Reply:
android source code itself comes with openssl, directly brought onto the next ndk can be compiled. . . In addition, I do not know of a chapter blog lz provided static library why not compile successfully? I tested the following should be possible.
Finally thank lz sharing, like lz sharing experience and encounter problems, I think this is more than a simple online call how much better you compile
Reply:
openssl is a good Dongdong, a pity that there was no good research!
Reply:
Content stored in the clipboard
Reply:
This I do not know ... he toss a long time before it comes out, though that android already have openssl, but do not know the source code can be directly inside out to compile
Can leave a contact, talk in detail
Reply:
Hello, openssl openssl you posted the article titled blog, use statically compiled from the source code is actually out of sync.
Reply:
Amount, so, ah, I was under the openssl source. . . Not with the android inside, no wonder
Thank you remind
Reply:
Thank you
Reply:
Reply:
Reply:
Good article
Reply:
Well studied
Reply:
Collection ~
Reply:
Learn ah
Reply:
Learning.
Reply:
Replies can get 10 points a day available points! Tips: teach you how to quickly get the available points
Reply:
Yes, learn! !
Reply:
thanks
Reply:
thanks
Reply:
Learn
Reply:
HAO ........................
Reply:
Is good stuff, learn about
Reply:
thanks, mark
Reply:
Thank you, really thank
Oh
Reply:
Thank you, really thank
Oh
Reply:

Reply:
Dinga ............. good stuff
Reply:
First study. There are questions I will stand in the message of the landlord. Haha
Reply:
Landlord, this https://github.com/guardianproject/openssl-android can compile successfully.
Generates two so files:. Libcrypto.so and libssl.so
My gcc is 4.3.4
android-ndk-r6.
But I still have a problem, I do not know libcrypto.so and libssl.so interface, do not know how to call them in the program.
Now, I would like to ask the landlord can give to illustrate how to call these two. So file to achieve DES encryption program like an android or java program.
Reply:
Learn
Reply:
Maybe you need to go look at JNI, java does not directly implement encryption, compiled into a dynamic library after calling openssl interface provides an interface with C and then call to java, java call interface that is provided by the dynamic library JNI to achieve
Reply:
Ah, I want to do:
Enter the android java program inside a key and a string of text, then call. So files inside DES encryption method (libcrypto.so and libssl.so encapsulates the encryption algorithm should be some out), get the results and output.
I do not know to do so, the program should be how to write. Because now I do not know. So external interface.
Reply:
Write a java native methods, such as public native String encrypt (String key, String text);
javah the class file into a. h file, it will generate a corresponding method, the rest of you call this method with a C interface in openssl encryption would be finished. Will you achieve finished compiled into a dynamic library for java call, System.load (...);
If there is not clear, please refer to that book my third point listed above, a very detailed description of the JNI implementation steps, that is, you are not quite sure how to call the java interface to dynamic library
Reply:
Look look look look look look look hurry hurry
Reply:
Learn new techniques
Reply:
Learn new techniques
Reply:
B content stored in the clipboard
Reply:
Learn new techniques
Reply:
Thank you. . .
Reply:
xiexie!
Reply:
I have followed your steps made out to generate a. So file, but with android but there is always the wrong call is not up and running, I used ANdroid version is ADT-2.1
Reply:
Report what is wrong
Reply:
When Eclipse is calling. So file, apk has been generated, but the emergence of Application automatic error shut down, I do not know why.
There are steps that you can say can configure more specific? File is used to generate commands so as ~ / android-ndk/ndk-build such instructions until the final results are displayed, are detailed written out? Thank you very much.
You can add me as a friend yet? I especially adore you very much. My QQ: 727849423
Reply:
If you are under specified under openssl source I use a modified version of the android-8 in openssl default.properties I uploaded the source code can be changed version
Reply:
Collection. . .
Reply:
Thank you, thank
Reply:
Reply:
Reply:
Friends of the faithful or multi-master csdn
Reply:
When compile, but why do I use openssl things in the android, the program collapsed ah? Solving ah! ! ~
Reply:
The landlord can add my friends do? Opendssl you would like to ask some questions, QQ313234231
Reply:
Landlord to ask you about, I had to compile your project, call the aes encryption, but a call to the encryption program would crash, aes encryption landlord has tried it?
Reply:
Reply:
Thanks for sharing!
No comments:
Post a Comment