CN110858249A - A kind of database file encryption method, decryption method and related device - Google Patents
A kind of database file encryption method, decryption method and related device Download PDFInfo
- Publication number
- CN110858249A CN110858249A CN201810972631.8A CN201810972631A CN110858249A CN 110858249 A CN110858249 A CN 110858249A CN 201810972631 A CN201810972631 A CN 201810972631A CN 110858249 A CN110858249 A CN 110858249A
- Authority
- CN
- China
- Prior art keywords
- information
- application
- key information
- encrypted
- database file
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 139
- 230000006870 function Effects 0.000 claims description 37
- 238000012545 processing Methods 0.000 claims description 22
- 238000003860 storage Methods 0.000 claims description 19
- 238000004590 computer program Methods 0.000 claims description 13
- 238000004891 communication Methods 0.000 claims description 9
- 238000005336 cracking Methods 0.000 abstract description 12
- 230000008569 process Effects 0.000 description 31
- 238000012795 verification Methods 0.000 description 19
- 238000010586 diagram Methods 0.000 description 12
- 238000012986 modification Methods 0.000 description 7
- 230000004048 modification Effects 0.000 description 7
- 230000001133 acceleration Effects 0.000 description 5
- 230000008901 benefit Effects 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 230000008447 perception Effects 0.000 description 3
- 238000007792 addition Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 239000004973 liquid crystal related substance Substances 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000005236 sound signal Effects 0.000 description 2
- 230000000007 visual effect Effects 0.000 description 2
- 241000699670 Mus sp. Species 0.000 description 1
- 230000005856 abnormality Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000007599 discharging Methods 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000005484 gravity Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012806 monitoring device Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 238000003825 pressing Methods 0.000 description 1
- 238000010079 rubber tapping Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000010897 surface acoustic wave method Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/30—Authentication, i.e. establishing the identity or authorisation of security principals
- G06F21/31—User authentication
- G06F21/32—User authentication using biometric data, e.g. fingerprints, iris scans or voiceprints
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
- G06F21/6218—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2221/00—Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F2221/21—Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F2221/2107—File encryption
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Health & Medical Sciences (AREA)
- Bioethics (AREA)
- Health & Medical Sciences (AREA)
- Databases & Information Systems (AREA)
- Storage Device Security (AREA)
Abstract
Description
技术领域technical field
本发明涉及数据安全技术领域,尤其涉及一种数据库文件加密方法、解密方法和相关装置。The invention relates to the technical field of data security, in particular to a database file encryption method, a decryption method and a related device.
背景技术Background technique
SQLCipher是一个在SQLite基础之上进行扩展的开源数据库,它主要是在SQLite的基础之上增加了数据加密功能,在项目中使用它来存储数据,可以大大提高程序的安全性。SQLCipher加密性能高,只要5%-15%的开销用于加密,且采用OpenSSL加密库提供的算法,完全做到数据库100%加密,因此非常适合移动开发过程的数据库保护。SQLCipher支持很多种不同的平台,例如可以应用到基于Android系统中应用,其他领域类似拓展。Android系统的数据库文件一般存储在/data/data/your_packagename/databases路径下,只要获得root权限就可以进入该目录,并可以查看、编辑应用数据,如果数据库存储了一些不允许用户查看和操作的敏感数据,则必须要给数据库加密。SqlCipher不是对表或列进行加密,而是对存储有敏感数据的整个数据库db文件加密,因而密钥的可靠性和难破解性就显得尤为重要。SQLCipher is an open source database extended on the basis of SQLite. It mainly adds data encryption function on the basis of SQLite. Using it to store data in the project can greatly improve the security of the program. SQLCipher has high encryption performance, only 5%-15% of the overhead is used for encryption, and the algorithm provided by the OpenSSL encryption library is used to completely encrypt 100% of the database, so it is very suitable for database protection in the mobile development process. SQLCipher supports many different platforms, for example, it can be applied to Android-based systems, and similar expansions in other fields. The database files of the Android system are generally stored in the /data/data/your_packagename/databases path. As long as you have root privileges, you can enter this directory, and you can view and edit application data. If the database stores some sensitive data that users are not allowed to view and operate data, the database must be encrypted. SqlCipher does not encrypt tables or columns, but encrypts the entire database db file that stores sensitive data, so the reliability and difficulty of cracking the key are particularly important.
现有的基于SQLCipher的密钥生成方法有以下几种:1、直接用明文密钥加密;2、对明文密钥进行加密得到密文密钥,然后利用密文密钥对数据库文件进行加密;3、动态生成明文密钥,然后利用加密算法生成密文密钥,再执行加密操作。上述几种方法在特定场合都有自己的适用性,但各有利弊,当对安全性要求较高时,极易通过静态分析、动态调试、反编译和反hook等方法破解密钥,从而拿到用户敏感数据,损害用户的利益。The existing SQLCipher-based key generation methods are as follows: 1. Encrypt directly with the plaintext key; 2. Encrypt the plaintext key to obtain the ciphertext key, and then use the ciphertext key to encrypt the database file; 3. Dynamically generate the plaintext key, then use the encryption algorithm to generate the ciphertext key, and then perform the encryption operation. The above methods have their own applicability in specific occasions, but each has its own advantages and disadvantages. When the security requirements are high, it is very easy to crack the key through static analysis, dynamic debugging, decompilation and anti-hook methods, so as to obtain the Sensitive data of users and harm the interests of users.
因此,如何提高数据库文件的安全性是首要考虑的问题之一。Therefore, how to improve the security of database files is one of the primary considerations.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供一种数据库文件加密方法、解密方法和相关装置,用以提高数据库文件的安全性。Embodiments of the present invention provide a database file encryption method, a decryption method and a related device, so as to improve the security of the database file.
第一方面,本发明实施例提供一种数据库文件加密方法,包括:In a first aspect, an embodiment of the present invention provides a database file encryption method, including:
在加密任一应用涉及的数据库文件时,判断该应用的指定目录中是否存在加密的密钥信息,其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的;When encrypting a database file involved in any application, determine whether there is encrypted key information in the specified directory of the application, wherein the encrypted key information is based on the device fingerprint information of the terminal and the application fingerprint information of the application. The key information is obtained by encrypting;
若是,则从读取到的所述加密的密钥信息中解密出密钥信息,并利用解密出的密钥信息加密所述数据库文件。If so, decrypt the key information from the read encrypted key information, and encrypt the database file by using the decrypted key information.
这样,通过利用密钥信息进行加密,然后利用终端的设备指纹信息和应用的应用指纹信息对密钥信息进行加密,这样能够保证一设备一应用一加密的密钥信息,从而提高了加密的数据库文件的破解难度。In this way, by using the key information for encryption, and then using the device fingerprint information of the terminal and the application fingerprint information of the application to encrypt the key information, it is possible to ensure that one device, one application and one encrypted key information, thereby improving the encrypted database. The difficulty of cracking the file.
第二方面,本发明实施例提供一种数据库文件解密方法,包括:In a second aspect, an embodiment of the present invention provides a method for decrypting a database file, including:
在接收到针对终端中应用的数据库文件的操作请求后,从所述应用的指定目录中获取加密的密钥信息,其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的;After receiving the operation request for the database file of the application in the terminal, obtain encrypted key information from the specified directory of the application, wherein the encrypted key information is based on the device fingerprint information of the terminal and the application's Obtained by encrypting the key information using fingerprint information;
从所述加密的密钥信息中解密出所述密钥信息;Decrypt the key information from the encrypted key information;
利用所述密钥信息对数据库文件进行解密并对解密后的数据库文件进行操作。The database file is decrypted by using the key information and the decrypted database file is operated.
第三方面,本发明实施例提供一种数据库文件加密装置,包括:In a third aspect, an embodiment of the present invention provides a database file encryption device, including:
判断单元,用于在加密任一应用涉及的数据库文件时,判断该应用的指定目录中是否存在加密的密钥信息,其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的;The judgment unit is used to judge whether there is encrypted key information in the specified directory of the application when encrypting the database file involved in any application, wherein the encrypted key information is based on the device fingerprint information of the terminal and the application. obtained by encrypting the key information with the application fingerprint information;
加解密单元,用于在所述判断单元的判断结果为是时,则从读取到的所述加密的密钥信息中解密出密钥信息,并利用解密出的密钥信息加密所述数据库文件。an encryption/decryption unit, configured to decrypt the key information from the read encrypted key information when the judgment result of the judgment unit is yes, and encrypt the database by using the decrypted key information document.
第四发明,本发明实施例提供一种数据库文件解密装置,包括:In the fourth invention, an embodiment of the present invention provides a database file decryption device, including:
获取单元,用于在接收到针对终端中应用的数据库文件的操作请求后,从所述应用的指定目录中获取加密的密钥信息,其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的;an obtaining unit, configured to obtain encrypted key information from a specified directory of the application after receiving an operation request for the database file applied in the terminal, wherein the encrypted key information is based on the device fingerprint of the terminal The information and the application fingerprint information of the application are obtained by encrypting the key information;
第一解密单元,用于从所述加密的密钥信息中解密出所述密钥信息;a first decryption unit for decrypting the key information from the encrypted key information;
第二解密单元,用于利用所述密钥信息对数据库文件进行解密并对解密后的数据库文件进行操作。The second decryption unit is configured to use the key information to decrypt the database file and operate the decrypted database file.
第五发明,本发明实施例提供一种通信设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序;所述处理器执行所述程序时实现如本发明提供的任一项所述的数据库文件加密方法,和/或实现如本发明提供的任一项所述的数据库文件解密方法。In the fifth invention, an embodiment of the present invention provides a communication device, including a memory, a processor, and a computer program stored on the memory and running on the processor; when the processor executes the program, the Any one of the database file encryption methods provided by the present invention, and/or implement any one of the database file decryption methods provided by the present invention.
第六方面,本发明实施例提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现如本发明提供的任一项所述的数据库文件加密方法中的步骤,和/或实现如本发明提供的任一项所述的数据库文件解密方法中的步骤。In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, implements the steps in the database file encryption method as provided in any one of the present invention , and/or implement the steps in the database file decryption method as provided in any one of the present invention.
本发明有益效果:Beneficial effects of the present invention:
本发明实施例提供的数据库文件加密方法,通过利用密钥信息对数据库文件进行加密,由于该密钥信息是利用终端的设备指纹信息和应用的应用指纹信息对密钥信息进行加密处理的,故提高了加密的密钥信息的破解难度,进而也就保证了加密的数据库文件的安全性。In the database file encryption method provided by the embodiment of the present invention, the database file is encrypted by using key information. Since the key information is encrypted by using the device fingerprint information of the terminal and the application fingerprint information of the application, the key information is encrypted. The difficulty of cracking the encrypted key information is improved, thereby ensuring the security of the encrypted database file.
本发明实施例提供的数据库文件解密方法,在接收到针对终端中应用的数据库文件的操作请求后,通过从应用的指定目录中读取加密的密钥信息,然后从加密的密钥信息中解密出密钥信息,再利用解密出的密钥信息对加密的数据库文件进行解密,从而在解密成功后对数据库文件进行操作,可以做到用户无感知的获取加密的密钥信息并解密出密钥信息,简化了用户操作流程。In the database file decryption method provided by the embodiment of the present invention, after receiving an operation request for a database file applied in a terminal, the encrypted key information is read from a specified directory of the application, and then decrypted from the encrypted key information. Obtain the key information, and then use the decrypted key information to decrypt the encrypted database file, so that the database file can be operated after the decryption is successful, so that the user can obtain the encrypted key information without perception and decrypt the key. information, which simplifies the user operation process.
本发明的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明而了解。本发明的目的和其他优点可通过在所写的说明书、权利要求书、以及附图中所特别指出的结构来实现和获得。Other features and advantages of the present invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention may be realized and attained by the structure particularly pointed out in the written description, claims, and drawings.
附图说明Description of drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本发明的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The accompanying drawings described herein are used to provide further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the attached image:
图1为本发明实施例提供的实施数据库文件加密方法或解密方法的终端100的结构示意图;1 is a schematic structural diagram of a
图2为本发明实施例提供的数据库文件加密方法的流程示意图之一;2 is one of the schematic flowcharts of a database file encryption method provided by an embodiment of the present invention;
图3为本发明实施例提供的加密的密钥信息生成方法的流程示意图之一;3 is one of the schematic flowcharts of a method for generating encrypted key information provided by an embodiment of the present invention;
图4为本发明实施例提供的对密钥信息进行加密得到加密的密钥信息的流程示意图;4 is a schematic flowchart of encrypting key information to obtain encrypted key information according to an embodiment of the present invention;
图5为本发明实施例提供的获取随机数的流程示意图;5 is a schematic flowchart of obtaining a random number according to an embodiment of the present invention;
图6为本发明实施例提供的利用设备指纹信息、应用指纹信息、随机数和预置的子密钥对密钥信息进行加密处理得到加密的密钥信息的流程示意图;6 is a schematic flowchart of performing encryption processing on key information to obtain encrypted key information by utilizing device fingerprint information, application fingerprint information, random numbers, and preset subkeys according to an embodiment of the present invention;
图7为本发明实施例提供的对加密的密钥信息进行完整性校验的流程示意图;7 is a schematic flowchart of performing integrity verification on encrypted key information according to an embodiment of the present invention;
图8为本发明实施例提供的数据库文件加密方法的流程示意图之二;8 is a second schematic flowchart of a database file encryption method provided by an embodiment of the present invention;
图9为本发明实施例提供的获取终端的设备指纹信息的流程示意图;9 is a schematic flowchart of acquiring device fingerprint information of a terminal according to an embodiment of the present invention;
图10为本发明实施例提供的获取应用的应用指纹信息的流程示意图;10 is a schematic flowchart of obtaining application fingerprint information of an application according to an embodiment of the present invention;
图11为本发明实施例提供的数据库文件解密方法的流程示意图之一;11 is one of the schematic flowcharts of a method for decrypting a database file according to an embodiment of the present invention;
图12为本发明实施例提供的解密加密的密钥信息的流程示意图;12 is a schematic flowchart of decrypting encrypted key information provided by an embodiment of the present invention;
图13为本发明实施例提供的数据库文件解密方法的流程示意图之二;13 is a second schematic flowchart of a method for decrypting a database file according to an embodiment of the present invention;
图14为本发明实施例提供的数据库文件解密方法的流程示意图之三;14 is a third schematic flowchart of a method for decrypting a database file provided by an embodiment of the present invention;
图15为本发明实施例提供的数据库文件加密装置的结构示意图;15 is a schematic structural diagram of a database file encryption device provided by an embodiment of the present invention;
图16为本发明实施例提供的数据库文件解密装置的结构示意图;16 is a schematic structural diagram of an apparatus for decrypting a database file provided by an embodiment of the present invention;
图17为实施本发明实施例提供的数据库文件加密、解密方法的终端设备的硬件结构示意图。FIG. 17 is a schematic diagram of a hardware structure of a terminal device implementing the method for encrypting and decrypting a database file provided by an embodiment of the present invention.
具体实施方式Detailed ways
本发明实施例提供的数据库文件加密方法、解密方法和相关装置,用以提高数据库文件的安全性。The database file encryption method, decryption method and related device provided by the embodiments of the present invention are used to improve the security of the database file.
以下结合说明书附图对本发明的优选实施例进行说明,应当理解,此处所描述的优选实施例仅用于说明和解释本发明,并不用于限定本发明,并且在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互组合。The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, but not to limit the present invention, and in the case of no conflict, the present invention The embodiments in and features in the embodiments can be combined with each other.
便于理解本发明,本发明涉及的技术术语中:To facilitate understanding of the present invention, in the technical terms involved in the present invention:
1、终端,为可以安装各类应用程序,并且能够将已安装的应用程序中提供的对象进行显示的电子设备,该电子设备可以是移动的,也可以是固定的。例如,手机、平板电脑、各类可穿戴设备、车载设备、个人数字助理(personal digital assistant,PDA)、销售终端(point of sales,POS)、地铁站内的监控设备或其它能够实现上述功能的电子设备等。1. A terminal is an electronic device that can install various application programs and can display objects provided in the installed application programs. The electronic device can be mobile or fixed. For example, mobile phones, tablet computers, various wearable devices, in-vehicle devices, personal digital assistants (PDAs), point of sales (POS), monitoring devices in subway stations, or other electronic devices that can realize the above functions equipment, etc.
2、应用,也即应用程序,为可以完成某项或多项特定工作的计算机程序,它具有可视的显示界面,能与用户进行交互,比如电子地图和微信等都可以称为应用。2. An application, that is, an application program, is a computer program that can complete one or more specific tasks. It has a visual display interface and can interact with users. For example, electronic maps and WeChat can be called applications.
3、高级加密标准,(Advanced Encryption Standard,AES),在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准。3. Advanced Encryption Standard (AES), also known as Rijndael encryption in cryptography, is a block encryption standard adopted by the US federal government.
4、密钥相关的哈希运输消息认证码,(Hash-based Message AuthenticationCode,HMAC),HMAC运算利用哈希算法,以一个密钥和一个消息为输入,生成一个消息摘要作为输出。4. Hash-based Message Authentication Code (HMAC) related to the key. The HMAC operation uses a hash algorithm, takes a key and a message as input, and generates a message digest as output.
5、在本发明实施例的描述中,“第一”、“第二”等词汇,仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。5. In the description of the embodiments of the present invention, words such as "first" and "second" are only used for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying the order. .
现有技术采用的直接用明文密钥对数据库执行加解密操作,但这里的明文密钥可以是用户自行设置,也可以是随机生成器产生,这样做的好处是操作简单,坏处是密钥容易被获取,当涉及到敏感数据时,安全性很低;现有技术采用的“利用加密算法对明文密钥进行加密得到密文密钥,然后利用密文密钥对数据库进行加解密操作”的方法,虽然采用密文密钥加密在一定程度上提高了安全性,但根据加密算法还是容易逆向分析和推导出明文密钥,同样存在安全隐患;现有技术采用的动态生成明文密钥的方法,虽然每次密钥不同,存在不易被破解的优点,但每次重新生成明文密钥会造成开销增大;此外,现有技术中还采用了将密钥存储在应用的服务端,将安全防护重点转移到通信和服务端的防护上,虽然在一定程度上提高了安全性,但会造成应用与服务端通信以及服务端自身安全防护压力增大。上述几种方法都有自己的应用场景,但当数据库文件安全性要求较高时,上述几种方法仍然存在安全隐患。The prior art adopts the plaintext key to directly perform encryption and decryption operations on the database, but the plaintext key here can be set by the user or generated by a random generator. The advantage of this is that the operation is simple, and the disadvantage is that the key is easy When sensitive data is involved, the security is very low; the existing technology adopts the method of "using an encryption algorithm to encrypt the plaintext key to obtain the ciphertext key, and then using the ciphertext key to encrypt and decrypt the database". Although the use of ciphertext key encryption improves the security to a certain extent, it is still easy to reversely analyze and derive the plaintext key according to the encryption algorithm, and there are also security risks; the method of dynamically generating the plaintext key adopted in the prior art , although the key is different each time, it has the advantage of being difficult to be cracked, but each time the plaintext key is regenerated, the overhead will increase; The focus of protection is shifted to the protection of communication and server. Although the security is improved to a certain extent, it will increase the pressure on the communication between the application and the server and the security protection of the server itself. The above methods have their own application scenarios, but when the security requirements of database files are high, the above methods still have security risks.
为了解决现有技术中数据库文件的安全性,本发明提出一种数据库文件加密方法,该方法可以应用到安装有能够实施本发明提供的方法的终端中,图1示出了一种终端100的结构示意图。参照图1所示,终端100包括:处理器110、存储器120、重力加速度传感器130、显示单元1/40、输入单元150、射频(radio frequency,RF)电路160以及电源170等。In order to solve the security of database files in the prior art, the present invention proposes a database file encryption method, which can be applied to a terminal capable of implementing the method provided by the present invention. FIG. 1 shows a terminal 100 Schematic. 1 , the terminal 100 includes: a
其中,处理器110是终端100的控制中心,利用各种接口和线路连接各个部件,通过运行或执行存储在存储器120内的软件程序和/或数据,执行终端100的各种功能,从而对终端进行整体监控。可选的,处理器110可包括一个或多个处理单元;优选的,处理器110可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器110中。在一些实施例中,处理器、存储器、可以在单一芯片上实现,在一些实施例中,它们也可以在独立的芯片上分别实现。The
存储器120可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、各种应用程序等;存储数据区可存储根据终端100的使用所创建的数据等。此外,存储器120可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件等。The
重力加速度传感器130可检测各个方向上(一般为三轴)加速度的大小,同时,该重力加速度传感器130还可用于检测终端静止时重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等。The
显示单元140可用于显示由用户输入的信息或提供给用户的信息以及终端100的各种菜单等,本发明实施例中主要用于显示终端100中各应用程序的显示界面以及显示界面中显示的文本、图片等对象。显示单元140可以包括显示面板141。显示面板141可以采用液晶显示屏(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-EmittingDiode,OLED)等形式来配置。The
输入单元150可用于接收用户输入的数字或字符等信息。输入单元150可包括触控面板151以及其他输入设备152。其中,触控面板151,也称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触摸笔等任何适合的物体或附件在触控面板151上或在触控面板151附近的操作),例如本发明实施例中的触控面板151可用于检测是否有用户的按压操作。具体的,触控面板151可以检测用户的触摸操作,并检测触摸操作带来的信号,将这些信号转换成触点坐标,发送给处理器110,并接收处理器110发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板151。其他输入设备152可以包括但不限于物理键盘、功能键(比如音量控制按键、开关机按键等)、轨迹球、鼠标、操作杆等中的一种或多种。The
当然,触控面板151可覆盖显示面板141,当触控面板151检测到在其上或附近的触摸操作后,传送给处理器110以确定触摸事件的类型,随后处理器110根据触摸事件的类型在显示面板141上提供相应的视觉输出。虽然在图2中,触控面板151与显示面板141是作为两个独立的部件来实现终端100的输入和输出功能,但是在某些实施例中,可以将触控面板151与显示面板141集成而实现终端100的输入和输出功能。Of course, the
终端100还可包括RF电路160,可用于和基站进行收发信息或数据。通常,RF电路160包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(low noiseamplifier,LNA)、双工器等。本发明实施例中,RF电路160可以通过无线通信与网络和其他电子设备通信,上述无线通信可以使用任一通信标准或协议。The terminal 100 may also include an
终端100还包括给各个部件供电的电源170(比如电池),电源可以通过电源管理系统与处理器110逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗等功能。The terminal 100 also includes a power supply 170 (such as a battery) for supplying power to various components. The power supply can be logically connected to the
终端100还可以包括音频电路180、扬声器181、麦克风182可提供用户与终端之间的音频接口。音频电路180可将接收到的音频数据转换后的电信号传输到扬声器181,由扬声器181转换为声音信号输出;另一方面,麦克风182将收集的声音信号转换为电信号,由音频电路180接收后转换为音频数据,再将音频数据输出处理器110处理后输出,或者将音频数据输出至存储器120以便进一步处理。The terminal 100 may further include an
终端100还可包括一个或多个传感器,例如压力传感器、重力加速度传感器、接近光传感器等。当然,根据具体应用中的需要,上述终端100还可以包括摄像头等其它部件,由于这些部件不是本申请实施例中重点使用的部件,因此,在图1中没有示出,且不再详述。The terminal 100 may further include one or more sensors, such as a pressure sensor, a gravitational acceleration sensor, a proximity light sensor, and the like. Of course, according to the needs of specific applications, the above-mentioned
本领域技术人员可以理解,图1仅仅是终端的举例,并不构成对终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件。Those skilled in the art can understand that FIG. 1 is only an example of a terminal, and does not constitute a limitation on the terminal, and may include more or less components than the one shown, or combine some components, or different components.
本发明提供的数据库文件加密方法和数据库文件解密方法的应用场景是,将本发明提供的加密方法和解密方法集成到软件工具开发包(Software Development Kit,SDK)中,然后将SDK集成到应用开发商开发的应用中,即在SQLCipher集成上述SDK,当用户在终端中下载集成了上述具有数据库文件加解密功能的SDK的应用时,现在的应用一般都需要用户注册,而且有些应用会涉及充值等交易,为了避免用户每次登录应用都需要输入用户名和密码等信息和保证涉及交易的用户的数据的安全性,可以采用本发明提供的方法对存储有这些敏感数据的数据库文件进行加密处理,从而可以保证数据库文件的安全性,进而保证敏感数据的安全性。此外,当检测到数据库文件时,通过内部调用SDK工具来读取加密的密钥信息,并利用解密出的密钥信息解密加密的数据库文件,以实现数据库文件的解密,无需用户手动输入密钥信息,在用户无感知的情况下就可以实现对数据库文件的解密,不仅简化了操作流程而且提高了用户体验。The application scenario of the database file encryption method and the database file decryption method provided by the present invention is to integrate the encryption method and decryption method provided by the present invention into a software tool development kit (Software Development Kit, SDK), and then integrate the SDK into application development In the application developed by the developer, that is, integrating the above SDK in SQLCipher, when the user downloads the application integrating the above SDK with the database file encryption and decryption function in the terminal, the current application generally requires the user to register, and some applications will involve recharge, etc. For transactions, in order to avoid users needing to input information such as user names and passwords every time they log in to the application and to ensure the security of the data of users involved in transactions, the method provided by the present invention can be used to encrypt the database files that store these sensitive data, thereby The security of database files can be guaranteed, thereby ensuring the security of sensitive data. In addition, when a database file is detected, the encrypted key information is read by calling the SDK tool internally, and the encrypted database file is decrypted by using the decrypted key information, so as to realize the decryption of the database file without the need for the user to manually enter the key Information, the database file can be decrypted without the user's perception, which not only simplifies the operation process but also improves the user experience.
下面结合图1和上述描述的应用场景,参考图2-图17来描述根据本发明示例性实施方式提供的数据库文件加密方法和数据库文件解密方法。需要注意的是,上述应用场景仅是为了便于理解本发明的精神和原理而示出,本发明的实施方式在此方面不受任何限制。相反,本发明的实施方式可以应用于适用的任何场景。The following describes the database file encryption method and the database file decryption method provided according to the exemplary embodiment of the present invention with reference to FIG. 2 to FIG. 17 in conjunction with FIG. 1 and the application scenarios described above. It should be noted that the above application scenarios are only shown for the convenience of understanding the spirit and principle of the present invention, and the embodiments of the present invention are not limited in this respect. Rather, embodiments of the present invention can be applied to any scenario where applicable.
参考图2所示,为本发明实施例提供的数据库文件加密方法的流程示意图,在下文的介绍过程中,以将该方法应用在图1所示的终端100为例。该方法的具体实施流程如下:Referring to FIG. 2 , it is a schematic flowchart of a database file encryption method provided by an embodiment of the present invention. In the following introduction process, the method is applied to the terminal 100 shown in FIG. 1 as an example. The specific implementation process of the method is as follows:
S11、在加密任一应用涉及的数据库文件时,判断该应用的指定目录中是否存在加密的密钥信息;若是则执行步骤S12;否则执行步骤S13。S11. When encrypting a database file involved in any application, determine whether there is encrypted key information in the designated directory of the application; if so, go to step S12; otherwise, go to step S13.
本发明中加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的,后续详细介绍之。The encrypted key information in the present invention is obtained by encrypting the key information according to the device fingerprint information of the terminal and the application fingerprint information of the application, which will be described in detail later.
具体地,本发明中的应用的指定目录可以根据实际情况而定,本发明对此不进行限定。Specifically, the specified directory of the application in the present invention may be determined according to the actual situation, which is not limited in the present invention.
S12、从读取到的所述加密的密钥信息中解密出密钥信息,并利用解密出的密钥信息加密所述数据库文件。S12. Decrypt the key information from the read encrypted key information, and encrypt the database file by using the decrypted key information.
在步骤S11判断结果为是时,表明该应用的指定目录中存储有加密的密钥信息,也就是说之前已执行过密钥信息的加密及存储过程。When the determination result in step S11 is yes, it indicates that encrypted key information is stored in the designated directory of the application, that is, the encryption and storage process of the key information has been performed before.
具体地,可以通过内部调用getTerminalKey()函数读取所述加密的密钥信息。具体实施时,通过在SQLCipher的SQLiteOpenHelper类中添加getTerminalKey()函数,该函数用于调用密钥生成工具SDK中TerminalCypto类的ReceiveTerminalKey()函数来读取密钥信息,并赋值给变量password,用于后续的加解密数据库db文件,无需在数据库操作函数中直接传递密钥信息。Specifically, the encrypted key information can be read by calling the getTerminalKey() function internally. In specific implementation, the getTerminalKey() function is added to the SQLiteOpenHelper class of SQLCipher. This function is used to call the ReceiveTerminalKey() function of the TerminalCypto class in the key generation tool SDK to read the key information, and assign it to the variable password for Subsequent encryption and decryption of the database db file does not need to directly pass the key information in the database operation function.
在SQLiteOpenHelper类中,重载了getWritableDatabase(char[]password)和getReadableDatabase(String password),去掉了password入参,改为getWritableDatabase()和getReadableDatabase(),函数内部调用getTerminalKey()函数获取赋值给password的加密的密钥信息。In the SQLiteOpenHelper class, getWritableDatabase(char[]password) and getReadableDatabase(String password) are overloaded, and the password input parameter is removed, and changed to getWritableDatabase() and getReadableDatabase(). Encrypted key information.
在SQLiteDatabase类中,重载了openOrCreateDatabase(String path,Stringpassword,CursorFactory factory,SQLiteDatabaseHookdatabaseHook),同上述一样,去掉password入参,改为openOrCreateDatabase(String path,Context context,SQLiteDatabase.CursorFactory factory,SQLiteDatabaseHook databaseHook),函数内部调用getTerminalKey()函数获取赋值给password的加密的密钥信息。In the SQLiteDatabase class, overloaded openOrCreateDatabase(String path, Stringpassword, CursorFactory factory, SQLiteDatabaseHookdatabaseHook), the same as above, remove the password input parameter and change it to openOrCreateDatabase(String path, Context context, SQLiteDatabase.CursorFactory factory, SQLiteDatabaseHook databaseHook), the function The getTerminalKey() function is called internally to obtain the encrypted key information assigned to password.
S13、随机产生密钥信息并利用产生的密钥信息加密所述数据库文件。S13. Randomly generate key information and encrypt the database file using the generated key information.
本步骤中,在步骤S11检测到上述指定目录中未存储加密的密钥信息时,则随机生成一个密钥信息key2,实际应用中随机生成的密钥信息key2也是一个随机数。在生成该密钥信息key2后,将key2传递给SDK工具中的TerminalCypto类的ReceiveTerminalKey函数,SQLCipher中通过添加在SQLiteOpenHelper类中的getTerminalKey()函数来获取SDK中的密钥信息,而无需在数据库操作函数中直接传递密钥信息。In this step, when it is detected in step S11 that the encrypted key information is not stored in the above designated directory, a key information key 2 is randomly generated, and the randomly generated key information key 2 is also a random number in practical applications. After the key information key 2 is generated, pass the key 2 to the ReceiveTerminalKey function of the TerminalCypto class in the SDK tool. In SQLCipher, the getTerminalKey() function added in the SQLiteOpenHelper class is used to obtain the key information in the SDK without needing to The key information is directly passed in the database operation function.
通过执行步骤S11~S13的流程,针对任一应用,产生的密钥信息对数据库文件进行加密处理,从而保证了数据库文件中敏感数据的安全性,此外,为了防止密钥信息被窃取,本发明提出利用终端的设备指纹信息和该应用的应用指纹信息对密钥信息进行加密处理,然后将加密的密钥信息存储到该应用的指定目录中,从而提高了加密的密钥信息的防破解能力,进一步提高了加密的数据库文件中敏感数据的安全性。此外,采用本发明提供的密钥信息加密方法,实现了同一终端上不同的应用加密得到加密的密钥信息不同,且不同终端由于终端的设备指纹不同,故也保证了不同终端的同一应用的加密的密钥信息不同,由此提高了加密的密钥信息的防破解能力。By executing the flow of steps S11 to S13, for any application, the generated key information encrypts the database file, thereby ensuring the security of the sensitive data in the database file. In addition, in order to prevent the key information from being stolen, the present invention It is proposed to use the device fingerprint information of the terminal and the application fingerprint information of the application to encrypt the key information, and then store the encrypted key information in the specified directory of the application, thereby improving the anti-cracking ability of the encrypted key information , which further improves the security of sensitive data in encrypted database files. In addition, by using the key information encryption method provided by the present invention, different applications on the same terminal are encrypted to obtain different encrypted key information, and different terminals have different device fingerprints, so the same application of different terminals is also guaranteed. The encrypted key information is different, thereby improving the anti-cracking capability of the encrypted key information.
较佳地,在执行步骤S13之后,还需要对随机产生的密钥信息进行加密处理,具体可以参考图3或图4所示的加密的流程,此外步骤S11中涉及的加密的密钥信息也是按照图3或图4所示的加密流程执行的,以下详细介绍之:Preferably, after step S13 is performed, it is also necessary to encrypt the randomly generated key information. For details, please refer to the encryption process shown in FIG. 3 or FIG. 4 . In addition, the encrypted key information involved in step S11 is also It is performed according to the encryption process shown in Figure 3 or Figure 4, and is described in detail below:
一种可能的实施方式中,如图3所示,为本发明实施例提供的加密的密钥信息生成方法的流程示意图,可以包括以下步骤:In a possible implementation manner, as shown in FIG. 3 , it is a schematic flowchart of a method for generating encrypted key information provided by an embodiment of the present invention, which may include the following steps:
S21、获取终端的设备指纹信息和该应用的应用指纹信息。S21. Acquire device fingerprint information of the terminal and application fingerprint information of the application.
S22、利用所述设备指纹信息和所述应用指纹信息对密钥信息进行加密处理得到加密的密钥信息。S22. Encrypt key information by using the device fingerprint information and the application fingerprint information to obtain encrypted key information.
步骤S21和步骤S22中,可以利用AES加密算法对上述设备指纹信息和应用指纹信息加密处理,然后再利用加密得到的信息对密钥信息进行加密处理得到加密的密钥信息。步骤S21和S22中的密钥信息可以为步骤S11中涉及的密钥信息,也可以为步骤S13中随机产生的密钥信息。由于终端的设备指纹信息用于唯一标识终端,而应用的应用指纹信息用于唯一标识应用,则利用终端的设备指纹信息和应用指纹信息来加密密钥信息时,能够保证一个终端设备中一应用对应一个加密的密钥信息,提高了加密的密钥信息的安全性和破解难度,进而也就保证了利用密钥信息加密的数据库文件中敏感数据的安全性。In steps S21 and S22, the above-mentioned device fingerprint information and application fingerprint information can be encrypted by using the AES encryption algorithm, and then the encrypted key information can be obtained by encrypting the key information using the encrypted information. The key information in steps S21 and S22 may be the key information involved in step S11, or may be the key information randomly generated in step S13. Since the device fingerprint information of the terminal is used to uniquely identify the terminal, and the application fingerprint information of the application is used to uniquely identify the application, when the device fingerprint information and the application fingerprint information of the terminal are used to encrypt the key information, one application in one terminal device can be guaranteed. Corresponding to an encrypted key information, the security of the encrypted key information and the difficulty of cracking are improved, thereby ensuring the security of sensitive data in the database file encrypted by the key information.
另一种可能的实施方式中,为了进一步提高加密的密钥信息的安全性,还可以按照图4所示的流程对密钥信息进行加密得到加密的密钥信息,包括以下步骤:In another possible implementation, in order to further improve the security of the encrypted key information, the encrypted key information can also be obtained by encrypting the key information according to the process shown in FIG. 4 , including the following steps:
S31、获取终端的设备指纹信息、该应用的应用指纹信息和随机数。S31. Acquire device fingerprint information of the terminal, application fingerprint information of the application, and a random number.
本步骤中,可以按照图5所示的流程获取随机数,包括以下步骤:In this step, the random number can be obtained according to the process shown in Figure 5, including the following steps:
S41、向应用的服务器发送随机数获取请求。S41. Send a random number acquisition request to an application server.
本发明中随机数获取请求中携带有所述终端的终端标识和该应用的应用标识。In the present invention, the random number acquisition request carries the terminal identification of the terminal and the application identification of the application.
具体地,为了进一步保证数据库文件的安全性,终端中的应用会向服务器发送随机数获取请求,服务器在接收到随机数获取请求后,根据终端标识、应用标识和随机数三者之间的对应关系,会确定是否为该应用生成随机数,若是则上述对应关系中必然存储有请求中携带的终端标识和应用的应用标识对应的随机数,然后将上述随机数进行加密处理,并将加密的随机数发送给终端。若确定出上述对应关系中未存储有请求中携带的终端标识和应用标识,则表明未为该终端中的该应用生成随机数,则表明该随机数获取请求为第一次请求,则为该终端中该应用随机生成一个随机数,然后对该随机数进行加密处理并将加密后的随机数发送给终端。Specifically, in order to further ensure the security of the database file, the application in the terminal will send a random number acquisition request to the server. relationship, it will determine whether to generate a random number for the application, and if so, the random number corresponding to the terminal identification carried in the request and the application identification of the application must be stored in the above corresponding relationship, and then the above random number is encrypted, and the encrypted The random number is sent to the terminal. If it is determined that the terminal identification and application identification carried in the request are not stored in the above corresponding relationship, it indicates that a random number is not generated for the application in the terminal, indicating that the random number acquisition request is the first request, and the The application in the terminal randomly generates a random number, then encrypts the random number and sends the encrypted random number to the terminal.
S42、判断终端是否成功接收到服务器下发的随机数;若是则执行步骤S43;若否,则执行步骤S47。S42: Determine whether the terminal has successfully received the random number sent by the server; if yes, go to step S43; if not, go to step S47.
具体地,可以通过检测终端是否向服务器发送上述获取请求的响应消息,响应消息中的具体内容可以由应用与服务器进行协商而定,由此可以根据响应消息来确定是否成功接收到服务器下发的随机数。Specifically, it can be detected whether the terminal sends the response message of the acquisition request to the server, and the specific content of the response message can be determined by the application and the server through negotiation, so whether the response message sent by the server is successfully received can be determined according to the response message. random number.
S43、获取服务器下发的随机数。S43: Obtain the random number issued by the server.
基于此,在成功接收时,可以获取到服务器下发的随机数。在成功接收之后,为了避免多次向服务器获取随机数而导致的应用与服务器交互太多所造成的处理资源浪费,本发明提出在获取到随机数后,还需要执行步骤S44~S46所示的存储过程。Based on this, upon successful reception, the random number sent by the server can be obtained. After successful reception, in order to avoid the waste of processing resources caused by too many interactions between the application and the server caused by obtaining the random number from the server for many times, the present invention proposes that after the random number is obtained, it is also necessary to perform the steps shown in steps S44 to S46. stored procedure.
S44、判断终端是否具有安全元件SE权限,若是,则执行步骤S45;否则执行步骤S46。S44. Determine whether the terminal has the security element SE authority, if yes, execute step S45; otherwise, execute step S46.
S45、在确定出所述SE中未存储随机数时,将接收到的随机数用白盒进行加密并将加密后的随机数存储到SE中。S45. When it is determined that the random number is not stored in the SE, encrypt the received random number with a white box and store the encrypted random number in the SE.
具体地,为了避免多次向服务器获取随机数,本发明在获取到随机数中,会判断是否具有SE权限,若有则将获取到的随机数存储到SE中,由于SE权限是比较难拿到的,当该终端具有SE权限时表明该终端对安全性要求较高,而由于SE权限较高,相应其安全性也较高,故将随机数存储到SE中,会加大随机数的安全性,进而也就加大了加密的密钥信息的破解难度。此外,为了进行一步提高加密的密钥信息的破解难度,本发明在将SE中写入随机数之前,采用白盒加密的方法对随机数进行加密处理然后将加密的随机数存到SE中。若SE中存储有该应用的随机数,则可以利用加密的随机数覆盖SE中存储的该应用的随机数。Specifically, in order to avoid obtaining random numbers from the server multiple times, the present invention will determine whether the random number has the SE authority, and if so, the obtained random number will be stored in the SE, because the SE authority is relatively difficult to obtain. Yes, when the terminal has the SE authority, it indicates that the terminal has higher security requirements, and because the SE authority is higher, the corresponding security is also higher, so storing the random number in the SE will increase the random number. Security, which in turn increases the difficulty of cracking the encrypted key information. In addition, in order to further improve the difficulty of cracking the encrypted key information, the present invention adopts the white box encryption method to encrypt the random number before writing the random number into the SE, and then stores the encrypted random number in the SE. If the random number of the application is stored in the SE, the random number of the application stored in the SE can be overwritten with the encrypted random number.
S46、在确定出数据库文件开始位置未存储随机数时,将接收到的随机数用白盒进行加密并将加密后的随机数存储到数据库文件开始位置处。S46. When it is determined that the random number is not stored in the starting position of the database file, encrypt the received random number with a white box and store the encrypted random number at the starting position of the database file.
当终端不具备SE权限时,为了避免多次向服务器获取随机数,本发明在获取到随机数中,还会判断该应用对应的数据库文件的开始位置是否存储有随机数,若不存在则将接收到的随机数存储到数据库文件的开始位置,为了进一步提高加密的密钥信息的破解难度,在将随机数存储到数据库文件的开始位置时,可以先对随机数进行白盒加密处理,然后将加密处理后的随机数存储到数据库文件的开始位置。当数据库文件中存储有该应用的随机数时,则利用接收到的随机数更新数据库文件开始位置存储的该应用的随机数。When the terminal does not have the SE authority, in order to avoid obtaining the random number from the server multiple times, the present invention will also determine whether the random number is stored in the starting position of the database file corresponding to the application when the random number is obtained. The received random number is stored at the beginning of the database file. In order to further improve the difficulty of cracking the encrypted key information, when the random number is stored at the beginning of the database file, white-box encryption can be performed on the random number first, and then Store the encrypted random number at the beginning of the database file. When the random number of the application is stored in the database file, the random number of the application stored in the starting position of the database file is updated by using the received random number.
S47、确定安全元件SE中是否存储有随机数;若是则执行步骤S48;否则执行步骤S49。S47 , determine whether a random number is stored in the secure element SE; if so, go to step S48 ; otherwise, go to step S49 .
当步骤S42未成功接收到服务器下发的随机数时,表明可能因为网络异常导致终端无法收到服务器下发的随机数,则此时判断SE中是否存储有该应用对应的随机数,若存在则从SE中提取出该应用的随机数。When the random number sent by the server is not successfully received in step S42, it indicates that the terminal may not be able to receive the random number sent by the server due to a network abnormality. At this time, it is judged whether the random number corresponding to the application is stored in the SE. Then the random number of the application is extracted from SE.
S48、从SE中获取随机数。S48. Obtain a random number from the SE.
S49、确定数据库文件开始位置是否存储有随机数,若是,则执行步骤S410;否则再次执行步骤S41。S49: Determine whether a random number is stored in the starting position of the database file, if so, execute step S410; otherwise, execute step S41 again.
S410、从数据库文件开始位置获取所述随机数。S410. Obtain the random number from the starting position of the database file.
步骤S49~S410中,当SE中未存储有该应用的随机数,则判断数据库文件的开始位置是否存储有该应用的随机数,若存在则从上述开始位置提取该应用对应的随机数,由此通过执行步骤S41~S410可以获取到随机数。In steps S49 to S410, when the random number of the application is not stored in the SE, it is judged whether the random number of the application is stored in the starting position of the database file, and if so, the random number corresponding to the application is extracted from the above starting position, and the number of the random number corresponding to the application is extracted from the above starting position. The random number can be obtained by executing steps S41-S410.
需要说明的是,步骤S41~S410所示的步骤可以每加密一次数据库文件就向服务器请求一次随机数,这样可以保证随机数的动态下发,进而保证加密的密钥信息的动态变化,从而大大提高了加密的密钥信息的安全性,进而也就提升了数据库文件的防破解难度。It should be noted that the steps shown in steps S41 to S410 may request a random number from the server every time the database file is encrypted, so as to ensure the dynamic distribution of the random number, thereby ensuring the dynamic change of the encrypted key information, thereby greatly reducing the need for The security of the encrypted key information is improved, and the difficulty of preventing cracking of the database file is further improved.
实际应用中,为了避免应用与服务器之间频繁交互所带来的终端处理资源消耗较大,针对一个应用,终端一般为该应用向该应用的服务器仅发送一次随机数获取请求,即步骤S41仅执行一次,当需要获取随机数时只需执行步骤S47~S410来获取随机数。In practical applications, in order to avoid the large consumption of terminal processing resources caused by frequent interaction between the application and the server, for an application, the terminal generally sends a random number acquisition request to the application server only once for the application, that is, step S41 only Execute once, and only need to execute steps S47 to S410 to obtain the random number when the random number needs to be obtained.
通过采用服务器下发的随机数来加密用于加密数据库文件的密钥信息,避免了所有与加密的密钥信息生成相关的参数全部存储在本地,服务器端针对一终端设备一应用分配的Rand_GUID存储在服务器端,只有在特殊情况如网络不通才会从终端本地SE或数据库文件开始位置备份中提取用白盒加密的Rand_GUID,在很大程度上提升了安全性。By using the random number issued by the server to encrypt the key information used to encrypt the database file, it is avoided that all parameters related to the generation of encrypted key information are stored locally, and the Rand_GUID allocated by the server for a terminal device and an application On the server side, the Rand_GUID encrypted with the white box is extracted from the backup of the local SE of the terminal or the starting position of the database file only in special cases such as network failure, which greatly improves the security.
S32、利用设备指纹信息、应用指纹信息、随机数和预置的子密钥对密钥信息进行加密处理得到加密的密钥信息。S32: Encrypt the key information by using the device fingerprint information, the application fingerprint information, the random number and the preset subkey to obtain encrypted key information.
本步骤中,可以利用SHA2算法、AES算法和HMAC算法来得到加密的密钥信息。具体地,可以按照图6所示的方法执行步骤S32,包括以下步骤:In this step, the encrypted key information can be obtained by using the SHA2 algorithm, the AES algorithm and the HMAC algorithm. Specifically, step S32 may be performed according to the method shown in FIG. 6, including the following steps:
S51、根据设备指纹信息、所述应用指纹信息、随机数和预置的子密钥,生成根密钥。S51. Generate a root key according to the device fingerprint information, the application fingerprint information, the random number and the preset subkey.
具体地,可以根据设备指纹信息、应用指纹信息、随机数和预置的子密钥,利用SHA2(SHA2-256)算法生成根密钥。例如,以设备指纹信息记为deviceFingerprint、应用指纹信息记为appFingerprint、随机数记为Rand_GuID,以及预置的子密钥包括d1、d2和d3为例进行说明,则可以按照下述公式生成根密钥key1:Specifically, the root key can be generated by using the SHA2 (SHA2-256) algorithm according to the device fingerprint information, the application fingerprint information, the random number and the preset subkey. For example, taking the device fingerprint information as deviceFingerprint, the application fingerprint information as appFingerprint, the random number as Rand_GuID, and the preset subkeys including d 1 , d 2 and d 3 as an example, the following formula can be used for illustration. Generate root key key 1 :
key1=SHA2(d1|d2|d3|deviceFingerprint|appFingerprint|Rand_GuID) (1)key 1 =SHA2(d 1 |d 2 |d 3 |deviceFingerprint|appFingerprint|Rand_GuID) (1)
S52、利用根密钥对所述密钥信息进行加密处理得到第一加密信息。S52: Encrypt the key information by using the root key to obtain first encrypted information.
具体地,可以利用AES算法和根密钥key1对密钥信息进行加密处理得到第一加密信息cipher1,参考下述公式:Specifically, the AES algorithm and the root key key 1 can be used to encrypt the key information to obtain the first encrypted information cipher1, with reference to the following formula:
cipher1=AESENkey1(key2) (2)cipher1=AESEN key1 (key 2 ) (2)
S53、利用根密钥对第一加密信息、所述设备指纹信息和所述应用指纹信息进行加密处理,得到第二加密信息。S53. Perform encryption processing on the first encrypted information, the device fingerprint information and the application fingerprint information by using the root key to obtain second encrypted information.
本步骤中,可以利用HMAC和根密钥对第一加密信息、所述设备指纹信息和所述应用指纹信息进行加密处理,得到第二加密信息cipher2,参考下述公式:In this step, HMAC and the root key can be used to encrypt the first encrypted information, the device fingerprint information and the application fingerprint information to obtain the second encrypted information cipher2, with reference to the following formula:
cipher2=HMACkey1(cipher|deviceFingerprint|appFingerprint) (3)cipher2=HMAC key1 (cipher|deviceFingerprint|appFingerprint) (3)
实际应用中,可以取HMAC结果,即等式右边的前64比特作为cipher2的值,即第二加密信息。In practical applications, the HMAC result, that is, the first 64 bits on the right side of the equation, can be taken as the value of cipher2, that is, the second encrypted information.
S54、利用预设的第一混淆参数对所述第二加密信息、所述设备指纹信息和所述应用指纹信息进行加密处理,得到第三加密信息。S54: Encrypt the second encrypted information, the device fingerprint information, and the application fingerprint information by using a preset first obfuscation parameter to obtain third encrypted information.
具体地,可以利用AES算法执行步骤S54,可以按照公式(4)得到第三加密信息cipher3:Specifically, step S54 can be performed by using the AES algorithm, and the third encrypted information cipher3 can be obtained according to formula (4):
cipher3=AESENK(cipher1|deviceFingerprint|appFingerprint) (4)cipher3=AESEN K (cipher1|deviceFingerprint|appFingerprint) (4)
具体地,公式(4)中K为预设的第一混淆参数,可以根据实际情况而定。Specifically, K in the formula (4) is a preset first confusion parameter, which can be determined according to the actual situation.
S55、对所述第二加密信息和所述第三加密信息进行或处理得到加密的密钥信息。S55. Perform OR processing on the second encrypted information and the third encrypted information to obtain encrypted key information.
本步骤中,可以按照公式(5)获得加密的密钥信息cipher:In this step, the encrypted key information cipher can be obtained according to formula (5):
cipher=cipher3|cipher2 (5)cipher=cipher3|cipher2 (5)
S33、将加密的密钥信息存储到该应用的指定目录中。S33. Store the encrypted key information in a specified directory of the application.
本步骤中,基于步骤S51~S55即可得到加密的密钥信息cipher,并将其存储到该应用的指定目录中。由于终端的设备指纹信息用于唯一标识终端,而应用的应用指纹信息用于唯一标识应用,再基于服务器为该终端该应用下发的随机数,则利用终端的设备指纹信息、应用指纹信息和服务器下发的随机数加密的密钥信息时,保证了一终端设备中一个应用对应一个随机数再对应一个加密的密钥信息,大大提高了加密的密钥信息的安全性和破解难度,进一步保证了利用密钥信息加密的数据库文件中敏感数据的安全性。In this step, the encrypted key information cipher can be obtained based on steps S51 to S55, and stored in the designated directory of the application. Since the device fingerprint information of the terminal is used to uniquely identify the terminal, and the application fingerprint information of the application is used to uniquely identify the application, and then based on the random number issued by the server for the terminal and the application, the device fingerprint information, application fingerprint information and When the random number encrypted key information is sent by the server, it is guaranteed that an application in a terminal device corresponds to a random number and then corresponds to an encrypted key information, which greatly improves the security of the encrypted key information and the difficulty of cracking, further The security of sensitive data in database files encrypted with key information is guaranteed.
较佳地,为了保证应用中指定目录存储的加密的密钥信息的准确性,本发明提出在步骤S11判断结果为是之后,在执行步骤S12之前,还包括:Preferably, in order to ensure the accuracy of the encrypted key information stored in the specified directory in the application, the present invention proposes that after the judgment result in step S11 is yes, and before step S12 is executed, the method further includes:
对所述加密的密钥信息的完整性校验通过。The integrity check of the encrypted key information is passed.
具体地,通过对加密的密钥信息进行完整性校验,可以在一定程度上提高数据库文件的安全性。当对指定目录中存储的加密的密钥信息进行完整性校验时,可以按照图7所示的流程对加密的密钥信息进行完整性校验,可以包括以下步骤:Specifically, by performing integrity check on the encrypted key information, the security of the database file can be improved to a certain extent. When performing integrity verification on the encrypted key information stored in the specified directory, the integrity verification can be performed on the encrypted key information according to the process shown in FIG. 7, which may include the following steps:
S61、将加密的密钥信息拆分为第四加密信息和第五加密信息。S61. Split the encrypted key information into fourth encrypted information and fifth encrypted information.
具体地,还以加密的密钥信息为cipher为例进行说明,则将cipher拆分成第四密钥信息cipher4和第五密钥信息cipher5。Specifically, taking the encrypted key information as a cipher as an example, the cipher is split into fourth key information cipher4 and fifth key information cipher5.
S62、利用预设的第一混淆参数对所述第五加密信息进行解密,并解密出第六加密信息、终端的设备指纹信息和应用的应用指纹信息。S62. Decrypt the fifth encrypted information by using the preset first obfuscation parameter, and decrypt the sixth encrypted information, the device fingerprint information of the terminal, and the application fingerprint information of the application.
本步骤中,利用AES解密算法执行步骤S62,即将cipher5利用第一混淆参数K进行AES解密,可以得到第六加密信息cipher6、解密出的设备指纹信息deviceFingerprint1、解密出的应用指纹信息appFingerprint1。’In this step, step S62 is performed by using the AES decryption algorithm, that is, cipher5 is decrypted by AES using the first obfuscation parameter K, and the sixth encrypted information cipher6, the decrypted device fingerprint information deviceFingerprint1, and the decrypted application fingerprint information appFingerprint1 can be obtained. ’
S63、利用根密钥对解密出的第六加密信息、终端的设备指纹信息和应用的应用指纹信息进行加密处理得到第七加密信息。S63 , encrypting the decrypted sixth encrypted information, the device fingerprint information of the terminal, and the application fingerprint information of the application by using the root key to obtain seventh encrypted information.
基于步骤S62,可以利用HMAC算法执行步骤S63,可以按照公式(6)得到第七加密信息cipher2‘:Based on step S62, the HMAC algorithm can be used to perform step S63, and the seventh encrypted information cipher2' can be obtained according to formula (6):
cipher2‘=HMACkey1(cipher1|deviceFingerprint1|appFringerprint1) (6)cipher2'=HMAC key1 (cipher1|deviceFingerprint1|appFringerprint1) (6)
S64、判断第七加密信息和第四加密信息是否一致,若是则执行步骤S65;否则执行步骤S66。S64: Determine whether the seventh encrypted information is consistent with the fourth encrypted information, if so, go to step S65; otherwise, go to step S66.
若确定出公式(6)得到的第七加密信息与拆分出的第四加密信息一致,即cipher2‘=cipher4,则执行步骤S65,即加密的密钥信息完整,否则加密的密钥信息不完整。If it is determined that the seventh encrypted information obtained by formula (6) is consistent with the split fourth encrypted information, that is, cipher2'=cipher4, then step S65 is executed, that is, the encrypted key information is complete, otherwise the encrypted key information is not whole.
S65、确定对所述加密的密钥信息的完整性校验通过。S65. Determine that the integrity check of the encrypted key information passes.
S66、确定对所述加密的密钥信息的完整性校验不通过。S66. Determine that the integrity check of the encrypted key information fails.
通过执行图7所示的流程即可确定出加密的密钥信息是否完整,当确定出加密的密钥信息不完整时,还需要执行步骤S13。Whether the encrypted key information is complete can be determined by executing the flow shown in FIG. 7 , and when it is determined that the encrypted key information is incomplete, step S13 needs to be executed.
优选地,本发明提供的方法还可以包括图8所示的流程,包括以下步骤:Preferably, the method provided by the present invention may also include the process shown in FIG. 8 , including the following steps:
S71、在检测到应用的版本更新时,从所述加密的密钥信息中解密出密钥信息。S71. Decrypt the key information from the encrypted key information when the version update of the application is detected.
本步骤中,在检测到应用的版本更新时,相当于应用发生了变化,故需要利用更新后的应用的应用指纹信息来重新加密密钥信息。故需要先从加密的密钥信息中解密出密钥信息。具体可以根据生成加密的密钥信息的过程的逆过程来执行解密过程,从而解密出密钥信息。In this step, when the version update of the application is detected, it is equivalent that the application has changed, so the key information needs to be re-encrypted by using the application fingerprint information of the updated application. Therefore, it is necessary to decrypt the key information from the encrypted key information first. Specifically, the decryption process may be performed according to the inverse process of the process of generating the encrypted key information, thereby decrypting the key information.
S72、确定更新后的应用的应用指纹信息。S72. Determine the application fingerprint information of the updated application.
具体地,可以重新获取更新后的应用的dex文件、证书和更新后的应用的包名,然后再利用更新后的dex文件、证书和更新后的应用的包名确定更新后的应用的应用指纹信息。Specifically, the dex file, the certificate and the package name of the updated application can be obtained again, and then the application fingerprint of the updated application can be determined by using the updated dex file, the certificate and the package name of the updated application. information.
S73、根据获取到的终端的设备指纹信息、所述应用指纹信息、获取到的随机数和预置的子密钥,重新对所述密钥信息进行加密处理得到新的加密的密钥信息。S73. Re-encrypt the key information to obtain new encrypted key information according to the acquired device fingerprint information of the terminal, the application fingerprint information, the acquired random number and the preset subkey.
本步骤中,在确定出更新后的应用的应用指纹信息后,在利用图4所示的流程重新对步骤S71中解密出的密钥信息进行加密处理,得到新的加密的密钥信息。需要说明的是,步骤S73中的随机数可以从SE或者数据库文件开始位置获取到的。In this step, after the application fingerprint information of the updated application is determined, the key information decrypted in step S71 is re-encrypted by using the flow shown in FIG. 4 to obtain new encrypted key information. It should be noted that the random number in step S73 can be obtained from the SE or the starting position of the database file.
S74、将所述新的加密的密钥信息存储到所述应用的指定目录中。S74. Store the new encrypted key information in a specified directory of the application.
在基于应用的新版本确定出新的加密的密钥信息后,将新的加密的密钥信息存储到更新后的应用的指定目录中。After the new encrypted key information is determined based on the new version of the application, the new encrypted key information is stored in the designated directory of the updated application.
较佳地,可以按照图9所示的方法获取图3、图4和图8中的终端的设备指纹信息,包括以下步骤:Preferably, the device fingerprint information of the terminals in FIG. 3 , FIG. 4 and FIG. 8 can be obtained according to the method shown in FIG. 9 , including the following steps:
S81、获取终端的IMEI、蓝牙多媒体访问控制地址BluetoothMacAddress和所述终端使用的操作系统的版本号。S81. Obtain the IMEI of the terminal, the Bluetooth multimedia access control address BluetoothMacAddress, and the version number of the operating system used by the terminal.
S82、根据预设的第二混淆参数、所述IMEI、所述BluetoothMacAddress和所述操作系统的版本号,生成所述终端的设备指纹信息。S82. Generate device fingerprint information of the terminal according to the preset second confusion parameter, the IMEI, the BluetoothMacAddress, and the version number of the operating system.
步骤S81~S82中,可以按照公式(7)确定终端的设备指纹信息:In steps S81-S82, the device fingerprint information of the terminal can be determined according to formula (7):
SHA2(IMEI|BluetoothMacAddress|AndroidID|K5) (7)SHA2(IMEI|BluetoothMacAddress|AndroidID|K5) (7)
本发明中终端的设备指纹信息用于唯一标识终端,不同的终端其设备指纹信息不同。实际应用中,可以将公式(7)中的前64比特作为终端的设备指纹信息,由于不同的终端其国际移动设备识别码(International Mobile Equipment Identity,IMEI)、BluetoothMacAddress和操作系统的版本号均不相同,故可以得出不同终端的设备指纹信息不同。公式(7)中K5为第二混淆参数,可以由实际情况而定。In the present invention, the device fingerprint information of the terminal is used to uniquely identify the terminal, and different terminals have different device fingerprint information. In practical applications, the first 64 bits in formula (7) can be used as the device fingerprint information of the terminal, because the version numbers of the International Mobile Equipment Identity (IMEI), BluetoothMacAddress and operating system of different terminals are different. Therefore, it can be concluded that the device fingerprint information of different terminals is different. In formula (7), K5 is the second confusion parameter, which can be determined by the actual situation.
可选地,可以按照图10所示的流程确定应用的应用指纹信息,包括以下步骤:Optionally, the application fingerprint information of the application can be determined according to the process shown in FIG. 10, including the following steps:
S91、获取所述应用的dex文件、证书和所述应用的包名。S91. Obtain a dex file, a certificate of the application, and a package name of the application.
S92、根据预设的第三混淆参数、所述dex文件、证书和所述包名,生成所述应用的应用指纹信息。S92. Generate application fingerprint information of the application according to the preset third obfuscation parameter, the dex file, the certificate, and the package name.
步骤S91~S92中,可以按照公式(8)确定应用的应用指纹信息:In steps S91-S92, the application fingerprint information of the application can be determined according to formula (8):
SHA2(dex|certificate|apk包名|K4) (8)SHA2(dex|certificate|apk package name|K4) (8)
本发明中应用的应用指纹信息用于唯一应用,不同的应用其应用指纹信息不同。实际应用中,可以取公式(8)中的前64比特作为应用的指纹信息,由于不同的应用的dex文件、证书和包名均不相同,则可以得出不同应用的应用指纹信息不同。本发明公式(8)中的K4为第三混淆参数,可以根据实际情况而定。The application fingerprint information applied in the present invention is used for a unique application, and different applications have different application fingerprint information. In practical applications, the first 64 bits in formula (8) can be taken as the fingerprint information of the application. Since the dex files, certificates and package names of different applications are different, it can be concluded that the application fingerprint information of different applications is different. K4 in the formula (8) of the present invention is the third confusion parameter, which can be determined according to the actual situation.
本发明提供的数据库文件加密方法,在加密任一应用涉及的数据库文件时,判断该应用的指定目录中是否存在加密的密钥信息,其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的;若是,则从读取到的所述加密的密钥信息中解密出密钥信息,并利用解密出的密钥信息加密所述数据库文件。通过采用上述方法,利用密钥信息对数据库文件进行加密,由于该密钥信息是利用终端的设备指纹信息和应用的应用指纹信息对密钥信息进行加密处理的,故提高了加密的密钥信息的破解难度,进而也就保证了加密的数据库文件的安全性。In the database file encryption method provided by the present invention, when encrypting a database file involved in any application, it is judged whether there is encrypted key information in the designated directory of the application, wherein the encrypted key information is based on the device fingerprint of the terminal. information and the application fingerprint information of the application to encrypt the key information; if so, decrypt the key information from the read encrypted key information, and use the decrypted key information to encrypt the database file. By adopting the above method, the database file is encrypted by using the key information. Since the key information is encrypted by using the device fingerprint information of the terminal and the application fingerprint information of the application, the encrypted key information is improved. Therefore, the security of the encrypted database file is guaranteed.
基于同一发明构思,本发明实施例还提供了一种数据库文件解密方法,参考图11所示,以将该方法应用在图1所示的终端100为例进行说明,该数据库文件解密方法的具体实施流程如下:Based on the same inventive concept, an embodiment of the present invention further provides a method for decrypting a database file. Referring to FIG. 11 , the method is applied to the terminal 100 shown in FIG. 1 as an example for description. The specific method for decrypting a database file is described. The implementation process is as follows:
S101、在接收到针对终端中应用的数据库文件的操作请求后,从所述应用的指定目录中获取加密的密钥信息。S101. After receiving an operation request for a database file of an application in a terminal, obtain encrypted key information from a specified directory of the application.
其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的。The encrypted key information is obtained by encrypting the key information according to the device fingerprint information of the terminal and the application fingerprint information of the application.
本步骤中,可以通过内部调用getTerminalKey()函数读取所述加密的密钥信息。具体实施时,通过在SQLCipher的SQLiteOpenHelper类中添加getTerminalKey()函数,该函数用于调用密钥生成工具SDK中TerminalCypto类的ReceiveTerminalKey()函数来读取密钥信息,并赋值给变量password,用于后续的加解密数据库db文件,无需在数据库操作函数中直接传递密钥信息。In this step, the encrypted key information can be read by calling the getTerminalKey() function internally. In specific implementation, the getTerminalKey() function is added to the SQLiteOpenHelper class of SQLCipher. This function is used to call the ReceiveTerminalKey() function of the TerminalCypto class in the key generation tool SDK to read the key information, and assign it to the variable password for Subsequent encryption and decryption of the database db file does not need to directly pass the key information in the database operation function.
具体地,加密的密钥信息具体可以参考图3或图4所示的流程获得,在此不再重复赘述。Specifically, the encrypted key information can be obtained by referring to the flow shown in FIG. 3 or FIG. 4 , and details are not repeated here.
S102、从所述加密的密钥信息中解密出所述密钥信息。S102. Decrypt the key information from the encrypted key information.
具体地,可以按照图12所示的方法解密出密钥信息,包括以下步骤:Specifically, the key information can be decrypted according to the method shown in Figure 12, including the following steps:
S111、将加密的密钥信息拆分成第一密文信息和第二密文信息。S111. Split the encrypted key information into first ciphertext information and second ciphertext information.
本步骤中,参考图6所示的加密操作,按照该加密操作的解密过程,先将加密的密钥信息cipher拆分成第一密文信息和第二密文信息,若执行解密操作的应用为合法应用,不存在攻击工具,则拆分出的第一密文信息应该为步骤S53中的第二加密信息cipher2,第二密文信息应该为步骤S54中的第三加密信息cipher3。In this step, referring to the encryption operation shown in FIG. 6, according to the decryption process of the encryption operation, the encrypted key information cipher is firstly split into the first cipher text information and the second cipher text information, if the application of the decryption operation is performed For legitimate application and no attack tool, the split first cipher text information should be the second encrypted information cipher2 in step S53, and the second cipher text information should be the third encrypted information cipher3 in step S54.
S112、利用预设的第一混淆参数对所述第二密文信息进行解密处理,得到第三密文信息。S112. Decrypt the second ciphertext information by using the preset first obfuscation parameter to obtain third ciphertext information.
本步骤中,利用第一混淆参数K对第二密文信息cipher3进行AES解密操作,可以解密出第三密文信息,同样若执行解密操作的应用为合法应用,不存在攻击工具,则解密出的第三密文信息cipher6应该为步骤S52中的第一加密信息cipher1。In this step, the AES decryption operation is performed on the second ciphertext information cipher3 by using the first obfuscation parameter K, and the third ciphertext information can be decrypted. Similarly, if the application performing the decryption operation is a legitimate application and there is no attack tool, the decrypted The third cipher text information cipher6 should be the first encrypted information cipher1 in step S52.
S113、利用根密钥对所述第三密文信息进行解密处理,得到所述密钥信息。S113. Decrypt the third ciphertext information by using the root key to obtain the key information.
本步骤中,利用根密钥key1利用AES解密算法对第三密文信息进行解密处理,参考公式(9)所示:In this step, the third ciphertext information is decrypted using the AES decryption algorithm using the root key key 1 , as shown in the reference formula (9):
key2=AESDEkey1(cipher6) (9)key2=AESDE key1 (cipher6) (9)
若操作该应用属于合法应用,则第三密文信息cipher6=第一加密信息cipher1。If the operation of the application belongs to a legitimate application, the third cipher text information cipher6=the first encrypted information cipher1.
S103、利用所述密钥信息对数据库文件进行解密并对解密后的数据库文件进行操作。S103: Decrypt the database file by using the key information and operate the decrypted database file.
具体地,在解密完成后,返回解密出的密钥信息key2及状态码0。然后利用解密出的密钥信息key2对加密的数据库进行解密操作。然后SQLCipher中数据库函数通过调用getTerminalKey函数便可获取key2对数据库文件进行增删改查操作。用户在调用SQLCipher这几个函数执行数据库增删改查等相关操作时,无需再传入password参数,密钥信息的生成、管理和调用等完全对用户无感知,从而简化了用户操作流程。Specifically, after the decryption is completed, the decrypted key information key 2 and status code 0 are returned. Then use the decrypted key information key 2 to decrypt the encrypted database. Then the database function in SQLCipher can obtain key 2 by calling the getTerminalKey function to perform addition, deletion, modification, and query operations on the database file. When users call SQLCipher to perform database addition, deletion, modification, and other related operations, they do not need to pass in the password parameter. The generation, management, and invocation of key information are completely unaware of the user, which simplifies the user operation process.
较佳地,在从所述加密的密钥信息中解密出所述密钥信息之前,还包括:Preferably, before decrypting the key information from the encrypted key information, the method further includes:
对所述加密的密钥信息的完整性校验通过。The integrity check of the encrypted key information is passed.
具体地,可以参考图7所示的流程对加密的密钥信息进行完整性校验,在此不再详细描述。Specifically, the integrity check of the encrypted key information may be performed with reference to the flow shown in FIG. 7 , which will not be described in detail here.
优选地,在从所述应用的指定目录中获取加密的密钥信息之前,还包括图13所示的流程,包括以下步骤:Preferably, before obtaining the encrypted key information from the specified directory of the application, the process shown in FIG. 13 is also included, including the following steps:
S121、获取终端的设备指纹信息。S121. Obtain device fingerprint information of the terminal.
实际应用中,如果每次都要实时确定终端的设备指纹信息,可能会造成终端的处理资源的浪费,故在确定加密的密钥信息过程中,在确定出终端的设备指纹信息后,将终端的设备指纹信息进行存储。In practical applications, if the device fingerprint information of the terminal needs to be determined in real time every time, the processing resources of the terminal may be wasted. Therefore, in the process of determining the encrypted key information, after the device fingerprint information of the terminal is determined, the terminal The device fingerprint information is stored.
S122、对所述设备指纹信息验证通过。S122. Pass the verification of the device fingerprint information.
本步骤中,在执行步骤S122时,通过再次执行步骤9所示的流程,确定终端当前的设备指纹信息,然后判断当前确定出的设备指纹信息与之前存储的设备指纹信息是否一致,若一致则对终端的设备指纹信息验证通过。只有在对终端的设备指纹信息验证通过后才会执行解密操作,即步骤S102。若对设备指纹信息验证不通过,则返回空值及相应状态码。In this step, when step S122 is performed, the current device fingerprint information of the terminal is determined by executing the process shown in step 9 again, and then it is determined whether the currently determined device fingerprint information is consistent with the previously stored device fingerprint information, and if so, then The device fingerprint information of the terminal is verified and passed. The decryption operation is performed only after the verification of the device fingerprint information of the terminal is passed, that is, step S102. If the verification of the device fingerprint information fails, a null value and a corresponding status code are returned.
进一步地,在对所述终端的设备指纹信息验证通过之后,在从所述应用的指定目录中获取加密的密钥信息之前,还包括图14所示的流程,包括以下步骤:Further, after the device fingerprint information of the terminal is verified and passed, before obtaining the encrypted key information from the specified directory of the application, the process shown in FIG. 14 is also included, including the following steps:
S131、获取应用的应用指纹信息。S131. Obtain application fingerprint information of an application.
实际应用中,如果每次都要实时确定应用的应用指纹信息,可能会造成终端的处理资源的浪费,故在确定加密的密钥信息过程中,在确定出应用的应用指纹信息后,将应用的应用指纹信息进行存储。In practical applications, if the application fingerprint information of the application needs to be determined in real time every time, the processing resources of the terminal may be wasted. Therefore, in the process of determining the encrypted key information, after the application fingerprint information of the application is determined, the application The application fingerprint information is stored.
S132、对所述应用指纹信息验证通过。S132. Pass the verification of the application fingerprint information.
本步骤中,在执行步骤S132时,通过再次执行步骤10所示的流程,确定应用当前的应用指纹信息,然后判断当前确定出的应用指纹信息与之前存储的应用指纹信息是否一致,若一致则对应用指纹信息验证通过。只有在对应用指纹信息验证通过后才会执行解密操作,即步骤S102。In this step, when step S132 is performed, the current application fingerprint information of the application is determined by executing the process shown in step 10 again, and then it is determined whether the currently determined application fingerprint information is consistent with the previously stored application fingerprint information, and if so, then Verification of the application fingerprint information is passed. The decryption operation is performed only after the verification of the application fingerprint information is passed, that is, step S102.
通过执行本发明提供的数据库文件解密方法,在接收到针对终端中应用的数据库文件的操作请求后,从所述应用的指定目录中获取加密的密钥信息,其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的;从所述加密的密钥信息中解密出所述密钥信息;利用所述密钥信息对数据库文件进行解密并对解密后的数据库文件进行操作。采用上述方法,通过内部调用getTerminalKey()函数读取加密的密钥信息,然后从加密的密钥信息中解密出密钥信息,再利用解密出的密钥信息对加密的数据库文件进行解密,从而在解密成功后对数据库文件进行操作,可以做到用户无感知的获取加密的密钥信息并解密出密钥信息,简化了用户操作流程。By executing the database file decryption method provided by the present invention, after receiving the operation request for the database file applied in the terminal, the encrypted key information is obtained from the specified directory of the application, wherein the encrypted key information It is obtained by encrypting the key information according to the device fingerprint information of the terminal and the application fingerprint information of the application; decrypting the key information from the encrypted key information; using the key information to encrypt the database Decrypt the file and operate on the decrypted database file. Using the above method, the encrypted key information is read by calling the getTerminalKey() function internally, then the key information is decrypted from the encrypted key information, and the encrypted database file is decrypted using the decrypted key information, thereby After the decryption is successful, the database file is operated, so that the user can acquire the encrypted key information without perception and decrypt the key information, which simplifies the user operation process.
本发明通过在SQLCipher上集成密钥管理SDK,结合设备指纹信息、应用指纹信息和服务器下发的随机数对用于加密数据库文件的密钥信息进行加密存储,简化用户调用相关数据操作函数,无需传入密钥参数,简化了用户使用SQLCipher的操作,从而做到数据库加解密操作对用户无感知。The invention integrates the key management SDK on SQLCipher, combines the device fingerprint information, the application fingerprint information and the random number issued by the server to encrypt and store the key information used to encrypt the database file, simplifies the user's invocation of relevant data operation functions, and does not require Passing in the key parameter simplifies the user's operation of using SQLCipher, so that the database encryption and decryption operations are unaware of the user.
基于同一发明构思,本发明实施例中还提供了一种数据库文件加密装置,由于上述装置解决问题的原理与数据库文件加密方法相似,因此上述装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, an embodiment of the present invention also provides a database file encryption device. Since the above-mentioned device solves the problem in a similar way to the database file encryption method, the implementation of the above-mentioned device can refer to the implementation of the method, and the repetition will not be repeated. Repeat.
如图15所示,为本发明实施例提供的数据库文件加密装置的结构示意图,包括:As shown in FIG. 15, it is a schematic structural diagram of a database file encryption device provided by an embodiment of the present invention, including:
判断单元141,用于在加密任一应用涉及的数据库文件时,判断该应用的指定目录中是否存在加密的密钥信息,其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的;The judging
加解密单元142,用于在所述判断单元141的判断结果为是时,则从读取到的所述加密的密钥信息中解密出密钥信息,并利用解密出的密钥信息加密所述数据库文件。The encryption and
一种可能的实施方式中,所述装置,还包括:In a possible implementation, the device further includes:
检验单元143,用于在所述判断单元141判断结果为是,在所述加解密单元142从所述加密的密钥信息中解密出密钥信息之前,对所述加密的密钥信息的完整性校验通过。The
优选地,所述装置,还包括:Preferably, the device further comprises:
第一加密单元144,用于若上述判断单元141判断在所述指定目录中不存在加密的密钥信息时,或者所述校验单元143对所述加密的密钥信息的完整性校验不通过时,则随机产生密钥信息并利用产生的密钥信息加密所述数据库文件。The
再一种可能的实施方式中,本发明提供的数据库文件加密装置,还包括:In yet another possible implementation, the database file encryption device provided by the present invention further includes:
获取单元145,用于获取所述终端的设备指纹信息和该应用的应用指纹信息;an obtaining
第二加密单元146,用于利用所述设备指纹信息和所述应用指纹信息对密钥信息进行加密处理得到加密的密钥信息。The
优选地,所述获取单元145,还用于获取所述终端的设备指纹信息、该应用的应用指纹信息和随机数;Preferably, the obtaining
所述第二加密单元146,还用于利用所述设备指纹信息、应用指纹信息、随机数和预置的子密钥对密钥信息进行加密处理得到加密的密钥信息;The
所述装置,还包括:The device also includes:
存储单元147,用于将所述加密的密钥信息存储到该应用的指定目录中。The
较佳地,所述第二加密单元146,具体用于根据所述设备指纹信息、所述应用指纹信息、随机数和预置的子密钥,生成根密钥;利用所述根密钥对所述密钥信息进行加密处理得到第一加密信息;利用所述根密钥对所述第一加密信息、所述设备指纹信息和所述应用指纹信息进行加密处理,得到第二加密信息;利用预设的第一混淆参数对所述第二加密信息、所述设备指纹信息和所述应用指纹信息进行加密处理,得到第三加密信息;对所述第二加密信息和所述第三加密信息进行或处理得到加密的密钥信息。Preferably, the
优选地,所述加解密单元,具体用于通过内部调用getTerminalKey()函数读取所述加密的密钥信息。Preferably, the encryption and decryption unit is specifically configured to read the encrypted key information by calling the getTerminalKey() function internally.
优选地,所述校验单元143,具体用于按照下述方法确定对所述加密的密钥信息的完整性校验通过:将所述加密的密钥信息拆分为第四加密信息和第五加密信息;利用预设的第一混淆参数对所述第五加密信息进行解密,并解密出第六加密信息、终端的设备指纹信息和应用的应用指纹信息;利用根密钥对解密出的第六加密信息、终端的设备指纹信息和应用的应用指纹信息进行加密处理得到第七加密信息;若确定出所述第七加密信息和第四加密信息一致,则确定对所述加密的密钥信息的完整性校验通过。Preferably, the
再一种可能的实施方式中,本发明提供的数据库文件加密装置中,In yet another possible implementation, in the database file encryption device provided by the present invention,
加解密单元142,还用于在检测到应用的版本更新时,从所述加密的密钥信息中解密出密钥信息;The encryption and
上述装置,还包括:The above device also includes:
确定单元148,用于确定更新后的应用的应用指纹信息;a determining
所述第二加密单元146,还用于根据获取到的终端的设备指纹信息、所述应用指纹信息、获取到的随机数和预置的子密钥,重新对所述密钥信息进行加密处理得到新的加密的密钥信息;The
所述存储单元147,还用于将所述新的加密的密钥信息存储到所述应用的指定目录中。The
再一种可能的实施方式中,本发明提供的数据库文件加密装置,还包括:In yet another possible implementation, the database file encryption device provided by the present invention further includes:
获取单元145,还用于按照下述方法获取随机数:向该应用的服务器发送随机数获取请求,所述请求中携带有所述终端的终端标识和该应用的应用标识,以使所述服务器根据终端标识、应用标识和随机数三者之间的对应关系,确定该应用的随机数;在确定出成功接收到服务器下发的随机数后,获取所述随机数;若确定出未成功接收到服务器下发的随机数,则确定安全元件SE中是否存储有随机数,若是则从SE中获取随机数;若否,则在确定出数据库文件开始位置存储有随机数时,从所述数据库文件开始位置获取所述随机数。The obtaining
优选地,所述装置,还包括:Preferably, the device further comprises:
处理单元149,用于在所述获取单元145在获取所述随机数之后,判断所述终端是否具有安全元件SE权限;若是,则在确定出所述SE中未存储随机数时,将接收到的随机数用白盒进行加密并将加密后的随机数存储到SE中;若否,则在确定出数据库文件开始位置未存储随机数时,将接收到的随机数用白盒进行加密并将加密后的随机数存储到数据库文件开始位置处。The
可选地,所述第二加密单元146,具体用于按照下述方法生成终端的设备指纹信息:获取终端的国际移动设备识别码IMEI、蓝牙多媒体访问控制地址BluetoothMacAddress和所述终端使用的操作系统的版本号;根据预设的第二混淆参数、所述IMEI、所述BluetoothMacAddress和所述操作系统的版本号,生成所述终端的设备指纹信息。Optionally, the
可选地,所述第二加密单元146,具体用于按照下述方法生成应用的应用指纹信息:获取所述应用的dex文件、证书和所述应用的包名;根据预设的第三混淆参数、所述dex文件、证书和所述包名,生成所述应用的应用指纹信息。Optionally, the
为了描述的方便,以上各部分按照功能划分为各模块(或单元)分别描述。当然,在实施本发明时可以把各模块(或单元)的功能在同一个或多个软件或硬件中实现。For the convenience of description, the above parts are divided into modules (or units) according to their functions and described respectively. Of course, when implementing the present invention, the functions of each module (or unit) may be implemented in one or more software or hardware.
基于同一发明构思,本发明实施例中还提供了一种数据库文件解密装置,由于上述装置解决问题的原理与数据库文件解密方法相似,因此上述装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, an embodiment of the present invention also provides a database file decryption device. Since the above-mentioned device solves the problem in a similar manner to the database file decryption method, the implementation of the above-mentioned device can refer to the implementation of the method, and the repetition will not be repeated. Repeat.
如图16所示,为本发明实施例提供的数据库文件解密装置的结构示意图,包括:As shown in FIG. 16, it is a schematic structural diagram of a database file decryption apparatus provided by an embodiment of the present invention, including:
获取单元151,用于在接收到针对终端中应用的数据库文件的操作请求后,从所述应用的指定目录中获取加密的密钥信息,其中,所述加密的密钥信息为根据终端的设备指纹信息和该应用的应用指纹信息对所述密钥信息进行加密得到的;The obtaining
第一解密单元152,用于从所述加密的密钥信息中解密出所述密钥信息;a
第二解密单元153,用于利用所述密钥信息对数据库文件进行解密并对解密后的数据库文件进行操作。The
在一种可能的实施方式中,本发明提供的数据库文件解密装置,还包括:In a possible implementation, the database file decryption device provided by the present invention further includes:
校验单元154,用于在所述第一解密单元152从所述加密的密钥信息中解密出所述密钥信息之前,对所述加密的密钥信息的完整性校验通过。The
在一种可能的实施方式中,本发明提供的数据库文件解密装置,还包括:In a possible implementation, the database file decryption device provided by the present invention further includes:
第一验证单元155,用于在所述第一解密单元152从所述加密的密钥信息中解密出所述密钥信息之前,获取所述终端的设备指纹信息;并对所述设备指纹信息验证通过。The
在一种可能的实施方式中,本发明提供的数据库文件解密装置,还包括:In a possible implementation, the database file decryption device provided by the present invention further includes:
第二验证单元156,用于在所述第一验证单元155对所述终端的设备指纹信息验证通过之后,在所述第一解密单元152从所述加密的密钥信息中解密出所述密钥信息之前,获取所述应用的应用指纹信息;并对所述应用指纹信息验证通过。The
优选地,所述第一解密单元152,具体用于将所述加密的密钥信息拆分成第一密文信息和第二密文信息;利用预设的第一混淆参数对所述第二密文信息进行解密处理,得到第三密文信息;利用根密钥对所述第三密文信息进行解密处理,得到所述密钥信息。Preferably, the
基于同一发明构思,本发明实施例还提供一种通信设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序;所述处理器执行所述程序时实现如本发明实施例提供的任一项所述的数据库文件加密方法或数据库文件解密方法。Based on the same inventive concept, an embodiment of the present invention also provides a communication device, including a memory, a processor, and a computer program stored on the memory and running on the processor; when the processor executes the program Implement the database file encryption method or the database file decryption method according to any one of the embodiments of the present invention.
此外,本申请实施例还提供了一种计算机可读存储介质,存储为执行上述处理器所需执行的计算机可执行指令,其包含用于执行上述处理器所需执行的程序。In addition, an embodiment of the present application further provides a computer-readable storage medium, which stores computer-executable instructions to be executed by the above-mentioned processor, and includes a program to be executed by the above-mentioned processor.
在一些可能的实施方式中,本发明提供的数据库文件加密方法或数据库文件解密方法的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当所述程序产品在计算机设备上运行时,所述程序代码用于使所述计算机设备执行本说明书上述描述的根据本发明各种示例性实施方式的数据库文件加密方法中的步骤,或者数据库文件解密方法中的步骤,例如,所述计算机设备可以执行如图2所示的步骤S11~S13中数据库文件加密流程,或者执行如图11所示的步骤S101~S103中数据库文件解密流程。In some possible implementations, various aspects of the database file encryption method or the database file decryption method provided by the present invention can also be implemented in the form of a program product, which includes program code, and when the program product runs on a computer device When the program code is used to cause the computer device to execute the steps in the database file encryption method according to various exemplary embodiments of the present invention described above in this specification, or the steps in the database file decryption method, for example, the The computer device may perform the database file encryption process in steps S11 to S13 shown in FIG. 2 , or the database file decryption process in steps S101 to S103 shown in FIG. 11 .
所述程序产品可以采用一个或多个可读介质的任意组合。可读介质可以是可读信号介质或者可读存储介质。可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples (non-exhaustive list) of readable storage media include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
本发明的实施方式的用于数据库文件加密方法或数据库文件解密方法的程序产品可以采用便携式紧凑盘只读存储器(CD-ROM)并包括程序代码,并可以在计算设备上运行。然而,本发明的程序产品不限于此,在本文件中,可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。The program product for the database file encryption method or the database file decryption method of the embodiments of the present invention may employ a portable compact disk read only memory (CD-ROM) and include program code, and may be executed on a computing device. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了可读程序代码。这种传播的数据信号可以采用多种形式,包括——但不限于——电磁信号、光信号或上述的任意合适的组合。可读信号介质还可以是可读存储介质以外的任何可读介质,该可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。A readable signal medium may include a propagated data signal in baseband or as part of a carrier wave, carrying readable program code therein. Such propagated data signals may take a variety of forms including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium can also be any readable medium, other than a readable storage medium, that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
可读介质上包含的程序代码可以用任何适当的介质传输,包括——但不限于——无线、有线、光缆、RF等等,或者上述的任意合适的组合。Program code embodied on a readable medium may be transmitted using any suitable medium including, but not limited to, wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
可以以一种或多种程序设计语言的任意组合来编写用于执行本发明操作的程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、C++等,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算设备上执行、部分地在用户设备上执行、作为一个独立的软件包执行、部分在用户计算设备上部分在远程计算设备上执行、或者完全在远程计算设备或服务器上执行。在涉及远程计算设备的情形中,远程计算设备可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算设备,或者,可以连接到外部计算设备(例如利用因特网服务提供商来通过因特网连接)。Program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages—such as Java, C++, etc., as well as conventional procedural Programming Language - such as the "C" language or similar programming language. The program code may execute entirely on the user computing device, partly on the user device, as a stand-alone software package, partly on the user computing device and partly on a remote computing device, or entirely on the remote computing device or server execute on. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (eg, using an Internet service) provider to connect via the Internet).
应当注意,尽管在上文详细描述中提及了装置的若干单元或子单元,但是这种划分仅仅是示例性的并非强制性的。实际上,根据本发明的实施方式,上文描述的两个或更多单元的特征和功能可以在一个单元中具体化。反之,上文描述的一个单元的特征和功能可以进一步划分为由多个单元来具体化。It should be noted that although several units or sub-units of the apparatus are mentioned in the above detailed description, this division is merely exemplary and not mandatory. Indeed, in accordance with embodiments of the present invention, the features and functions of two or more units described above may be embodied in one unit. Conversely, the features and functions of one unit described above may be further subdivided to be embodied by multiple units.
此外,尽管在附图中以特定顺序描述了本发明方法的操作,但是,这并非要求或者暗示必须按照该特定顺序来执行这些操作,或是必须执行全部所示的操作才能实现期望的结果。附加地或备选地,可以省略某些步骤,将多个步骤合并为一个步骤执行,和/或将一个步骤分解为多个步骤执行。Furthermore, although the operations of the methods of the present invention are depicted in the figures in a particular order, this does not require or imply that the operations must be performed in the particular order, or that all illustrated operations must be performed to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined to be performed as one step, and/or one step may be decomposed into multiple steps to be performed.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。Although the preferred embodiments of the present invention have been described, additional changes and modifications to these embodiments may occur to those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be construed to include the preferred embodiment and all changes and modifications that fall within the scope of the present invention.
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。It will be apparent to those skilled in the art that various modifications and variations can be made in the present invention without departing from the spirit and scope of the invention. Thus, provided that these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims (22)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810972631.8A CN110858249B (en) | 2018-08-24 | 2018-08-24 | Database file encryption method, database file decryption method and related devices |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810972631.8A CN110858249B (en) | 2018-08-24 | 2018-08-24 | Database file encryption method, database file decryption method and related devices |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110858249A true CN110858249A (en) | 2020-03-03 |
CN110858249B CN110858249B (en) | 2021-11-16 |
Family
ID=69635580
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810972631.8A Active CN110858249B (en) | 2018-08-24 | 2018-08-24 | Database file encryption method, database file decryption method and related devices |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110858249B (en) |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111382409A (en) * | 2020-03-19 | 2020-07-07 | 支付宝(杭州)信息技术有限公司 | Identity authentication method and device for protecting privacy |
CN111711640A (en) * | 2020-06-30 | 2020-09-25 | 郑州工业应用技术学院 | A secure computer network communication system |
CN112511507A (en) * | 2020-11-17 | 2021-03-16 | 武汉默联股份有限公司 | Data processing device and data processing method |
CN112653559A (en) * | 2021-01-04 | 2021-04-13 | 潍柴动力股份有限公司 | Electric control unit starting method and device and storage medium |
CN113407885A (en) * | 2021-06-23 | 2021-09-17 | 中移(杭州)信息技术有限公司 | XPath data tampering warning method, device, equipment and readable storage medium |
CN113496561A (en) * | 2020-04-02 | 2021-10-12 | 广州汽车集团股份有限公司 | Vehicle-mounted fingerprint identification system and communication method thereof |
CN113794706A (en) * | 2021-09-06 | 2021-12-14 | 北京百度网讯科技有限公司 | Data processing method and device, electronic equipment and readable storage medium |
CN114390012A (en) * | 2021-12-15 | 2022-04-22 | 中国电子科技集团公司第三十研究所 | West trust application data evidence obtaining method based on reverse analysis |
CN115828289A (en) * | 2023-02-16 | 2023-03-21 | 中信天津金融科技服务有限公司 | Encryption method and system for digital archive |
CN117009319A (en) * | 2023-08-07 | 2023-11-07 | 广州青莲网络科技有限公司 | Database operation method, system and storage medium based on large language model |
Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1533646A (en) * | 2002-04-15 | 2004-09-29 | ������������ʽ���� | Apparatus and method for processing information apparatus and method for providing information, apparatus and method for managing usage right, recording medium and program |
US20080077806A1 (en) * | 2006-09-27 | 2008-03-27 | International Business Machines Corporation | Encrypting and decrypting database records |
CN102082790A (en) * | 2010-12-27 | 2011-06-01 | 北京握奇数据系统有限公司 | Method and device for encryption/decryption of digital signature |
CN103106372A (en) * | 2013-01-17 | 2013-05-15 | 上海交通大学 | Lightweight class privacy data encryption method and system for Android system |
CN104636444A (en) * | 2015-01-13 | 2015-05-20 | 大唐移动通信设备有限公司 | Database encryption and decryption method and device |
US20150178506A1 (en) * | 2004-06-01 | 2015-06-25 | Ben-Gurion University Of The Negev, Research And Development Authority | Method and system for database encryption |
CN105989270A (en) * | 2015-09-25 | 2016-10-05 | 武汉安天信息技术有限责任公司 | Cloud computing-based android database security protection method and system |
CN106992851A (en) * | 2017-04-01 | 2017-07-28 | 北京元心科技有限公司 | TrustZone-based database file password encryption and decryption method and device and terminal equipment |
CN107506659A (en) * | 2017-07-27 | 2017-12-22 | 西安电子科技大学 | A kind of data protection system and method for the Universal Database based on SGX |
CN107563215A (en) * | 2016-07-01 | 2018-01-09 | 四川秘无痕信息安全技术有限责任公司 | A kind of Android system wechat chat record decryption method |
CN107925577A (en) * | 2014-06-13 | 2018-04-17 | 百可德罗德公司 | The method and computer program product for generating and managing for encryption key |
-
2018
- 2018-08-24 CN CN201810972631.8A patent/CN110858249B/en active Active
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1533646A (en) * | 2002-04-15 | 2004-09-29 | ������������ʽ���� | Apparatus and method for processing information apparatus and method for providing information, apparatus and method for managing usage right, recording medium and program |
US20150178506A1 (en) * | 2004-06-01 | 2015-06-25 | Ben-Gurion University Of The Negev, Research And Development Authority | Method and system for database encryption |
US20080077806A1 (en) * | 2006-09-27 | 2008-03-27 | International Business Machines Corporation | Encrypting and decrypting database records |
CN102082790A (en) * | 2010-12-27 | 2011-06-01 | 北京握奇数据系统有限公司 | Method and device for encryption/decryption of digital signature |
CN103106372A (en) * | 2013-01-17 | 2013-05-15 | 上海交通大学 | Lightweight class privacy data encryption method and system for Android system |
CN107925577A (en) * | 2014-06-13 | 2018-04-17 | 百可德罗德公司 | The method and computer program product for generating and managing for encryption key |
CN104636444A (en) * | 2015-01-13 | 2015-05-20 | 大唐移动通信设备有限公司 | Database encryption and decryption method and device |
CN105989270A (en) * | 2015-09-25 | 2016-10-05 | 武汉安天信息技术有限责任公司 | Cloud computing-based android database security protection method and system |
CN107563215A (en) * | 2016-07-01 | 2018-01-09 | 四川秘无痕信息安全技术有限责任公司 | A kind of Android system wechat chat record decryption method |
CN106992851A (en) * | 2017-04-01 | 2017-07-28 | 北京元心科技有限公司 | TrustZone-based database file password encryption and decryption method and device and terminal equipment |
CN107506659A (en) * | 2017-07-27 | 2017-12-22 | 西安电子科技大学 | A kind of data protection system and method for the Universal Database based on SGX |
Non-Patent Citations (2)
Title |
---|
FB客服: ""SQLCipher之攻与防"", 《腾讯云》 * |
编码美丽: ""微信数据库最新解密方式,用代码解密微信数据库信息!"", 《公众号名称为"编码美丽"》 * |
Cited By (16)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111382409A (en) * | 2020-03-19 | 2020-07-07 | 支付宝(杭州)信息技术有限公司 | Identity authentication method and device for protecting privacy |
CN113496561A (en) * | 2020-04-02 | 2021-10-12 | 广州汽车集团股份有限公司 | Vehicle-mounted fingerprint identification system and communication method thereof |
CN111711640B (en) * | 2020-06-30 | 2022-09-30 | 郑州工业应用技术学院 | A secure computer network communication system |
CN111711640A (en) * | 2020-06-30 | 2020-09-25 | 郑州工业应用技术学院 | A secure computer network communication system |
CN112511507A (en) * | 2020-11-17 | 2021-03-16 | 武汉默联股份有限公司 | Data processing device and data processing method |
CN112653559A (en) * | 2021-01-04 | 2021-04-13 | 潍柴动力股份有限公司 | Electric control unit starting method and device and storage medium |
CN112653559B (en) * | 2021-01-04 | 2023-01-06 | 潍柴动力股份有限公司 | Electric control unit starting method and device and storage medium |
CN113407885A (en) * | 2021-06-23 | 2021-09-17 | 中移(杭州)信息技术有限公司 | XPath data tampering warning method, device, equipment and readable storage medium |
CN113407885B (en) * | 2021-06-23 | 2024-04-12 | 中移(杭州)信息技术有限公司 | XPath data tampering alarm method, device, equipment and readable storage medium |
CN113794706A (en) * | 2021-09-06 | 2021-12-14 | 北京百度网讯科技有限公司 | Data processing method and device, electronic equipment and readable storage medium |
CN113794706B (en) * | 2021-09-06 | 2023-08-15 | 北京百度网讯科技有限公司 | Data processing method and device, electronic equipment and readable storage medium |
CN114390012A (en) * | 2021-12-15 | 2022-04-22 | 中国电子科技集团公司第三十研究所 | West trust application data evidence obtaining method based on reverse analysis |
CN115828289A (en) * | 2023-02-16 | 2023-03-21 | 中信天津金融科技服务有限公司 | Encryption method and system for digital archive |
CN115828289B (en) * | 2023-02-16 | 2023-05-30 | 中信天津金融科技服务有限公司 | Encryption method and system for digitized file |
CN117009319A (en) * | 2023-08-07 | 2023-11-07 | 广州青莲网络科技有限公司 | Database operation method, system and storage medium based on large language model |
CN117009319B (en) * | 2023-08-07 | 2024-01-26 | 广州青莲网络科技有限公司 | Database operation method, system and storage medium based on large language model |
Also Published As
Publication number | Publication date |
---|---|
CN110858249B (en) | 2021-11-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110858249B (en) | Database file encryption method, database file decryption method and related devices | |
CN112733107B (en) | Information verification method, related device, equipment and storage medium | |
US11683187B2 (en) | User authentication with self-signed certificate and identity verification and migration | |
ES2836114T3 (en) | Information sending method, information reception method, device and system | |
US10917394B2 (en) | Data operations using a proxy encryption key | |
CN112291190B (en) | Identity authentication method, terminal and server | |
WO2018157858A1 (en) | Information storage method, device, and computer-readable storage medium | |
US10409984B1 (en) | Hierarchical data security measures for a mobile device | |
CN104715187B (en) | Method and apparatus for the node in certification electronic communication system | |
WO2017041599A1 (en) | Service processing method and electronic device | |
CN108769027B (en) | Secure communication method, device, mobile terminal and storage medium | |
US20230421372A1 (en) | Accessory assisted account recovery | |
TWI420339B (en) | Software authorization system and method | |
CN107786331B (en) | Data processing method, device, system and computer readable storage medium | |
WO2020125134A1 (en) | Customized model tamper-proof method and apparatus, terminal device and storage medium | |
CN106845177A (en) | Cipher management method and system | |
EP3206329A1 (en) | Security check method, device, terminal and server | |
CN111259452A (en) | Data management method based on block chain and related device | |
TWI546698B (en) | Login system based on servers, login authentication server, and authentication method thereof | |
CN114389802B (en) | Information decryption method and device, electronic equipment and readable storage medium | |
CN113904830A (en) | SPA authentication method and device, electronic equipment and readable storage medium | |
CN112464259A (en) | ERP page acquisition method and device, computer equipment and storage medium | |
US20240421981A1 (en) | Key distribution using key duplication policies | |
WO2024260239A1 (en) | Data processing method and apparatus, device, medium, and program product | |
CN118631456A (en) | Password detection method, device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |