A kind of Android platform software protection system, method and apparatus
Technical field
The present invention relates to a kind of protecting computer software technology, the software especially for Android platform is anti-divulges a secret and copyright protecting system and method, server and intelligent terminal.
Background technology
At present, the Android operation system dominating exploitation by Google company has been the mobile intelligent terminal platform that global market share is the highest.The application software quantity of Android constantly increases, and establishes good software marketing pattern.The same with conventional P C platform, the successful commercialization of Android application software, has also caused their conversed analysis and has cracked.
The conversed analysis (reversinganalysis) of application software is comprised:
One, the methods such as dis-assembling, decompiling, debugging are adopted to analyze to the executable code of software, to understand the execution flow process of its code and algorithm realization etc.;
Two, the configuration file of software and data file are analyzed, to obtain the form of these files and semantic etc.;
Three, the network communication data of software is analyzed, to obtain the protocol format of software and server communication, protocol semantics, data ciphering method and data concrete meaning etc.
Wherein, rear two alanysis are based upon on the basis of first kind analysis, namely need first to analyze executable code, could further analysis configuration file, data file, network communication data etc.
By conversed analysis, assailant can obtain the trade secret in software.Such as, in the anti-viral software of mobile phone, the executable codes such as Malicious Code Detection algorithm, Feature Correspondence Algorithm, and the data file such as malicious code feature database, once victim conversed analysis obtains detail, both may utilize by other similar softwares, also may be carried out specific aim defence or attack by malicious code authors.For another example, in the e-Bank payment software of mobile phone, authentication and the financial account information of user is related to by the data of Internet Transmission, once the victims such as software code, configuration file, network communication data are thoroughly understood by conversed analysis, just likely cause further malicious attack, direct economic loss is caused to individual and bank.
Cracking (cracking) is a kind of attack with special object on conversed analysis basis.Business software uses after needing user charges.To unpaid expense family, generally do not allow to use, maybe can only use a small amount of function, maybe can only use one period of trial period.In order to ensure this strategy, business software comprises the discriminating (being called " authentication code " by the code snippet being responsible for this discriminating work below) to user's license (License) and user identity usually, to judge whether user pays.Assailant is by the conversed analysis to authentication code, and distort code execution flow journey further, distort, copy or forge associated profile, distort network data, amendment internal storage data etc., the function making unpaid expense family also can obtain paying customer just to have.This attack is referred to as to crack, and it greatly compromises the economic rights and interests of software developer, violates the relevant law of intellectual property protection.
The applied software development of Android platform generally adopts Java language.Source code is compiled into java class file, use AndroidSDK(SoftwareDevelopmentKit again, SDK (Software Development Kit)) in instrument be converted to the binary executable of DEX form, finally be packaged into APK formatted file together with software merit rating, resource file etc., i.e. Android application software installation kit.User downloads APK formatted file, and is installed to Android terminal.When application software is run, perform among the Dalvik virtual machine of the instruction in DEX formatted file in android system.
Android is the wide-open operating system of source code.No matter the instruction coding method of DEX formatted file, or the principle of work of Dalvik virtual machine, all because source code is open known to people.There are at present all kinds of conversed analysis instruments for DEX formatted file, comprise disassemblers smali, decompiling instrument dex2jar, and for the automation tools such as apktool of APK formatted file.In addition, conversed analysis and the technology cracked have occurred for many years on conventional P C platform, and the assailant of Android platform has used for reference traditional method.Under the help of these tool and methods, current assailant can carry out conversed analysis to most Android application software easily and crack.
Such as, the common flow process that cracks is: use apktool to untie APK file, apktool can call smali and carry out dis-assembling to DEX formatted file wherein; Assailant analyzes the dis-assembling result of smali, understands the code flow of this application software; Then find authentication code, the part of key is modified, such as, conditional jump instructions during authentication is made into unconditional jump instruction; Re-use the code that these revised by apktool and be repackaged into APK formatted file, and again sign.So just obtain one crack after APK file.
In addition, Android application program can also use NDK(NativeDevelopmentKit, primary development kit) exploitation.Android system runs on Linux, and the Dalvik virtual machine at each application software place is an independently Linux process.AndroidNDK provides so a kind of development approach: programmer writes the partial function of software by C language, by the instrument of NDK source code is compiled as the dynamic link file (SO formatted file) in Linux; Write other functions with Java language, be compiled as DEX formatted file with SDK instrument; Finally by SDK, SO formatted file is packaged as APK formatted file together with DEX formatted file.Operationally, the code in DEX loads SO formatted file, and calls its function interface provided.
SO formatted file in NDK exploitation is the one of LinuxELF format standard, and order format is wherein ARM instruction set or the Thumb instruction set of ARM architecture.There are the decompiling such as disassemblers and the x86/ARMDecompiler instruments such as IDAPro can carry out conversed analysis to this file at present.
This platform defence conversed analysis and crack method comprise at present:
One, Code obfuscation.Namely automatically by equivalent but that the code of redundancy complexity replacement developer is hand-written Java source code, the workload that assailant carries out conversed analysis is improved.
Two, character string information is changed.In high-quality Java source code, bag, class, method, name of variables often have good readability, namely have clear and definite implication, therefore can guess its function by title.DEX file intactly saves these names, for conversed analysis provides conveniently.Such as, but most of name only uses in application program inside, self-defining class.If these names are replaced with insignificant character string, the operation of program can't be affected, but conversed analysis can be made to be absorbed in understanding difficulty.ProGuard instrument in AndroidSDK carrys out protection software in this way with regard to profit.
Three, NDK exploitation is used.As previously mentioned, the understanding to ARM form assembly language is related to the conversed analysis of SO file, improve the difficulty of software code being carried out to conversed analysis to a certain extent.
There is following problem in these methods:
1. be no matter the data after code or encryption, all with document form long-term existence among Android installation file and Android device, assailant can obtain easily;
2., by Code obfuscation, code still can be disassembled and decompiling, just improves the time understood required for code;
3., by change character string information, the logic of code itself does not change, and still can be disassembled and decompiling, equally just improve the time understood required for code;
4. be familiar with ARM form assembly language along with assailant understands gradually, and along with the continuous maturation of this platform decompiling instrument, the conversed analysis difficulty adopting the method for NDK exploitation to improve can be more and more lower.
In theory, the execution of application software in computing equipment finally all cannot be hidden by conversed analysis.The essence of software protection improves constantly conversed analysis and the difficulty cracked and time cost, and making assailant obtain valuable information needs the cost paid higher than its obtainable interests.
Software protection can bring extra software development cost, such as, increase development difficulty, extend the development time etc.Therefore, from the angle the need of special protection, the code of application software can be divided into two parts in logic:
One, non-core code, does not need special protection, such as, with interface, the multiplexing third party library code etc. of user interactions;
Two, core code, needs special protection, such as important algorithm, authentication code, important configuration data etc.
How these two parts divide, and do not have general method, are determined by the actual conditions of each application software.Such as, in anti-viral software, Malicious Code Detection algorithm, Feature Correspondence Algorithm etc. are all nucleus modules; In Net silver software, it is all nucleus module that user logs in code, financial transaction code etc.; In charge business software, paying code, authentication code etc. are all nucleus modules.
The invention still further relates to the amendment to DEX file Dynamic loading technique in android system.
Under normal circumstances, the DEX file in Android application software is the position of being specified by systematic conservation when mounted.In order to the ability of expanded application software, Android provides DEX file Dynamic loading technique.Specifically, application software operationally, the APK form do not installed before can loading one by dalvik.system.DexClassLoader class or JAR formatted file, and the DEX formatted file of " classes.dex " by name that comprise in this file is loaded on Dalvik virtual machine; Further, by methods such as such findClass (), the code realized in this DEX formatted file can be called.
Up to the present Android version (from 1.0 to 4.0), following requirements is there is: APK or the JAR formatted file containing " classes.dex " must be a physical file, in the nand flash memory that the equipment that is kept at is built-in or external SD card by said method dynamic load DEX formatted file; During dynamic load, system can generate a temporary file in the built-in nand flash memory of equipment or external SD card, and this file is the optimization (expansion .odex by name) to DEX formatted file.
Summary of the invention
For above technical matters, the present invention essentially discloses one protection application software in android system and is not subject to conversed analysis and cracks system and method.For Dalvik virtual machine in android system and linux system storehouse increase interface, Android is made to have the ability directly loading DEX formatted file and SO formatted file from internal memory; The core code of application software is stored in line server, encrypts and send to the application software being arranged on client after signing; Certifying signature after application software receives core code is also deciphered, then by stored in clear in internal memory, be directly loaded in system, then call code wherein, last releasing memory.The method substantially increases the difficulty that assailant carries out conversed analysis and cracks, the safety of energy available protecting Android application software.
The present invention is made up of three parts:
1, the Android operation system revised, realizes the dynamic load of DEX formatted file in internal memory;
2, the non-core code of application software, be arranged in intelligent terminal (comprising mobile phone, panel computer etc.), and this intelligent terminal uses the Android operation system of above-mentioned amendment;
3, the core code of application software, is stored in server online for a long time.
First, the source code of Android operation system is modified.Dalvik virtual machine increases such function, Dalvik virtual machine is made can directly to load a DEX formatted file from the memory address of specifying, and make application program can pass through bag name, class name, the method name of wherein code, call these codes and perform in Dalvik virtual machine.The Linux of Android bottom increases such function, makes Linux can directly load a SO formatted file from the memory address of specifying, and make application program can pass through the api interface of wherein code, call these codes and perform in Linux.
The core code of application software is the DEX formatted file be compiled into by the instrument of Java source code in AndroidSDK, or the SO formatted file be compiled into by the instrument of C source code in AndroidNDK.The server storing these core codes receives the request that in intelligent terminal, the non-core code of application software is sent, and the core code of being asked is encrypted, carried out digital signature, then sends to the application software in intelligent terminal.
The non-core code of application software is positioned among complete Android application program (i.e. APK formatted file).This application program is openly distributed by software developer, and user is mounted in intelligent terminal.Non-core code, except completing the function required for application software, also possesses following functions: send request to server, receives the core code sent, and verifies its digital signature; Apply for one section of internal memory, by core code deciphering to this section of internal memory; Be DEX form or SO form according to core code, make Dalvik virtual machine or Linux directly load core code from this section of internal memory, then called the function of core code as required by api interface; Finally when application software does not re-use core code, discharge this section of internal memory.
Specifically, the invention provides a kind of Android platform software protection system, comprise intelligent terminal and line server:
Described intelligent terminal comprises the non-core code of amended Android operation system and application software; The source code of described amended Android operation system to Android operation system is modified, and realizes the dynamic load of core code in internal memory of application software; The non-core code of described application software is among complete Android application program, possesses the function beyond the function required for application software, comprise: send request to line server, receive the core code that line server is sent, through the core code of loading application software in internal memory after checking, called the core code of application software as required by api interface;
Line server stores the core code of application software, receives the request that in intelligent terminal, the non-core code of application software is sent, and requested core code is sent to the non-core code of the application software in intelligent terminal after process.
The core code of described system software comprises DEX formatted file and SO formatted file.
The line server of described system stores the core code of application software, receive the request that the non-core code of application software is sent in intelligent terminal, some or all of requested core code is encrypted and/or sends to the non-core code of the application software in intelligent terminal after requested core code is carried out digital signature.
Present invention also offers a kind of source code amending method of Android operation system, be applicable to described system, described method comprises:
To the Dalvik virtual machine of Android operation system, the function of dalvik.system.DexClassLoader class in expansion AndroidFramework, dalvik.system.DexClassLoader class after expansion provides calling interface, receive the DEX formatted file in internal memory, load described DEX formatted file in the mode loading DEX formatted file;
In Android source code, the source code part of linux kernel and system library increases an interface, and described interface loads SO formatted file from the memory address of specifying;
Compile whole Android source code engineering, generate corresponding system image and developing instrument.
The .odex temporary file produced during DEX formatted file described in described method loads is kept in internal memory.
Present invention also offers a kind of Android platform software guard method, be applicable to described system, described method comprises:
The core code of line server to the part or all of application software stored is encrypted;
The core code of line server to the application software stored carries out digital signature;
The file at the core code place of application software and corresponding ciphertext are sent to intelligent terminal.
A kind of server provided by the invention, the line server in system described in described server, described server comprises:
Ciphering unit, for being encrypted the core code of the part or all of application software stored;
Digital signature unit, for carrying out digital signature to the core code of the application software stored;
Transmitting element, sends to intelligent terminal for the file at the core code place by application software and corresponding ciphertext.
A kind of Android platform software guard method provided by the invention, be applicable to described system, described method comprises:
The file at the core code place of the application software that intelligent terminal for reception line server sends and corresponding ciphertext;
The core code file of the software that is applied also is deciphered according to the file verification digital signature received;
By the core code file copy of application software in internal memory, the interface calling amended Android operation system completes the loading of core code file;
The core code of application software is called as required by api interface;
Discharge the internal memory storing core code.
Further, intelligent terminal, before the file receiving the core code place of application software that line server sends and corresponding ciphertext, sends the request needing application software core code to line server.
The invention provides a kind of intelligent terminal, described intelligent terminal is the intelligent terminal in described system, and described intelligent terminal comprises amended Android operation system, also comprises:
Receiving element, for receiving the file at the core code place of the application software that line server sends and corresponding ciphertext;
Authentication unit, for also deciphering the core code file of the software that is applied according to the file verification digital signature received;
Loading unit, for by the core code file copy of application software in internal memory, the interface calling amended Android operation system completes the loading of core code file;
Call unit, for calling the core code of application software as required by api interface;
Releasing unit, for dischargeing the internal memory storing core code.
Described intelligent terminal also comprises:
Transmitting element, for sending the request needing application software core code to line server.
The invention has the beneficial effects as follows:
One, compared with existing method of software Protection, the method for the invention makes the extremely difficult core code obtaining application software of assailant, thus cannot carry out conversed analysis to it.
First, the application software of open distribution does not comprise core code, assailant cannot as downloading to application software from software market or download website in the past, directly static dis-assembling is done to it and just can see all codes, obtain this partial code this application software to be run, make its connection server.
Secondly, the communication on server and intelligent terminal between application software adopts encryption and digital signature completely, even if assailant has captured network communication data, when not having key, cannot solve core code expressly.Use digital signature, also ensure that assailant pseudo-ly in this course cannot produce false core code, gain application software by cheating and load.
Finally, in the Android operation system of intelligent terminal, core code is only present in internal memory all the time, and only application software need wherein function time be present in internal memory, and not to be present in the built-in nand flash memory of equipment or external SD card with document form.At present, the Dalvik virtual machine that Android application program is run is positioned at independently in Linux process, and process authority is this application program, and exclusive user creates, and assailant is difficult to the virtual memory space reading core code place.Even if assailant can read, due to dynamic assignment when the memory headroom storing core code is operation, consider the complicacy of Linux and Dalvik in memory management, assailant is also difficult to accurately find core code which address concrete in internal memory, and the physical length of this section of internal memory.In addition, current linux kernel and Android4.0 start to adopt ASLR(address space to distribute randomization later) technology, this increase further assailant locate core code memory address difficulty.
Moreover, even if assailant finally obtains core code, after its conversed analysis and amendment, also extremely difficultly implanted in the memory headroom of application software place process, be more difficult to requirement application program and load this part of implanted application heap (this relates to new Memory Allocation, the on-the-fly modifying of programmed instruction).Therefore, cannot crack application software.
In addition, Software Protection Technique of the present invention is not identical with the protection philosophy of other existing Software Protection Technique, does not therefore conflict yet, and jointly can use with other resist technologies existing, such as Code obfuscation, change character string information etc.Therefore, this scheme can use jointly with prior art, more all sidedly protection software safety.
Accompanying drawing explanation
In order to be illustrated more clearly in the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, the accompanying drawing that the following describes is only some embodiments recorded in the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is a kind of Android platform software protection system of the present invention schematic diagram;
Fig. 2 is the source code amending method process flow diagram of a kind of Android operation system of the present invention;
Fig. 3 is line server workflow diagram of the present invention;
Fig. 4 is line server system schematic of the present invention;
Fig. 5 is intelligent terminal workflow diagram of the present invention;
Fig. 6 is intelligent terminal system schematic diagram of the present invention.
Embodiment
In order to make those skilled in the art person understand technical scheme in the embodiment of the present invention better, and enable above-mentioned purpose of the present invention, feature and advantage become apparent more, below in conjunction with accompanying drawing, technical scheme in the present invention is described in further detail.
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:
Described intelligent terminal 101 comprises the non-core code of amended Android operation system and application software; The source code of described amended Android operation system to Android operation system is modified, and realizes the dynamic load of core code in internal memory of application software; The non-core code of described application software is among complete Android application program, possesses the function beyond the function required for application software, comprise: send request to line server 102, receive the core code that line server 102 is sent, through the core code of loading application software in internal memory after checking, called the core code of application software as required by api interface;
Line server 102 stores the core code of application software, receives the request that in intelligent terminal 101, the non-core code of application software is sent, and requested core code is sent to the non-core code of the application software in intelligent terminal 101 after process.
The core code of application software comprises DEX formatted file and SO formatted file.
Line server 102 stores the core code of application software, receive the request that the non-core code of application software is sent in intelligent terminal 101, some or all of requested core code is encrypted and/or sends to the non-core code of the application software in intelligent terminal 101 after requested core code is carried out digital signature.
The present invention includes the method for amendment Dalvik virtual machine and linux system, main flow as shown in Figure 2.
S201: amendment Dalvik virtual machine
The groundwork of amendment Dalvik virtual machine is, the ability of dalvik.system.DexClassLoader class in expansion AndroidFramework, it is made to receive the data of one section of DEX formatted file in internal memory, load this segment data in the mode loading DEX formatted file, and the interface that calls wherein code similar with existing interface is provided.In addition, consider from the angle of safety, the .odex temporary file produced in loading procedure also will be made not to be stored in the built-in nand flash memory of equipment or external SD card, but be also kept in internal memory.
In the source code of Android4.0.1_r1 version, achieve a part of code of above-mentioned functions.
Specifically, in the libcore/dalvik/src/main/java/dalvik/system/DexFile.java file of source code, there is following JNI interface statement: nativeprivatestaticintopenDexFile (byte [] fileContents), the function of this interface reads a DEX formatted file from the byte arrays internal memory.The function of this JNI interface realizes the dalvik/vm/native/dalvik_system_DexFile.cpp file (the 248th row) being positioned at source code, function name is Dalvik_dalvik_system_DexFile_openDexFile_bytearray, it have invoked dvmRawDexFileOpenArray function, and the realization of the latter is positioned at the dalvik/vm/RawDexFile.cpp file of source code (the 249th row).Analyze these two functions known, it is when a structure DEX formatted file structure, and the .odex temporary file of generation has also been kept in internal memory.
Next start to increase some codes in source code, to complete the amendment to Dalvik virtual machine.
In the libcore/dalvik/src/main/java/dalvik/system/DexFile.java file of source code, for DexFile class increases a constructed fuction, prototype is privateDexFile (byte [] fileContents, intflags), its code and existing privateDexFile (StringsourceName, StringoutputName, intflags) code of function is the same, but openDexFile wherein calls use that JNI interface foregoing.
In the libcore/dalvik/src/main/java/dalvik/system/DexFile.java file of source code, for DexFile class increases a method, prototype is staticpublicDexFileloadDex (byte [] fileContents, intflags), its code is similar to existing loadDex method, and this DexFile constructed fuction realized is called in difference above.
In the libcore/dalvik/src/main/java/dalvik/system/DexPathList.j ava file of source code, for DexPathList class increases a method, prototype is privatestaticDexFileloadDexFile (byte [] fileContents), code is similar to existing loadDexFile method, but calls the loadDex method of the DexFile class realized above.
In the libcore/dalvik/src/main/java/dalvik/system/DexPathList.j ava file of source code, for DexPathList class increases a method, prototype is privatestaticElement [] makeDexElements (byte [] fileContents), code is similar to existing makeDexElements method, but in the if statement of the 207th row, only enter Article 1 branch, and call the loadDexFile method of the DexPathList class realized above.
In the libcore/dalvik/src/main/java/dalvik/system/DexPathList.j ava file of source code, for DexPathList class increases a constructed fuction, prototype is publicDexPathList (ClassLoaderdefiningContext, byte [] fileContents), code is similar to existing constructed fuction, but calls the makeDexElements method of the DexPathList class realized above.
In the libcore/dalvik/src/main/java/dalvik/system/BaseDexClassL oader.java file of source code, for BaseDexClassLoader class increases a constructed fuction, prototype is publicBaseDexClassLoader (byte [] fileContents), code is similar to existing constructed fuction, but calls the constructed fuction of the DexPathList class realized above.
In the libcore/dalvik/src/main/java/dalvik/system/DexClassLoade r.java file of source code, for DexClassLoader class increases a constructed fuction, prototype is publicDexClassLoader (byte [] fileContents), code is the same with existing constructed fuction, but calls the constructed fuction of the BaseDexClassLoader class realized above.
So far, we obtain and meet amended Dalvik virtual machine source code of the presently claimed invention.
S202: amendment linux system
The fundamental purpose of amendment linux system is, the linux kernel in Android source code engineering and system library part increase partial code, and make it increase an interface, the major function of this interface is the data loading one section of SO formatted file from the memory address of specifying.
This work in the industry cycle has accomplished in many ways at present.Such as, the system call of a dlopen_mem () is increased in glibc, prototype is void*dlopen_mem (char*addr, size_tlen, intflag), code be existing dlopen () system call in glibc java standard library source code basis on amendment form.Specifically, first parameter of dlopen () is the disk path of the SO formatted file that will open, and it can be opened this file and be read out by its full content.In the realization of dlopen_mem (), directly read data from parameter addr and len, then continue the follow-up code performing dlopen ().
So far, we obtain and meet amended linux system source code of the presently claimed invention.
S203: compiling Android engineering
Adopt conventional method by whole Android source code engineering compiling, generate corresponding system image, SDK developing instrument, NDK developing instrument.
Like this, in the SDK developing instrument obtained, just can use newly-increased DexClassLoader (byte [] fileContents) interface, dynamic load DEX formatted file from internal memory; In the NDK developing instrument obtained, just can use newly-increased dlopen_mem () system call, dynamic load SO formatted file from internal memory; In new system image, the application software employing above-mentioned interface and system call just can normally be run.
Present invention also offers the workflow of the line server storing core code, as shown in Figure 3, comprising:
S301: encryption core code
Core code exists with the form of DEX formatted file or SO formatted file, adopts general cryptographic algorithm to be encrypted to all or part of of core code, to ensure its confidentiality in transmitting procedure.Can symmetric cryptography be used, also can use asymmetric encryption.
Such as, select symmetric encipherment algorithm AES, the key of use is designated as akey, is encrypted the file f ile at core code place, obtains the file f ile_enc after encrypting.
Select rivest, shamir, adelman, such as a RSA again, the PKI of use is designated as rkey_pub, and private key is designated as rkey_pri.Use private key rkey_pri to AES key akey encryption, obtain the ciphertext akey_enc of akey.
Here, the PKI that RSA Algorithm uses and private key are just generating in advance, and are programmed in corresponding client application software by PKI rkey_pub.
S302: signature core code
General Digital Signature Algorithm is adopted to sign to core code, to ensure the integrality of file.
Such as, the most classical a kind of digital signature method is adopted.Use hash algorithm SHA1 to carry out digital digest to core code place file cipher text file_enc, obtain a cryptographic hash hvalue.
Use RSA Algorithm and above-mentioned private key rkey_pri to be encrypted this cryptographic hash hvalue, obtain ciphertext hvalue_enc.
S303: send to client
By core code place file cipher text file_enc, the ciphertext akey_enc of aes algorithm key used, the ciphertext hvalue_enc of cryptographic hash, together send to client.
Accordingly, present invention also offers a kind of server, as shown in Figure 4, described server is the line server 102 in described system, and described server comprises:
Ciphering unit 401, for being encrypted the core code of the part or all of application software stored;
Digital signature unit 402, for carrying out digital signature to the core code of the application software stored;
Transmitting element 403, sends to intelligent terminal for the file at the core code place by application software and corresponding ciphertext.
Present invention also offers the workflow of non-core code in application software, in the application software being installed to client, contain non-core code.These codes can be divided into two parts: one, relevant to this software embody rule code; Two, the code loading core code is responsible for.The present invention only relates to rear portion code, provides its main working process and implementation method below.As shown in Figure 5, comprising:
S501: receive file_enc, akey_enc, hvalue_enc that S303 sends to client from server.
S502: certifying digital signature, to ensure the integrality of file.
Such as, to the endorsement method described in S302, first use is selected in advance and is programmed into the RSA PKI rkey_pub of application software, and deciphering hvalue_enc, obtains cryptographic hash hvalue.
Next, with SHA1 algorithm, digital digest is carried out to the file_enc sent, obtain another cryptographic hash hvalue2, whether identically compare hvalue with hvalue2.
If not identical, then think that the core code received is incomplete, be likely tampered, report abnormal and exit software.
If identical, then think that the core code received is complete, enter next step.
S503: decipher akey_enc with RSA PKI rkey_pub, obtain aes algorithm key akey.With aes algorithm, using akey as key, deciphering file_enc, obtains the complete content of core code place file f ile.
S504: be DEX form or SO form according to core code place file, applies for the internal memory of this file size, and is copied to wherein by file content in Java or in C.
Specifically, if file is DEX form, then adopt the byte array record memory address in Java language, by new method application internal memory, use System.arraycopy method copy; If file is SO form, then in NDK, use the char* pointer record memory address of C language, by malloc function application internal memory, use memcpy function copy, use int type variable record data length.
S505: call the new function interface that amendment Dalvik virtual machine and linux system before this obtain, directly load core code from the internal memory of back.
If file is DEX form, then call publicDexClassLoader (byte [] fileContents) constructed fuction obtained in S201, using memory address as parameter, obtain a DexClassLoader object, namely complete the dynamic load of DEX format object;
If file is SO form, then call the void*dlopen_mem (char*addr obtained in S202, size_tlen, intflag) system call, its parameter addr is the memory address obtained in S504, and parameter len is the data length recorded in S504, and parameter f lag is 0, obtain the handle of a void* type, namely complete the dynamic load of SO format object.
S506: according to the real needs of application software, calls the class in core code, method, function etc.
If file is DEX form, then uses the loadClass () method of the DexClassLoader object obtained in S505, obtain such Class object according to the title of java class in core code; Further, use the getDeclaredMethod method of this Class object, according to the title of the method for the java class in core code, obtain the Method object of the method in such.Now, just can call the invoke method of this Method object, call the method.
If file is SO form, then uses the handle of the void* type obtained in S505, according to the title of C language function in core code, by dlsym () system call, obtain the pointer of this function.Now, just can directly call this function pointer, run the code wherein realized.
S507: but when application software no longer needs to use core code, discharge the internal memory storing core code.When core code place file is DEX form, then call the delete method of byte [] object in Java language; When file is SO form, then call the free method in C language.
Accordingly, present invention also offers a kind of intelligent terminal, described intelligent terminal is the intelligent terminal 101 in described system, and described intelligent terminal 101 comprises amended Android operation system, also comprises:
Receiving element 601, for receiving the file at the core code place of the application software that line server sends and corresponding ciphertext;
Authentication unit 602, for also deciphering the core code file of the software that is applied according to the file verification digital signature received;
Loading unit 603, for by the core code file copy of application software in internal memory, the interface calling amended Android operation system completes the loading of core code file;
Call unit 604, for calling the core code of application software as required by api interface;
Releasing unit 605, for dischargeing the internal memory storing core code.
Described intelligent terminal 101, also comprises:
Transmitting element 600, for sending the request needing application software core code to line server.
In this instructions, the embodiment of method adopts the mode of going forward one by one to describe, and for the embodiment of system, because it is substantially similar to embodiment of the method, so description is fairly simple, relevant part illustrates see the part of embodiment of the method.
Although depict the present invention by embodiment, those of ordinary skill in the art know, the present invention has many distortion and change and do not depart from spirit of the present invention, and the claim appended by wishing comprises these distortion and change and do not depart from spirit of the present invention.