A kind of Android platform software protection system, method and apparatusTechnical field
The present invention relates to a kind of protecting computer software technology, divulge a secret and copyright protecting system and method, server and intelligent terminal especially for the software of Android platform is anti-.
Background technology
At present, the Android operating system by the leading exploitation of Google company has been the highest mobile intelligent terminal platform of world market occupation rate.The application software quantity of Android constantly increases, and has set up good software marketing pattern.The same with conventional P C platform, the successful commercialization of Android application software, also caused to they conversed analysis with crack.
Conversed analysis (reversing analysis) to using software comprising:
One, the executable code of software is adopted methods such as dis-assembling, decompiling, debugging analyze, with the execution flow process of understanding its code and algorithm realization etc.;
Two, the configuration file and the data file of software are analyzed, with the form that obtains these files and semanteme etc.;
Three, the network communication data of software is analyzed, to obtain protocol format, protocol semantics, data ciphering method and the concrete implication of data etc. of software and server communication.
Wherein, back two alanysis are based upon on the basis that the first kind analyzes, and promptly need to analyze earlier executable code, further analysis configuration file, data file, network communication data etc.
Through conversed analysis, the assailant can obtain the trade secret in the software.For example; In the anti-viral software of mobile phone; Executable codes such as malicious code detection algorithm, characteristic matching algorithm, and data file such as malicious code feature database are in case the victim conversed analysis obtains detail; Both possibly utilized, also possibly carried out specific aim defence or attack by malicious code authors by other similar software.For another example; In the e-Bank payment software of mobile phone; The authentication and the financial account information that relate to the user through the data of Network Transmission; In case victims such as software code, configuration file, network communication data are thoroughly understood through conversed analysis, just might cause further malicious attack, individual and bank are caused direct economic loss.
Cracking (cracking) is a kind of attack with special purpose on the conversed analysis basis.Business software needs to use after the user charges.To the unpaid expense family, generally do not allow to use, maybe can only use a small amount of function, maybe can only use one period trial period.In order to ensure this strategy, whether business software comprises the discriminating (the following code snippet that will be responsible for this discriminating work is called " authentication code ") to user's permission (License) and user identity usually, pay with judges.The assailant is through the conversed analysis to authentication code; And further distort code and carry out flow process, distort, duplicate or forge the relevant configuration file, distort network data, revise internal storage data etc., make the unpaid expense family also can obtain the function that the paying customer just has.This attack is referred to as to crack, and it has greatly damaged software developer's economic rights and interests, has violated the relevant law of intellectual property protection.
The applied software development of Android platform generally adopts Java language.Source code is compiled into the java class file; Use Android SDK (Software Development Kit again; SDK) instrument in converts the binary executable of DEX form into; Be packaged into the APK formatted file with software arrangements, resource file etc. at last, i.e. Android application software installation kit.User's download APK formatted file, and be installed to the Android terminal.During the application software operation, carry out among the Dalvik virtual machine of the instruction in the DEX formatted file in the Android system.
Android is the wide-open operating system of source code.No matter be the instruction coding method of DEX formatted file, or the principle of work of Dalvik virtual machine, all known by people because source code is open.All kinds of conversed analysis instruments occurred at present, comprised disassemblers smali, decompiling instrument dex2jar to the DEX formatted file, and the automation tools such as apktool that are directed against the APK formatted file.In addition, conversed analysis has occurred for many years on conventional P C platform with the technology that cracks, and the assailant of Android platform has used for reference traditional method.Under the help of these tool and methods, the assailant can carry out conversed analysis and crack most Android application software easily at present.
For example, the common flow process that cracks is: use apktool to untie the APK file, apktool can call smali wherein DEX formatted file is carried out dis-assembling; The assailant analyzes the dis-assembling result of smali, understands the code flow of this application software; Find authentication code then, the part of key is made amendment, the condition jump instruction during for example authentication makes the unconditional jump instruction into; Re-use apktool these codes of revising are repackaged into the APK formatted file, the new signature of laying equal stress on.So just obtained the APK file after is cracked.
In addition, the Android application program can also be used NDK (Native Development Kit, primary development kit) exploitation.The Android system runs on the Linux, and the Dalvik virtual machine at each application software place is an independently Linux process.Android NDK provides a kind of like this development approach: the programmer is with the partial function of C language software, by the instrument of NDK source code is compiled as the dynamic link file (SO formatted file) among the Linux; Write other functions with Java language, be compiled as the DEX formatted file with the SDK instrument; By SDK SO formatted file and DEX formatted file are packaged as the APK formatted file together at last.When operation, the code among the DEX loads the SO formatted file, and calls the function interface that it provides.
SO formatted file in the NDK exploitation is a kind of of Linux ELF format standard, and order format wherein is the ARM instruction set or the Thumb instruction set of ARM architecture.There are decompiling instruments such as disassemblers such as IDA Pro and x86/ARM Decompiler to carry out conversed analysis at present to this file.
This platform defence conversed analysis and crack method comprise at present:
One, code is obscured.Be that equivalence is used but the hand-written Java source code of redundant complicated code replacement developer in robotization ground, the raising assailant carries out the workload of conversed analysis.
Two, change character string information.In high-quality Java source code, bag, class, method, name of variables often have readable preferably, promptly have clear and definite implication, therefore can be through its function of title conjecture.The DEX file has intactly been preserved these names, for conversed analysis provides convenience.But most of name is only the inner use of application program, for example self-defining type.If these names are replaced with insignificant character string, can't influence the operation of program, but being absorbed in, conversed analysis understands difficulty.ProGuard instrument among the Android SDK just utilizes this method to protect software.
Three, use the NDK exploitation.As previously mentioned, the conversed analysis of SO file is related to the understanding to ARM form assembly language, improved the difficulty of software code being carried out conversed analysis to a certain extent.
There is following problem in these methods:
1. no matter be code or data encrypted, all with the document form long-term existence among Android installs file and Android equipment, the assailant can obtain easily;
2. obscure through code, code still can just have been improved the needed time of code of understanding by dis-assembling and decompiling;
3. through the change character string information, the logic of code itself does not change, and still can equally just have been improved the needed time of code of understanding by dis-assembling and decompiling;
4. be familiar with ARM form assembly language along with the assailant understands gradually, and along with the continuous maturation of this platform decompiling instrument, adopt the conversed analysis difficulty that method improved of NDK exploitation can be more and more lower.
In theory, the execution of application software in computing equipment finally all can't be hidden by conversed analysis.The essence of software protection is to improve constantly conversed analysis and the difficulty and the time cost that crack, makes the assailant obtain the cost that valuable informational needs pays and is higher than its obtainable interests.
The software protection meeting brings extra software development cost, for example increases development difficulty, prolongs the development time etc.Therefore, from whether needing the angle of special protection, can the code of application software be divided into two parts in logic:
One, non-core code does not need special protection, for example with the interface of user interactions, multiplexing third party library code etc.;
Two, core code needs special protection, for example important algorithm, authentication code, important configuration data etc.
How these two parts divide, and do not have method in common, by the actual conditions decision of each application software.For example, in anti-viral software, malicious code detection algorithm, characteristic matching algorithm etc. all is a nucleus module; In Net silver software, User login code, financial transaction code etc. all is a nucleus module; In the charge business software, paying code, authentication code etc. all are nucleus modules.
The invention still further relates to modification to DEX file dynamic load technology in the Android system.
Generally, the DEX file in the Android application software is to be kept at appointed positions by system when mounted.For the ability of expanded application software, Android provides DEX file dynamic load technology.Particularly; Application software is when operation; Can load an APK form or a JAR formatted file that does not have installation before through the dalvik.system.DexClassLoader class, and the DEX formatted file of " classes.dex " by name that comprised in this document is loaded on the Dalvik virtual machine; Further, can call the code of realizing in this DEX formatted file through such findClass methods such as ().
Up to the present Android version (from 1.0 to 4.0); Have following requirement through said method dynamic load DEX formatted file: the APK or the JAR formatted file that have comprised " classes.dex " must be physical files, in nand flash memory that the equipment that is kept at is built-in or the external SD card; During dynamic load, system can generate a temporary file in built-in nand flash memory of equipment or external SD card, and this document is to the optimization of DEX formatted file (expansion .odex by name).
Summary of the invention
To above technical matters, the present invention mainly discloses a kind of application software of in the Android system, protecting and has not received conversed analysis and crack system and method.For Dalvik virtual machine in the Android system and linux system storehouse increase interface, make Android have the ability that from internal memory, directly loads DEX formatted file and SO formatted file; The core code of application software is stored in the line server, sends to the application software that is installed in client behind encryption and the signature; Application software receives certifying signature and deciphering behind the core code, then with stored in clear in internal memory, directly be loaded in the system, call code wherein then, last releasing memory.This method has greatly increased the assailant and has carried out conversed analysis and the difficulty that cracks, and can effectively protect the safety of Android application software.
The present invention is made up of three parts:
1, the Android operating system of revising realizes the dynamic load of DEX formatted file in internal memory;
2, the non-core code of application software be installed in the intelligent terminal (comprising mobile phone, panel computer etc.), and this intelligent terminal uses the Android operating system of above-mentioned modification;
3, the core code of application software is stored in the long-term online server.
At first, the source code of Android operating system is made amendment.On the Dalvik virtual machine, increase such function; Make the Dalvik virtual machine directly load a DEX formatted file from the memory address of appointment; And make application program can pass through wherein bag name, class name, the method name of code, call these codes and in the Dalvik virtual machine, carry out.On the Linux of Android bottom, increase such function, make Linux directly load a SO formatted file, and make application program can pass through the wherein api interface of code, call these codes and in Linux, carry out from the memory address of appointment.
The core code of application software is to pass through the DEX formatted file that the instrument among the Android SDK is compiled into by the Java source code, or passes through the SO formatted file that the instrument among the Android NDK is compiled into by the C source code.The server of storing these core codes receives the non-core code sent request of application software in the intelligent terminal, and the core code of its request is encrypted, carried out digital signature, sends to the application software in the intelligent terminal then.
The non-core code of application software is positioned among the complete Android application program (being the APK formatted file).The software developer openly distributes this application program, and the user is mounted to it in intelligent terminal.Non-core code also possesses following function except accomplishing the needed function of application software: send request to server, receive the core code of sending, and verify its digital signature; Apply for one section internal memory, core code is deciphered to this section internal memory; According to core code is DEX form or SO form, makes Dalvik virtual machine or Linux from this section internal memory, directly load core code, calls the function of core code then as required through api interface; When application software does not re-use core code, discharge this section internal memory at last.
Particularly, the invention provides a kind of Android platform software protection system, comprise intelligent terminal and line server:
Said intelligent terminal comprises the non-core code of amended Android operating system and application software; Said amended Android operating system is made amendment to the source code of Android operating system, realizes the dynamic load of core code in internal memory of application software; The non-core code of said application software is among complete Android application program; Possesses the function beyond the needed function of application software; Comprise: send request to line server; Receive the core code that line server is sent,, pass through the core code of api interface calling application software as required through verifying the core code of loading application software in internal memory afterwards;
The core code of line server storage application software receives the non-core code sent request of application software in the intelligent terminal, and requested core code is sent to the non-core code of application software in the intelligent terminal through after handling.
The core code of said system software comprises DEX formatted file and SO formatted file.
The core code of the line server storage application software of said system; Receive the non-core code sent request of application software in the intelligent terminal, some or all of requested core code is encrypted and/or requested core code is carried out sending to the non-core code of application software in the intelligent terminal after the digital signature.
The present invention also provides a kind of source code amending method of Android operating system, is applicable to described system, and said method comprises:
Dalvik virtual machine to Android operating system; The function of dalvik.system.DexClassLoader class among the expansion Android Framework; Dalvik.system.DexClassLoader class after the expansion provides calling interface; Receive the DEX formatted file in the internal memory, load described DEX formatted file with the mode that loads the DEX formatted file;
The source code of linux kernel and system library partly increases an interface in the Android source code, and said interface loads the SO formatted file from the memory address of appointment;
Compile whole Android source code engineering, generate corresponding system image and developing instrument.
The .odex temporary file that said method produces when loading described DEX formatted file is kept in the internal memory.
The present invention also provides the guard method of a kind of Android platform software, is applicable to described system, and said method comprises:
Line server is encrypted the core code of the part or all of application software of storage;
Line server carries out digital signature to the core code of the application software of storage;
The file and the corresponding ciphertext at the core code of application software place are sent to intelligent terminal.
A kind of server provided by the invention, the line server in the said system of said server, said server comprises:
Ciphering unit is used for the core code of part or all of application software of storage is encrypted;
The digital signature unit is used for the core code of application software of storage is carried out digital signature;
Transmitting element is used for the file and the corresponding ciphertext at the core code of application software place are sent to intelligent terminal.
A kind of Android platform software provided by the invention guard method is applicable to described system, and said method comprises:
The file at the core code place of the application software that intelligent terminal reception line server sends and corresponding ciphertext;
Also decipher the core code file of the software that is applied according to the file verification digital signature that receives;
In internal memory, the interface that calls amended Android operating system is accomplished the loading of core code file with the core code document copying of application software;
Pass through the core code of api interface calling application software as required;
Discharge the internal memory of storage core code.
Further, intelligent terminal needed the request of application software core code to the line server transmission before the file and corresponding ciphertext at the core code place of the application software that the reception line server sends.
The invention provides a kind of intelligent terminal, said intelligent terminal is the intelligent terminal in the said system, and said intelligent terminal comprises amended Android operating system, also comprises:
Receiving element is used to receive the file and the corresponding ciphertext at the core code place of the application software that line server sends;
Authentication unit is used for according to the be applied core code file of software of the file verification digital signature that receives and deciphering;
Loading unit is used for core code document copying with application software to internal memory, and the interface that calls amended Android operating system is accomplished the loading of core code file;
Call unit is used for as required the core code through api interface calling application software;
Releasing unit is used to discharge the internal memory of storing core code.
Described intelligent terminal also comprises:
Transmitting element needing to the line server transmission to be used for the request of application software core code.
The invention has the beneficial effects as follows:
One of which is compared with the existing software protection scheme, and the method for the invention makes the extremely difficult core code that obtains application software of assailant, thereby can't carry out conversed analysis to it.
At first; The application software of open distribution does not comprise core code; The assailant can't look like to download to application software from software market or download website in the past; Directly it is done static dis-assembling and just can see all codes, obtain this partial code must move this application software, makes its Connection Service device.
Secondly, adopt encryption and digital signature fully,, do not having under the situation of key, can't solve core code expressly even if the assailant has grasped network communication data in the communication between the application software on server and the intelligent terminal.Use digital signature, guaranteed that also the assailant can't pseudo-ly in this course produce false core code, gains application software by cheating and loads.
At last; In the Android of intelligent terminal operating system; Core code only is present in the internal memory all the time, and only when application software needs wherein function, is present in the internal memory, and is not present in built-in nand flash memory of equipment or the external SD card with document form.At present, the Dalvik virtual machine that the Android application program is moved is positioned at independently on the Linux process, and the process authority is that the exclusive user of this application program creates, and the assailant is difficult to read the virtual memory space at core code place.Even if the assailant can read; Because the memory headroom of storage core code is when operation dynamic assignment; Consider Linux and the Dalvik complicacy in memory management, the assailant also is difficult to accurately find core code concrete which address in internal memory, and the physical length of this section internal memory.In addition, all begin to adopt ASLR (address space distribution randomization) technology after present linux kernel and the Android 4.0, this further strengthened the assailant locate the core code memory address difficulty.
Moreover; Even if the assailant has finally obtained core code; To its conversed analysis with after revising; In the also extremely difficult memory headroom, more be difficult to the requirement application program and load the application heap (this relates to on-the-fly modifying of new Memory Allocation, programmed instruction etc.) that this part quilt is implanted its implantation application software place process.Therefore, can't crack using software.
In addition, the protection philosophy of Software Protection Technique according to the invention and other existing Software Protection Technique is also inequality, does not therefore also conflict, and can use jointly with existing other resist technologies, and for example character string information etc. is obscured, changed to code.Therefore, this scheme can be used with prior art jointly, protects software security more all sidedly.
Description of drawings
In order to be illustrated more clearly in the present invention or technical scheme of the prior art; To do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art below; Obviously, the accompanying drawing in describing below only is some embodiment that put down in writing among the present invention, for those of ordinary skills; Under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is a kind of Android platform software of the present invention protection system synoptic diagram;
Fig. 2 is the source code amending method process flow diagram of a kind of Android operating system of the present invention;
Fig. 3 is a line server workflow diagram of the present invention;
Fig. 4 is a line server system schematic of the present invention;
Fig. 5 is an intelligent terminal workflow diagram of the present invention;
Fig. 6 is an intelligent terminal system synoptic diagram of the present invention.
Embodiment
In order to make those skilled in the art person understand the technical scheme in the embodiment of the invention better, and make above-mentioned purpose of the present invention, feature and advantage can be more obviously understandable, below in conjunction with accompanying drawing technical scheme among the present invention done further detailed explanation.
At first introduce a kind of Android platform software protection system provided by the invention, as shown in Figure 1, comprise intelligent terminal 101 and line server 102:
Said intelligent terminal 101 comprises the non-core code of amended Android operating system and application software; Said amended Android operating system is made amendment to the source code of Android operating system, realizes the dynamic load of core code in internal memory of application software; The non-core code of said application software is among complete Android application program; Possesses the function beyond the needed function of application software; Comprise: send request to line server 102; Receive the core code that line server 102 is sent,, pass through the core code of api interface calling application software as required through verifying the core code of loading application software in internal memory afterwards;
The core code of line server 102 storage application software receives the non-core code sent request of application software in the intelligent terminal 101, and requested core code is sent to the non-core code of application software in the intelligent terminal 101 through after handling.
The core code of application software comprises DEX formatted file and SO formatted file.
The core code of line server 102 storage application software; Receive the non-core code sent request of application software in the intelligent terminal 101, some or all of requested core code is encrypted and/or requested core code is carried out sending to the non-core code of application software in the intelligent terminal 101 after the digital signature.
The present invention includes the method for revising Dalvik virtual machine and linux system, main flow process is as shown in Figure 2.
S201: revise the Dalvik virtual machine
The groundwork of revising the Dalvik virtual machine is; The ability of dalvik.system.DexClassLoader class among the expansion Android Framework; Make it receive the data of one section DEX formatted file in the internal memory; Mode to load the DEX formatted file loads this segment data, and provides with existing interface and similarly call the wherein interface of code.In addition, consider, the .odex temporary file that produces in the loading procedure is not stored in built-in nand flash memory of equipment or the external SD card, but also is kept in the internal memory from the angle of safety.
In the source code of Android 4.0.1_r1 version, realized a part of code of above-mentioned functions.
Particularly; In the libcore/dalvik/src/main/java/dalvik/system/DexFile.java of source code file; Have following JNI interface statement: native private static int openDexFile (byte [] fileContents), the function of this interface is to read a DEX formatted file in the byte arrays from internal memory.The function of this JNI interface realizes being positioned at the dalvik/vm/native/dalvik_system_DexFile.cpp file (the 248th row) of source code; Function name is Dalvik_dalvik_system_DexFile_openDexFile_bytearray; It has called the dvmRawDexFileOpenArray function, and the latter's realization is positioned at the dalvik/vm/RawDexFile.cpp file (the 249th row) of source code.Analyzing these two functions can know, it is when DEX formatted file structure of structure, and the .odex temporary file of generation also has been kept in the internal memory.
Next begin in source code, to increase some codes, to accomplish modification to the Dalvik virtual machine.
In the libcore/dalvik/src/main/java/dalvik/system/DexFile.java of source code file; For the DexFile class increases a constructed fuction, prototype is private DexFile (byte [] fileContents, int flags); Its code and existing private DexFile (String sourceName; String outputName, int flags) code of function is the same, but openDexFile wherein calls and uses foregoing that JNI interface.
In the libcore/dalvik/src/main/java/dalvik/system/DexFile.java of source code file; For the DexFile class increases a method; Prototype is static public DexFile loadDex (byte [] fileContents; Int flags), its code is similar with existing loadDex method, and difference is to call this DexFile constructed fuction that realize the front.
In the libcore/dalvik/src/main/java/dalvik/system/DexPathList.j of source code ava file; For the DexPathList class increases a method; Prototype is private static DexFile loadDexFile (byte [] fileContents); Modern in fact sign indicating number is similar with existing loadDexFile method, but calls the loadDex method of the DexFile class that realizes the front.
In the libcore/dalvik/src/main/java/dalvik/system/DexPathList.j of source code ava file; For the DexPathList class increases a method; Prototype is private static Element [] makeDexElements (byte [] fileContents); Modern in fact sign indicating number is similar with existing makeDexElements method, but in the if statement of the 207th row, only gets into article one branch, and calls the loadDexFile method of the DexPathList class that realizes the front.
In the libcore/dalvik/src/main/java/dalvik/system/DexPathList.j of source code ava file; For the DexPathList class increases a constructed fuction; Prototype is public DexPathList (ClassLoader definingContext; Byte [] fileContents), modern in fact sign indicating number is similar with existing constructed fuction, but calls the makeDexElements method of the DexPathList class that realizes the front.
In the libcore/dalvik/src/main/java/dalvik/system/BaseDexClassL of source code oader.java file; For the BaseDexClassLoader class increases a constructed fuction; Prototype is public BaseDexClassLoader (byte [] fileContents); Modern in fact sign indicating number is similar with existing constructed fuction, but calls the constructed fuction of the DexPathList class that realizes the front.
In the libcore/dalvik/src/main/java/dalvik/system/DexClassLoade of source code r.java file; For the DexClassLoader class increases a constructed fuction; Prototype is public DexClassLoader (byte [] fileContents); Modern in fact sign indicating number is the same with existing constructed fuction, but calls the constructed fuction of the BaseDexClassLoader class that realizes the front.
So far, we have obtained meeting amended Dalvik virtual machine source code of the presently claimed invention.
S202: revise linux system
The fundamental purpose of revising linux system is, linux kernel and system library in Android source code engineering partly increase partial code, make it increase an interface, and the major function of this interface is the data from one section SO formatted file of memory address loading of appointment.
The in the industry cycle existing at present accomplished in many ways of this work.For example; In glibc, increase the system call of a dlopen_mem (), prototype is void * dlopen_mem (char * addr, size_t len; Int flag), revise on the source code basis that modern in fact sign indicating number is existing dlopen () system call in the glibc java standard library and form.Particularly, first parameter of dlopen () is the disk path of the SO formatted file that will open, and it can be opened this file and its full content is read out.In the realization of dlopen_mem (), directly from parameter addr and len reading of data, the follow-up code that continues execution dlopen () then gets final product.
So far, we have obtained meeting amended linux system source code of the presently claimed invention.
S203: compiling Android engineering
Adopt conventional method with whole Android source code engineering compiling, generate corresponding system image, SDK developing instrument, NDK developing instrument.
Like this, in the SDK developing instrument that obtains, just can use newly-increased DexClassLoader (byte [] fileContents) interface, dynamic load DEX formatted file from internal memory; In the NDK developing instrument that obtains, just can use newly-increased dlopen_mem () system call, dynamic load SO formatted file from internal memory; In new system image, used the application software of above-mentioned interface and system call just can normally move.
The present invention also provides the workflow of the line server of storage core code, and is as shown in Figure 3, comprising:
S301: encryption core code
Core code exists with the form of DEX formatted file or SO formatted file, the general cryptographic algorithm of all or part of employing of core code is encrypted, to guarantee its confidentiality in transmission course.Symmetric cryptography can be used, also asymmetric encryption can be used.
For example, select symmetric encipherment algorithm AES, the key of use is designated as akey, and the file f ile that core code is belonged to encrypts the file f ile_enc after obtaining encrypting.
Select a rivest, shamir, adelman again, for example RSA is designated as rkey_pub with the PKI that uses, and private key is designated as rkey_pri.Use private key rkey_pri that AES key akey is encrypted, obtain the ciphertext akey_enc of akey.
Here, PKI that RSA Algorithm uses and private key are just generating in advance, and PKI rkey_pub is programmed in the corresponding client application software.
S302: signature core code
Adopt general Digital Signature Algorithm to sign to core code, to guarantee the integrality of file.
For example, adopt the most classical a kind of digital signature method.Use hash algorithm SHA1 that core code place file cipher text file_enc is carried out digital digest, obtain a cryptographic hash hvalue.
Use RSA Algorithm and above-mentioned private key rkey_pri that this cryptographic hash hvalue is encrypted, obtain ciphertext hvalue_enc.
S303: send to client
Core code is belonged to the ciphertext akey_enc of file cipher text file_enc, the used key of aes algorithm, the ciphertext hvalue_enc of cryptographic hash, together send to client.
Accordingly, the present invention also provides a kind of server, and is as shown in Figure 4, and said server is the line server 102 in the said system, and said server comprises:
Ciphering unit 401 is used for the core code of part or all of application software of storage is encrypted;
Digital signature unit 402 is used for the core code of application software of storage is carried out digital signature;
Transmitting element 403 is used for the file and the corresponding ciphertext at the core code of application software place are sent to intelligent terminal.
The present invention also provides the workflow of non-core code in the application software, in being installed to the application software of client, has comprised non-core code.These codes can be divided into two parts: one, with the relevant code of the concrete application of this software; Two, be responsible for loading the code of core code.The present invention only relates to a part of code in back, provides its groundwork flow process and implementation method below.As shown in Figure 5, comprising:
S501: receive file_enc, akey_enc, the hvalue_enc that S303 sends to client from server.
S502: certifying digital signature, to guarantee the integrality of file.
For example, to the endorsement method described in the S302, at first with the RSA PKI rkey_pub that selects and be programmed into application software in advance, deciphering hvalue_enc obtains cryptographic hash hvalue.
Next, with the SHA1 algorithm file_enc that sends is carried out digital digest, obtain another cryptographic hash hvalue2, relatively whether hvalue and hvalue2 be identical.
If inequality, think that then the core code that receives is incomplete, might be distorted, report unusually and withdraw from software.
If identical, think that then the core code that receives is complete, gets into next step.
S503:, obtain aes algorithm key akey with RSA PKI rkey_pub deciphering akey_enc.Use aes algorithm, as key, deciphering file_enc obtains the complete content that core code belongs to file f ile with akey.
S504: according to core code place file is DEX form or SO form, applies for the internal memory of this document size in Java or among the C, and file content is copied to wherein.
Particularly,, then adopt the byte array record memory address in the Java language,, use System.arraycopy method copy through new method application internal memory if file is the DEX form; If file is the SO form, then in NDK, use the char * pointer record memory address of C language, through malloc function application internal memory, use memcpy function copy, use int type variable record data length.
S505: call and revise the new function interface that Dalvik virtual machine and linux system obtain before this, from the internal memory of back, directly load core code.
If file is the DEX form; Then call public DexClassLoader (byte [] fileContents) constructed fuction that obtains among the S201; Memory address as parameter, is obtained a DexClassLoader object, promptly accomplished the dynamic load of DEX form object;
If file is the SO form, then call the void * dlopen_mem (char * addr, the size_t len that obtain among the S202; Int flag) system call; Its parameter addr is the memory address that obtains among the S504, and parameter l en is a data recorded length among the S504, and parameter f lag is 0; Obtain the handle of a void * type, promptly accomplished the dynamic load of SO form object.
S506:, call class in the core code, method, function etc. according to the real needs of application software.
If file is the DEX form, then use the loadClass () method of the DexClassLoader object that obtains among the S505, obtain such Class object according to the title of java class in the core code; Further, use the getDeclaredMethod method of this Class object,, obtain the Method object of the method in such according to the title of the method for the java class in the core code.Now, just can call the invoke method of this Method object, call this method.
If file is the SO form, then use the handle of the void * type that obtains among the S505, according to the title of C language function in the core code,, obtain the pointer of this function through dlsym () system call.Now, just can directly call this function pointer, move the code of wherein realization.
S507: but application software discharges the internal memory of having stored core code no longer need use core code the time.File is the DEX form when the core code place, then calls the delete method of byte [] object in the Java language; When file is the SO form, then call the free method in the C language.
Accordingly, the present invention also provides a kind of intelligent terminal, and said intelligent terminal is the intelligent terminal 101 in the said system, and said intelligent terminal 101 comprises amended Android operating system, also comprises:
Receivingelement 601 is used to receive the file and the corresponding ciphertext at the core code place of the application software that line server sends;
Authentication unit 602 is used for according to the be applied core code file of software of the file verification digital signature that receives and deciphering;
Loading unit 603 is used for core code document copying with application software to internal memory, and the interface that calls amended Android operating system is accomplished the loading of core code file;
Callunit 604 is used for as required the core code through api interface calling application software;
Releasingunit 605 is used to discharge the internal memory of storing core code.
Described intelligent terminal 101 also comprises:
Transmittingelement 600 needing to the line server transmission to be used for the request of application software core code.
The embodiment of method adopts the mode of going forward one by one to describe in this instructions, and for the system implementation example, because it is basically similar in appearance to method embodiment, so description is fairly simple, relevant part gets final product referring to the part explanation of method embodiment.
Though described the present invention through embodiment, those of ordinary skills know, the present invention has many distortion and variation and do not break away from spirit of the present invention, hope that appended claim comprises these distortion and variation and do not break away from spirit of the present invention.