Method and device for storing ciphertext
1. A method for storing ciphertext, comprising:
acquiring an encryption instruction, wherein the encryption instruction indicates to encrypt a file in an external memory;
acquiring a characteristic value of a first account identifier according to the encryption instruction;
encrypting a first key by using the characteristic value of the first account identifier to generate a first ciphertext, wherein the first key is used for encrypting a second key, and the second key is used for encrypting a first file in the external memory;
encrypting the characteristic value of the first account identification to generate a second ciphertext;
storing the first ciphertext and the second ciphertext in an unerasable partition.
2. The method of claim 1, further comprising:
acquiring indication information of account switching;
checking the first account identification according to the indication information;
after the first account identification passes the verification, acquiring a characteristic value of a second account identification;
and updating the first ciphertext and the second ciphertext according to the characteristic value of the second account identifier.
3. The method of claim 1, further comprising:
after the factory level reset is completed, checking the first account identification;
and when the first account identification is successfully verified, decrypting the first ciphertext and the second ciphertext to generate the first key.
4. The method of claim 3, wherein the verifying the first account identification comprises:
and when the state of the factory-level reset protection FRP is triggered, checking the first account identification.
5. The method according to claim 3 or 4, characterized in that the method further comprises:
encrypting the first key by using a default value to generate a third ciphertext;
encrypting the default value to generate a fourth ciphertext;
storing the third ciphertext and the fourth ciphertext in the unerasable partition.
6. The method of claim 5, further comprising:
copying the third ciphertext and the fourth ciphertext from the non-erasable partition to an erasable partition;
generating the first key according to the third ciphertext and the fourth ciphertext in the erasable partition;
and decrypting the encrypted first file in the external memory according to the first key.
7. The method according to any one of claims 3 to 6, wherein before the verifying the first account id, the method further comprises:
acquiring a factory-level reset instruction triggered by a recovery interface;
data in an erasable partition is formatted according to the factory level reset instruction.
8. The method according to any one of claims 1 to 7,
the encrypting the first key by using the characteristic value of the first account id includes:
invoking the key management module keymaster TA to execute: encrypting the first key by using the characteristic value of the first account identification;
the encrypting the characteristic value of the first account id includes:
invoking the keymaster TA to perform: and encrypting the characteristic value of the first account identification.
9. The method of any of claims 1-8, wherein storing the first ciphertext and the second ciphertext in an unerasable partition comprises:
calling a TEE API to execute: storing the first ciphertext and the second ciphertext in the unerasable partition.
10. The method of any of claims 1 to 9, wherein the first key is further used to encrypt a third key, the third key being used to encrypt the encrypted second file in the external memory.
11. The method according to any one of claims 1 to 10, further comprising:
acquiring a characteristic value of a screen locking password according to the encryption instruction;
encrypting the first secret key by using the characteristic value of the screen locking password to generate a fifth ciphertext;
encrypting the characteristic value of the screen locking password to generate a sixth ciphertext;
storing the fifth ciphertext and the sixth ciphertext in an erasable partition.
12. The method of claim 11,
the encrypting the first key using the feature value of the lock screen password comprises:
invoke the keymaster TA to perform: encrypting the first key using a feature value of the screen-locking password;
the encrypting the characteristic value of the screen locking password comprises the following steps:
invoking the keymaster TA to perform: and encrypting the characteristic value of the screen locking password.
13. The method according to claim 11 or 12, characterized in that the method further comprises:
acquiring a user-level reset instruction triggered by a setting interface;
backing up the fifth ciphertext and the sixth ciphertext to the non-erasable partition according to the user-level reset instruction.
14. The method of claim 13, wherein the backing up the fifth ciphertext and the sixth ciphertext to the non-erasable partition according to the user-level reset instruction comprises:
decrypting the first key from the fifth ciphertext and the sixth ciphertext according to the user-level reset instruction;
encrypting the first key by using a default value to generate a seventh ciphertext;
encrypting the default value to generate an eighth ciphertext;
storing the seventh ciphertext and the eighth ciphertext in the unerasable partition.
15. The method of claim 14, further comprising:
copying the seventh ciphertext and the eighth ciphertext from the non-erasable partition to the erasable partition after a user-level reset is complete;
decrypting the first key from the seventh ciphertext and the eighth ciphertext in the erasable partition;
and decrypting the encrypted first file in the external memory according to the first key.
16. The method of any of claims 11 to 15, wherein the erasable partition is a data partition and the characteristic value of the screen-lock password is a hash value of the screen-lock password.
17. The method according to any one of claims 1 to 16, wherein the non-erasable partition is a sec storage partition, and the characteristic value of the first account id is a hash value of the first account id.
18. A method for storing ciphertext, comprising:
displaying an encryption setting interface of the external memory;
receiving a first operation performed by a user on the encryption setting interface;
in response to the first operation, encrypting a file in the external memory;
receiving a second operation of the user;
displaying a factory level reset setting interface in response to the second operation;
receiving a third operation performed by the user on the factory level reset setting interface;
performing a plant level reset in response to the third operation;
displaying an account verification interface;
receiving verification information input by the user on the account verification interface;
and when the verification information passes verification and an operation of accessing the file in the external memory by a user is received, decrypting the encrypted file in the external memory.
19. An apparatus for holding ciphertext, comprising a processor and a memory, the memory being configured to store a computer program, the processor being configured to invoke and run the computer program from the memory, to cause the apparatus to perform the method of any of claims 1 to 17, or to cause the apparatus to perform the method of claim 18.
20. A chip comprising a processor which, when executing instructions, performs the method of any one of claims 1 to 17 or causes the chip to perform the method of claim 18.
21. A computer-readable storage medium, characterized in that it stores a computer program which, when executed by a processor, causes the processor to carry out the method of any one of claims 1 to 17 or causes the processor to carry out the method of claim 18.
Background
With the emergence of large data volume services such as enhanced mobile broadband (eMBB), high definition video (hd) and the like, electronic devices face a problem of insufficient storage space. An external memory (such as a Secure Digital (SD) card) connected to the electronic device can solve the problem of insufficient storage space, and data in the external memory needs to be encrypted for storage in order to ensure data security.
The key of the external memory is encrypted by the screen locking password and then stored in the erasable partition of the electronic device, and when a user performs factory reset (factory reset) on the electronic device, the encrypted key (i.e., ciphertext) in the erasable partition is deleted if the encrypted key is not stored in time, so that data in the external memory cannot be decrypted.
Disclosure of Invention
The application provides a method and a device for storing a ciphertext, which can solve the problem that data in an external memory cannot be decrypted after electronic equipment executes factory level reset.
In a first aspect, a method for saving a ciphertext is provided, including: acquiring an encryption instruction, wherein the encryption instruction indicates to encrypt a file in an external memory; acquiring a characteristic value of a first account identifier according to the encryption instruction; encrypting a first key by using the characteristic value of the first account identifier to generate a first ciphertext, wherein the first key is used for encrypting a second key, and the second key is used for encrypting a first file in the external memory; encrypting the characteristic value of the first account identification to generate a second ciphertext; storing the first ciphertext and the second ciphertext in an unerasable partition.
The electronic equipment acquires the encryption instruction, generates a first ciphertext and a second ciphertext, and stores the first ciphertext and the second ciphertext in the non-erasable partition of the electronic equipment, so that the electronic equipment completes the safe storage of the first ciphertext and the second ciphertext before the user conducts factory-level reset on the electronic equipment; after the electronic device completes the factory level reset, the first key can be recovered from the non-erasable partition, then the second key in the external memory is decrypted by using the first key, and the file in the external memory is decrypted by using the second key, so that the problem that the file in the external memory cannot be decrypted after the factory level reset is solved.
Optionally, the method further comprises: acquiring indication information of account switching; checking the first account identification according to the indication information; after the first account identification passes the verification, acquiring a characteristic value of a second account identification; and updating the first ciphertext and the second ciphertext according to the characteristic value of the second account identifier.
The user can switch the currently logged-in account identifier (such as a first account identifier) on the account login interface, and after the user triggers the electronic device to generate the indication information for switching the account on the account login interface, the electronic device can require the user to input a password corresponding to the first account identifier to check the first account identifier. After the first account id passes the verification, it is indicated that the user switching the account ids is a valid user, the electronic device may acquire a second account id input by the user, calculate a hash value (an example of a feature value) of the second account id, and then update the first ciphertext and the second ciphertext using the hash value of the second account id, where the electronic device may decrypt the first key first, then generate an updated first ciphertext using the hash value of the second account id, and then encrypt the hash value of the second account id to generate an updated second ciphertext. According to the scheme, after the current user (the user for switching the account identification) is determined to be a legal user, the account identification (the second account identification) of the current user is used for updating the first ciphertext and the second ciphertext, the right of encrypting and decrypting the external memory corresponding to the first account identification is removed, and therefore the safety of data in the external memory is guaranteed.
Optionally, the method further comprises: after the factory level reset is completed, checking the first account identification; and when the first account identification is successfully verified, decrypting the first ciphertext and the second ciphertext to generate the first key.
After the electronic equipment executes the factory level reset, an account verification mechanism is started, and the mechanism requires that the electronic equipment can be normally used after the account verification is successful. The last logged account identifier (such as the first account identifier) before the factory-level reset is verified, so that the user after the electronic equipment performs the factory-level reset can be ensured to be a legal user, and the safety of data in the external memory is ensured.
Optionally, the verifying the first account id includes:
when a Factory Reset Protection (FRP) state has been triggered, the first account id is verified.
Optionally, the method further comprises: encrypting the first key by using a default value to generate a third ciphertext; encrypting the default value to generate a fourth ciphertext; storing the third ciphertext and the fourth ciphertext in the unerasable partition.
Because the user may switch the account number, the electronic device continues to use the first account number identifier or the second account number identifier to encrypt and store the first key after performing the factory level reset, so that the risk of disclosure exists, and the electronic device may use a default value to encrypt and store the first key after decrypting the first key, so that the security of data in the external memory is ensured.
Optionally, the method further comprises: copying the third ciphertext and the fourth ciphertext from the non-erasable partition to an erasable partition; generating the first key according to the third ciphertext and the fourth ciphertext in the erasable partition; and decrypting the encrypted first file in the external memory according to the first key.
Optionally, before verifying the first account id, the method further includes: acquiring a factory-level reset instruction triggered by a recovery interface; data in an erasable partition is formatted according to the factory level reset instruction.
Optionally, the encrypting the first key by using the feature value identified by the first account number includes: invoking the key management module keymaster TA to execute: encrypting the first key by using the characteristic value of the first account identification; the encrypting the characteristic value of the first account id includes: invoking the keymaster TA to perform: and encrypting the characteristic value of the first account identification.
Optionally, the storing the first ciphertext and the second ciphertext in an unerasable partition includes: calling the application program interface of the trusted execution environment to execute: storing the first ciphertext and the second ciphertext in the unerasable partition.
Optionally, the first key is further used for encrypting a third key, and the third key is used for encrypting a second file encrypted in the external memory.
Optionally, the method further comprises: acquiring a characteristic value of a screen locking password according to the encryption instruction; encrypting the first secret key by using the characteristic value of the screen locking password to generate a fifth ciphertext; encrypting the characteristic value of the screen locking password to generate a sixth ciphertext; storing the fifth ciphertext and the sixth ciphertext in an erasable partition.
Optionally, the encrypting the first key using the feature value of the lock screen password includes: invoke the keymaster TA to perform: encrypting the first key using a feature value of the screen-locking password; the encrypting the characteristic value of the screen locking password comprises the following steps: invoking the keymaster TA to perform: and encrypting the characteristic value of the screen locking password.
Optionally, the method further comprises: acquiring a user-level reset instruction triggered by a setting interface; backing up the fifth ciphertext and the sixth ciphertext to the non-erasable partition according to the user-level reset instruction.
Optionally, the backing up the fifth ciphertext and the sixth ciphertext to the unerasable partition according to the user-level reset instruction includes: decrypting the first key from the fifth ciphertext and the sixth ciphertext according to the user-level reset instruction; encrypting the first key by using a default value to generate a seventh ciphertext; encrypting the default value to generate an eighth ciphertext; storing the seventh ciphertext and the eighth ciphertext in the unerasable partition.
Optionally, the method further comprises: copying the seventh ciphertext and the eighth ciphertext from the non-erasable partition to the erasable partition after a user-level reset is complete; decrypting the first key from the seventh ciphertext and the eighth ciphertext in the erasable partition; and decrypting the encrypted first file in the external memory according to the first key.
Optionally, the erasable partition is a data partition, and the characteristic value of the screen locking password is a hash value of the screen locking password.
Optionally, the non-erasable partition is a sec _ storage partition, and the characteristic value of the first account id is a hash value of the first account id.
In a second aspect, there is provided another method for saving ciphertext, including: displaying an encryption setting interface of the external memory; receiving a first operation performed by a user on the encryption setting interface; in response to the first operation, encrypting a file in the external memory; receiving a second operation of the user; displaying a factory level reset setting interface in response to the second operation; receiving a third operation performed by the user on the factory level reset setting interface; performing a plant level reset in response to the third operation; displaying an account verification interface; receiving verification information input by the user on the account verification interface; and when the verification information passes verification and an operation of accessing the file in the external memory by a user is received, decrypting the encrypted file in the external memory.
The electronic equipment acquires the encryption instruction, generates a first ciphertext and a second ciphertext, and stores the first ciphertext and the second ciphertext in the non-erasable partition of the electronic equipment, so that the electronic equipment completes the safe storage of the first ciphertext and the second ciphertext before the user conducts factory-level reset on the electronic equipment; after the electronic device completes the factory level reset, the first key can be recovered from the non-erasable partition, then the second key in the external memory is decrypted by using the first key, and the file in the external memory is decrypted by using the second key, so that the problem that the file in the external memory cannot be decrypted after the factory level reset is solved.
In a third aspect, an apparatus for holding ciphertext is provided that includes means for performing any of the methods of the first or second aspects. The device can be a terminal device or a chip in the terminal device. The apparatus may include an input unit and a processing unit.
When the apparatus is a terminal device, the processing unit may be a processor, and the input unit may be a communication interface; the terminal device may further comprise a memory for storing computer program code which, when executed by the processor, causes the terminal device to perform the method of any of the first or second aspects.
When the apparatus is a chip in a terminal device, the processing unit may be a processing unit inside the chip, and the input unit may be an output interface, a pin, a circuit, or the like; the chip may also include a memory, which may be a memory within the chip (e.g., registers, cache, etc.) or a memory external to the chip (e.g., read-only memory, random access memory, etc.); the memory is adapted to store computer program code which, when executed by the processor, causes the chip to perform the method of any one of the first or second aspects.
In a fourth aspect, there is provided a computer readable storage medium having computer program code stored thereon, which, when run by an apparatus for holding ciphertext, causes the apparatus to perform the method of any one of the first or second aspects.
In a fifth aspect, there is provided a computer program product comprising: computer program code which, when run by an apparatus for holding ciphertext, causes the apparatus to perform any of the methods of the first or second aspects.
Drawings
FIG. 1 is a schematic diagram of a hardware system suitable for use in the apparatus of the present application;
FIG. 2 is a schematic diagram of a software system suitable for use in the apparatus of the present application;
FIG. 3 is a schematic diagram of an encryption setup interface provided herein;
FIG. 4 is a schematic diagram of an encrypted validation interface provided herein;
FIG. 5 is a schematic diagram of an encryption process interface provided herein;
FIG. 6 is a schematic diagram of a method for storing a secret key provided herein;
FIG. 7 is a schematic diagram of an encryption process provided herein;
FIG. 8 is a schematic diagram of a method for backing up and recovering keys in a user-level reset scenario provided herein;
FIG. 9 is a schematic diagram illustrating ciphertext storage change of a storage region in a user-level reset scenario according to the present application;
FIG. 10 is a diagram illustrating a method for factory level rekeying provided herein;
FIG. 11 is a schematic view of an account login interface provided herein;
fig. 12 is a schematic diagram illustrating a ciphertext storage change of a storage area when an account is switched;
FIG. 13 is a schematic illustration of a factory level reset setup interface provided herein;
FIG. 14 is a schematic illustration of a plant level reset validation interface provided herein;
FIG. 15 is a schematic diagram of a factory level reset process interface provided herein;
FIG. 16 is a schematic diagram of a method for recovering keys in a factory level reset scenario provided herein;
FIG. 17 is a schematic view of an account verification interface provided herein;
FIG. 18 is a diagram illustrating ciphertext storage changes in a storage region in a factory level reset scenario, according to the present disclosure;
FIG. 19 is a schematic diagram of an apparatus for storing ciphertext provided herein;
fig. 20 is a schematic diagram of an electronic device for storing a ciphertext according to the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 1 shows a hardware system suitable for use in the apparatus of the present application.
The apparatus 100 may be a mobile phone, a smart screen, a tablet computer, a wearable electronic device, an in-vehicle electronic device, an Augmented Reality (AR) device, a Virtual Reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a Personal Digital Assistant (PDA), a projector, and the like, and the embodiment of the present application does not limit the specific type of the apparatus 100.
The apparatus 100 may include a processor 110, an external memory interface 120, an internal memory 121, a Universal Serial Bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, a Subscriber Identification Module (SIM) card interface 195, and the like. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
The configuration shown in fig. 1 is not intended to specifically limit the apparatus 100. In other embodiments of the present application, the apparatus 100 may include more or fewer components than those shown in FIG. 1, or the apparatus 100 may include a combination of some of the components shown in FIG. 1, or the apparatus 100 may include sub-components of some of the components shown in FIG. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination of software and hardware.
Processor 110 may include one or more processing units. For example, the processor 110 may include at least one of the following processing units: an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a video codec, a Digital Signal Processor (DSP), a baseband processor, and a neural Network Processor (NPU). The different processing units may be independent devices or integrated devices.
The controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of instruction fetching and instruction execution.
A memory may also be provided in processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Avoiding repeated accesses reduces the latency of the processor 110, thereby increasing the efficiency of the system.
In some embodiments, processor 110 may include one or more interfaces. For example, the processor 110 may include at least one of the following interfaces: an inter-integrated circuit (I2C) interface, an inter-integrated circuit audio source (I2S) interface, a Pulse Code Modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a general-purpose input/output (GPIO) interface, a SIM interface, and a USB interface.
The I2C interface is a bi-directional synchronous serial bus that includes a serial data line (SDA) and a Serial Clock Line (SCL). In some embodiments, processor 110 may include multiple sets of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc., respectively, through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K via an I2C interface, such that the processor 110 and the touch sensor 180K communicate via an I2C bus interface to implement the touch functionality of the device 100.
The I2S interface may be used for audio communication. In some embodiments, processor 110 may include multiple sets of I2S buses. The processor 110 may be coupled to the audio module 170 via an I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 may communicate audio signals to the wireless communication module 160 via the I2S interface, enabling answering of calls via a bluetooth headset.
The PCM interface may also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 may be coupled through a PCM interface. In some embodiments, the audio module 170 may also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to implement a function of answering a call through a bluetooth headset. Both the I2S interface and the PCM interface may be used for audio communication.
The UART interface is a universal serial data bus used for asynchronous communications. The bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, a UART interface is generally used to connect the processor 110 with the wireless communication module 160. For example: the processor 110 communicates with a bluetooth module in the wireless communication module 160 through a UART interface to implement a bluetooth function. In some embodiments, the audio module 170 may transmit the audio signal to the wireless communication module 160 through a UART interface, so as to realize the function of playing music through a bluetooth headset.
MIPI interfaces may be used to connect processor 110 with peripheral devices such as display screen 194 and camera 193. The MIPI interface includes a Camera Serial Interface (CSI), a Display Serial Interface (DSI), and the like. In some embodiments, processor 110 and camera 193 communicate through a CSI interface to implement the capture functionality of apparatus 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the device 100.
The GPIO interface may be configured by software. The GPIO interface may be configured as a control signal interface and may also be configured as a data signal interface. In some embodiments, a GPIO interface may be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, and the sensor module 180. The GPIO interface may also be configured as an I2C interface, an I2S interface, a UART interface, or a MIPI interface.
The USB interface 130 is an interface conforming to the USB standard specification, and may be a Mini (Mini) USB interface, a Micro (Micro) USB interface, or a USB Type C (USB Type C) interface, for example. The USB interface 130 may be used to connect a charger to charge the apparatus 100, to transmit data between the apparatus 100 and a peripheral device, and to connect an earphone to play audio through the earphone. The USB interface 130 may also be used to connect other apparatuses 100, such as AR devices.
The connection relationship between the modules shown in fig. 1 is merely illustrative and does not limit the connection relationship between the modules of the apparatus 100. Alternatively, the modules of the apparatus 100 may also adopt a combination of the connection manners in the above embodiments.
The charge management module 140 is used to receive power from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive the current of the wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive electromagnetic waves through a wireless charging coil of the device 100 (current path shown as dashed line). The charging management module 140 may also supply power to the device 100 through the power management module 141 while charging the battery 142.
The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140, and supplies power to the processor 110, the internal memory 121, the display 194, the camera 193, the wireless communication module 160, and the like. The power management module 141 may also be used to monitor parameters such as battery capacity, battery cycle number, and battery state of health (e.g., leakage, impedance). Alternatively, the power management module 141 may be disposed in the processor 110, or the power management module 141 and the charging management module 140 may be disposed in the same device.
The wireless communication function of the apparatus 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in device 100 may be used to cover a single or multiple communication bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed as a diversity antenna of a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
The mobile communication module 150 may provide a solution for wireless communication applied on the device 100, such as at least one of the following: second generation (2)thgeneration, 2G) mobile communication solution, third generation (3)thgeneration, 3G) mobile communication solution, fourth generation (4)thgeneration, 5G) mobile communication solution, fifth generation (5)thgeneration, 5G) mobile communication solutions. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a Low Noise Amplifier (LNA), and the like. The mobile communication module 150 may receive electromagnetic waves from the antenna 1, and perform filtering, amplification, and other processes on the received electromagnetic waves, and then transmit the electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 may also amplify the signal modulated by the modem processor, and the amplified signal is converted into electromagnetic waves by the antenna 1 to be radiated. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the same device as at least some of the modules of the processor 110.
The modem processor may include a modulator and a demodulator. The modulator is used for modulating a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used for demodulating the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then passes the demodulated low frequency baseband signal to a baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and then transferred to the application processor. The application processor outputs sound signals through an audio device (e.g., speaker 170A, microphone 170B) or displays images or video through the display screen 194. In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be provided in the same device as the mobile communication module 150 or other functional modules, independent of the processor 110.
Similar to the mobile communication module 150, the wireless communication module 160 may also provide a wireless communication solution applied on the device 100, such as at least one of the following: wireless Local Area Networks (WLANs), Bluetooth (BT), Bluetooth Low Energy (BLE), Ultra Wide Band (UWB), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR) technologies. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency-modulates and filters electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive, frequency modulate and amplify the signal to be transmitted from the processor 110, which is converted to electromagnetic waves via the antenna 2 for radiation.
In some embodiments, antenna 1 of apparatus 100 and mobile communication module 150 are coupled and antenna 2 of apparatus 100 and wireless communication module 160 are coupled such that electronic device 100 may communicate with a network and other electronic devices through wireless communication techniques. The wireless communication technology may include at least one of the following communication technologies: global system for mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), time division code division multiple access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, IR technologies. The GNSS may include at least one of the following positioning techniques: global Positioning System (GPS), global navigation satellite system (GLONASS), beidou satellite navigation system (BDS), quasi-zenith satellite system (QZSS), Satellite Based Augmentation System (SBAS).
The device 100 may implement display functionality through the GPU, the display screen 194, and the application processor. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and an application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
The display screen 194 may be used to display images or video. The display screen 194 includes a display panel. The display panel may adopt a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Mini light-emitting diode (Mini LED), a Micro light-emitting diode (Micro LED), a Micro OLED (Micro OLED), or a quantum dot light-emitting diode (QLED). In some embodiments, the apparatus 100 may include 1 or N display screens 194, N being a positive integer greater than 1.
The device 100 may implement a photographing function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
The ISP is used to process the data fed back by the camera 193. For example, when a photo is taken, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converting into an image visible to naked eyes. The ISP can perform algorithm optimization on the noise, brightness and color of the image, and can also optimize parameters such as exposure, color temperature and the like of a shooting scene. In some embodiments, the ISP may be provided in camera 193.
The camera 193 is used to capture still images or video. The object generates an optical image through the lens and projects the optical image to the photosensitive element. The photosensitive element may be a Charge Coupled Device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The light sensing element converts the optical signal into an electrical signal, which is then passed to the ISP where it is converted into a digital image signal. And the ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into a standard Red Green Blue (RGB), YUV, or the like format image signal. In some embodiments, device 100 may include 1 or N cameras 193, N being a positive integer greater than 1.
The digital signal processor is used for processing digital signals, and can process digital image signals and other digital signals. For example, when the apparatus 100 selects a frequency bin, the digital signal processor is configured to perform fourier transform or the like on the frequency bin energy.
Video codecs are used to compress or decompress digital video. The apparatus 100 may support one or more video codecs. In this way, the apparatus 100 can play or record video in a variety of encoding formats, such as: moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG 4.
The NPU is a processor which uses biological neural network structure for reference, for example, the NPU can rapidly process input information by using a transfer mode between human brain neurons, and can also continuously self-learn. The NPU may implement functions of the apparatus 100, such as intelligent recognition: image recognition, face recognition, speech recognition and text understanding.
The external memory interface 120 may be used to connect an external memory card, such as a Secure Digital (SD) card, to implement the memory capability of the expansion device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music, video, etc. are saved in an external memory card.
The internal memory 121 may be used to store computer-executable program code, which includes instructions. The internal memory 121 may include a program storage area and a data storage area. Wherein the storage program area may store an operating system, an application program required for at least one function (e.g., a sound playing function and an image playing function). The storage data area may store data (e.g., audio data and a phonebook) created during use of the device 100. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a nonvolatile memory such as: at least one magnetic disk storage device, a flash memory device, and a universal flash memory (UFS), and the like. The processor 110 performs various processing methods of the apparatus 100 by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
The apparatus 100 may implement audio functions, such as music playing and recording, through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor.
The audio module 170 is used to convert digital audio information into an analog audio signal for output, and may also be used to convert an analog audio input into a digital audio signal. The audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 or some functional modules of the audio module 170 may be disposed in the processor 110.
The speaker 170A, also referred to as a horn, converts the audio electrical signal into a sound signal. The device 100 may listen to music or hands-free talk through the speaker 170A.
The receiver 170B, also called an earpiece, is used to convert the electrical audio signal into a sound signal. When the user uses the device 100 to receive a call or voice information, the voice can be received by placing the receiver 170B close to the ear.
The microphone 170C, also referred to as a microphone or microphone, is used to convert sound signals into electrical signals. When a user makes a call or sends voice information, a sound signal may be input into the microphone 170C by sounding near the microphone 170C. The apparatus 100 may be provided with at least one microphone 170C. In other embodiments, the apparatus 100 may be provided with two microphones 170C to implement the noise reduction function. In other embodiments, three, four, or more microphones 170C may be provided with the apparatus 100 to perform the functions of identifying the source of the sound and directing the recording. The processor 110 may process the electrical signal output by the microphone 170C, for example, the audio module 170 and the wireless communication module 160 may be coupled via a PCM interface, and the microphone 170C converts the ambient sound into an electrical signal (e.g., a PCM signal) and transmits the electrical signal to the processor 110 via the PCM interface; from processor 110, the electrical signal is subjected to a volume analysis and a frequency analysis to determine the volume and frequency of the ambient sound.
The headphone interface 170D is used to connect a wired headphone. The headset interface 170D may be the USB interface 130, or may be a 3.5mm open mobile device 100 platform (OMTP) standard interface, a cellular telecommunications industry association (cellular telecommunications industry association of the USA, CTIA) standard interface.
The pressure sensor 180A is used for sensing a pressure signal, and converting the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the display screen 194. The pressure sensor 180A may be of a wide variety, and may be, for example, a resistive pressure sensor, an inductive pressure sensor, or a capacitive pressure sensor. The capacitive pressure sensor may be a sensor that includes at least two parallel plates having conductive material, and when a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes, and the apparatus 100 determines the strength of the pressure based on the change in capacitance. When a touch operation is applied to the display screen 194, the device 100 detects the touch operation from the pressure sensor 180A. The apparatus 100 may also calculate the position of the touch from the detection signal of the pressure sensor 180A. In some embodiments, the touch operations that are applied to the same touch position but different touch operation intensities may correspond to different operation instructions. For example: when the touch operation with the touch operation intensity smaller than the first pressure threshold value acts on the short message application icon, executing an instruction for viewing the short message; and when the touch operation with the touch operation intensity larger than or equal to the first pressure threshold value acts on the short message application icon, executing an instruction of newly building the short message.
The gyro sensor 180B may be used to determine the motion attitude of the apparatus 100. In some embodiments, the angular velocity of device 100 about three axes (i.e., the x-axis, y-axis, and z-axis) may be determined by gyroscope sensor 180B. The gyro sensor 180B may be used for photographing anti-shake. For example, when the shutter is pressed, the gyro sensor 180B detects the shake angle of the device 100, calculates the distance to be compensated for by the lens module according to the shake angle, and allows the lens to counteract the shake of the device 100 by a reverse movement, thereby achieving anti-shake. The gyro sensor 180B can also be used in scenes such as navigation and motion sensing games.
The air pressure sensor 180C is used to measure air pressure. In some embodiments, the device 100 calculates altitude from barometric pressure values measured by the barometric pressure sensor 180C, aiding in positioning and navigation.
The magnetic sensor 180D includes a hall sensor. The device 100 may detect the opening and closing of the flip holster using the magnetic sensor 180D. In some embodiments, when the apparatus 100 is a flip phone, the apparatus 100 may detect the opening and closing of the flip according to the magnetic sensor 180D. The device 100 can set the automatic unlocking of the flip cover according to the detected opening and closing state of the leather sheath or the opening and closing state of the flip cover.
Acceleration sensor 180E may detect the magnitude of acceleration of device 100 in various directions, typically the x-axis, y-axis, and z-axis. The magnitude and direction of gravity can be detected when the device 100 is at rest. The acceleration sensor 180E may also be used to recognize the attitude of the device 100 as an input parameter for applications such as landscape and portrait screen switching and pedometers.
The distance sensor 180F is used to measure a distance. The device 100 may measure distance by infrared or laser. In some embodiments, for example in a shooting scene, the device 100 may utilize the range sensor 180F to range for fast focus.
The proximity light sensor 180G may include, for example, a light-emitting diode (LED) and a photodetector, for example, a photodiode. The LED may be an infrared LED. The device 100 emits infrared light outward through the LED. The apparatus 100 uses a photodiode to detect infrared reflected light from nearby objects. When reflected light is detected, the apparatus 100 may determine that an object is present nearby. When no reflected light is detected, the apparatus 100 can determine that there is no object nearby. The device 100 can detect whether the user holds the device 100 close to the ear or not by using the proximity light sensor 180G, so as to automatically turn off the screen to save power. The proximity light sensor 180G may also be used for automatic unlocking and automatic screen locking in a holster mode or a pocket mode.
The ambient light sensor 180L is used to sense the ambient light level. The device 100 may adaptively adjust the brightness of the display screen 194 based on the perceived ambient light level. The ambient light sensor 180L may also be used to automatically adjust the white balance when taking a picture. The ambient light sensor 180L may also cooperate with the proximity light sensor 180G to detect whether the device 100 is in a pocket to prevent inadvertent contact.
The fingerprint sensor 180H is used to collect a fingerprint. The device 100 can utilize the collected fingerprint characteristics to achieve the functions of unlocking, accessing an application lock, taking a picture, answering an incoming call, and the like.
The temperature sensor 180J is used to detect temperature. In some embodiments, the apparatus 100 implements a temperature processing strategy using the temperature detected by the temperature sensor 180J. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the apparatus 100 performs a reduction in performance of a processor located near the temperature sensor 180J, so as to reduce power consumption and implement thermal protection. In other embodiments, the device 100 heats the battery 142 when the temperature is below another threshold to avoid a low temperature causing the device 100 to shut down abnormally. In other embodiments, when the temperature is below a further threshold, the apparatus 100 performs a boost on the output voltage of the battery 142 to avoid abnormal shutdown due to low temperature.
The touch sensor 180K is also referred to as a touch device. The touch sensor 180K may be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, which is also referred to as a touch screen. The touch sensor 180K is used to detect a touch operation applied thereto or in the vicinity thereof. The touch sensor 180K may pass the detected touch operation to the application processor to determine the touch event type. Visual output associated with the touch operation may be provided through the display screen 194. In other embodiments, the touch sensor 180K may be disposed on a surface of the device 100 at a different location than the display screen 194.
The bone conduction sensor 180M may acquire a vibration signal. In some embodiments, the bone conduction sensor 180M may acquire a vibration signal of the human vocal part vibrating the bone mass. The bone conduction sensor 180M may also contact the human pulse to receive the blood pressure pulsation signal. In some embodiments, the bone conduction sensor 180M may also be disposed in a headset, integrated into a bone conduction headset. The audio module 170 may analyze a voice signal based on the vibration signal of the bone mass vibrated by the sound part acquired by the bone conduction sensor 180M, so as to implement a voice function. The application processor can analyze heart rate information based on the blood pressure beating signal acquired by the bone conduction sensor 180M, so as to realize the heart rate detection function.
The keys 190 include a power-on key and a volume key. The keys 190 may be mechanical keys or touch keys. The device 100 can receive a key input signal and realize the function related to the case input signal.
The motor 191 may generate vibrations. The motor 191 may be used for incoming call prompts as well as for touch feedback. The motor 191 may generate different vibration feedback effects for touch operations applied to different applications. The motor 191 may also produce different vibration feedback effects for touch operations applied to different areas of the display screen 194. Different application scenarios (e.g., time reminders, received messages, alarms, and games) may correspond to different vibration feedback effects. The touch vibration feedback effect may also support customization.
Indicator 192 may be an indicator light that may be used to indicate a change in charge status and charge level, or may be used to indicate a message, missed call, and notification.
The SIM card interface 195 is used to connect a SIM card. The SIM card may be inserted into the SIM card interface 195 to make contact with the device 100, or may be removed from the SIM card interface 195 to make separation from the device 100. The apparatus 100 may support 1 or N SIM card interfaces, N being a positive integer greater than 1. The same SIM card interface 195 may be inserted with multiple cards at the same time, which may be of the same or different types. The SIM card interface 195 may also be compatible with external memory cards. The device 100 interacts with the network through the SIM card to implement functions such as communication and data communication. In some embodiments, the device 100 employs an embedded SIM (eSIM) card, which can be embedded in the device 100 and cannot be separated from the device 100.
The hardware system of the apparatus 100 is described in detail above, and the software system of the apparatus 100 is described below. The software system may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture or a cloud architecture, and the software system of the apparatus 100 is exemplarily described in the embodiment of the present application by taking the layered architecture as an example.
As shown in fig. 2, the software system adopting the layered architecture is divided into a plurality of layers, and each layer has a clear role and division of labor. The layers communicate with each other through a software interface. In some embodiments, the software system may be divided into four layers, an application layer, an application framework layer, an Android Runtime (Android Runtime) and system library, and a kernel layer from top to bottom, respectively.
The application layer may include applications such as camera, gallery, calendar, talk, map, navigation, WLAN, bluetooth, music, video, short message, etc.
The application framework layer provides an Application Programming Interface (API) and a programming framework for the application of the application layer. The application framework layer may include some predefined functions.
For example, the application framework layers include a window manager, a content provider, a view system, a phone manager, a resource manager, and a notification manager.
The window manager is used for managing window programs. The window manager can obtain the size of the display screen and judge whether a status bar, a lock screen and a capture screen exist.
The content provider is used to store and retrieve data and make it accessible to applications. The data may include video, images, audio, calls made and answered, browsing history and bookmarks, and phone books.
The view system includes visual controls such as controls to display text and controls to display pictures. The view system may be used to build applications. The display interface may be composed of one or more views, for example, a display interface including a short message notification icon, which may include a view displaying text and a view displaying pictures.
The phone manager is used to provide communication functions of the device 100, such as management of call status (on or off).
The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, and video files.
The notification manager enables the application to display notification information in the status bar, can be used to convey notification-type messages, can disappear automatically after a short dwell, and does not require user interaction. Such as notification managers, are used for download completion notifications and message reminders. The notification manager may also manage notifications that appear in a chart or scrollbar text form in a status bar at the top of the system, such as notifications for applications running in the background. The notification manager may also manage notifications that appear on the screen in dialog windows, such as prompting for text messages in a status bar, sounding a prompt tone, vibrating the electronic device, and flashing an indicator light.
The Android Runtime comprises a core library and a virtual machine. The Android runtime is responsible for scheduling and managing an Android system.
The core library comprises two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The application layer and the application framework layer run in a virtual machine. And executing java files of the application program layer and the application program framework layer into a binary file by the virtual machine. The virtual machine is used to perform the functions of object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
The system library may include a plurality of functional modules, such as: surface managers (surface managers), Media Libraries (Media Libraries), three-dimensional graphics processing Libraries (e.g., open graphics library for embedded systems, OpenGL ES) and 2D graphics engines (e.g., Skin Graphics Library (SGL)) for embedded systems.
The surface manager is used for managing the display subsystem and providing fusion of the 2D layer and the 3D layer for a plurality of application programs.
The media library supports playback and recording of multiple audio formats, playback and recording of multiple video formats, and still image files. The media library may support a variety of audiovisual coding formats, such as MPEG4, h.264, moving picture experts group audio layer 3 (MP 3), Advanced Audio Coding (AAC), adaptive multi-rate (AMR), joint picture experts group (JPG), and Portable Network Graphics (PNG).
The three-dimensional graphics processing library may be used to implement three-dimensional graphics drawing, image rendering, compositing, and layer processing.
The two-dimensional graphics engine is a drawing engine for 2D drawing.
The kernel layer is a layer between hardware and software. The kernel layer can comprise driving modules such as a display driver, a camera driver, an audio driver and a sensor driver.
The following illustrates the workflow of the software system and the hardware system of the apparatus 100 in connection with displaying a photographing scene.
When a user performs a touch operation on the touch sensor 180K, a corresponding hardware interrupt is sent to the kernel layer, and the kernel layer processes the touch operation into an original input event, where the original input event includes information such as touch coordinates and a timestamp of the touch operation. The original input event is stored in the kernel layer, and the application framework layer acquires the original input event from the kernel layer, identifies a control corresponding to the original input event, and notifies an Application (APP) corresponding to the control. For example, the touch operation is a click operation, the APP corresponding to the control is a camera APP, and after the camera APP is awakened by the click operation, the camera drive of the kernel layer can be called through the API, and the camera 193 is controlled to shoot through the camera drive.
The method for saving ciphertext provided by the present application is described as an example of the apparatus 100.
In order to ensure the security of the files in the external memory, the files in the external memory may be encrypted and stored in the external memory, and the keys for decrypting the files are stored in the internal memory of the device 100, so that the content in the external memory can only be read out as plaintext in the device 100, and when the external memory is connected to other electronic devices, because the other electronic devices do not store the keys, the content in the external memory cannot be decrypted by the other electronic devices, thereby ensuring the security of the files in the external memory.
The external memory may be an SD card, a usb disk, or another type of memory, and the external memory may establish a data connection with the device 100 in an insertion manner, or may establish a data connection with the device 100 in a wired or wireless manner. The following description will be made by taking SD as an example.
The user may trigger the encryption process for the SD card at the encryption setup interface shown in fig. 3. The user may click on "encrypt memory card" in fig. 3 to enter the encryption setup confirmation interface shown in fig. 4, and then click on "encrypt memory card" in fig. 4 to confirm that the file in the SD card is encrypted, and the interface of the encryption process is shown in fig. 5. The encryption algorithm used in the encryption process is not limited in the present application.
After the file in the SD card is encrypted, the File Encryption Key (FEK) needs to be properly stored. One way to save FEK is to encrypt FEK multiple times before storing it in erasable partitions, as shown in fig. 6.
After a user triggers an encryption process on the SD card on the encryption setting interface shown in fig. 3, the SD card encryption setting module generates an encryption instruction, and there are two cases for the module called by the encryption instruction based on the setting condition of the screen locking password.
The first condition is as follows: the lock screen password is not set.
The SD card encryption module calls the encryption management module (Vold) to encrypt the FEK through the encryption command, and subsequently encrypts a file encryption key (FEKEK) of the encrypted FEK using a default value (empty auth) when the user does not set the screen locking password, which will be described in detail below.
Case two: the lock screen password is set.
The SD card encryption module calls a lock screen service (LockSettingsService) to acquire a password hash value through the encryption instruction, and then the lock screen service transmits the password hash value to the encryption management module (Vold) so as to encrypt the key for encrypting the FEK by using the password hash value subsequently. The password hash value is information generated based on the screen locking password, for example, the screen locking service performs hash calculation on the screen locking password to generate the password hash value when the user sets the screen locking password, and acquires the previously stored password hash value after the user triggers the encryption of the SD card and transmits the password hash value to the encryption management module.
Vold is responsible for realizing encryption and decryption core functions, and triggers encryption logic or decryption logic for the SD card by calling an encryption library or a decryption library.
When a file system (e.g., eCryptfs) creates a file in an SD card, the file system generates a random number for each file, for example, when eCryptfs creates a new file, a random number, i.e., FEK, is created using a random function provided by a kernel. The FEK is used to encrypt files in the SD card and to decrypt files encrypted in the SD card.
Optionally, eCryptfs stores the encrypted file in a file format of open good privacy protocol (OpenPGP), and the encrypted file may be divided into a plurality of logical blocks (extents), where the size of each logical block is adjustable, but the size of each logical block is usually not larger than the size of a physical page.
After the file in the SD card is encrypted, the FEK needs to be stored in an encrypted way. Vold unmounts the file system when the user sets the SD card encryption and re-mounts the file system, and at this time, a random number, that is, FEKEK (an example of the first key), is generated. The FEKEK is used to encrypt the FEK (one example of the second key), where the FEKEK is set by Vold to a key ring (keying) of the kernel, and the file system acquires the FEKEK from the keying when encrypting the FEK. The encrypted FEK is stored in metadata (meta data) of the encrypted file.
After the FEK is encrypted, the FEKEK also needs to be stored encrypted. Since Vold belongs to a module in a Rich Execution Environment (REE), security does not meet requirements, FEKEK cannot be encrypted, Vold can call a key management module in a Trusted Execution Environment (TEE), that is, a keycaster Trusted Application (TA), through a Client Application (CA), and encryption of FEKEK is completed by the keycaster TA.
The keymaster TA may encrypt the FEKEK using the password hash value and according to Advanced Encryption Standard (AES), generating ciphertext 1 (one example of a fifth ciphertext). Subsequently, the keymaster TA may encrypt the password hash value according to AES using a Hardware Unique Key (HUK) to generate a keymaster _ key _ blob (an example of a sixth ciphertext). The keymaster TA stores the ciphertext 1 and the keymaster _ key _ blob in the erasable partition (/ data path).
Because the HUKs of different devices have uniqueness, the HUK is used for encrypting the password hash value, and the key master _ key _ blob can only be decrypted on the device 100, so that the security of the encrypted file in the SD card is ensured.
The encryption flow involved in fig. 6 is shown in fig. 7.
If two files to be encrypted (file 1 and file 2) exist in the current SD card, the file system generates two random numbers for the two files, namely, FEK1 and FEK 2; subsequently, the file system encrypts file 1 using FEK1 and file 2 using FEK 2.
After the files 1 and 2 are encrypted, the file system acquires the FEKEK from the keying, and uses the FEKEK to encrypt the FEK1 and the FEK2 respectively, the encrypted FEK1 is stored in the metadata of the file 1, and the encrypted FEK2 is stored in the metadata of the file 2.
Subsequently, Vold calls the keymaster TA through CA, and the keymaster TA encrypts the FEKEK by using a password hash value; the keymaster TA then encrypts the password hash value using the hardware HUK.
When the encrypted file in the SD card needs to be decrypted, the device 100 performs the inverse process of the encryption flow shown in fig. 7, for example, Vold calls keymaster TA through CA to perform the following decryption steps: the keymaster TA acquires the keymaster _ key _ blob and the ciphertext 1 from the erasable partition, decrypts the keymaster _ key _ blob by using the HUK to obtain a password hash value, and then decrypts the ciphertext 1 by using the password hash value to obtain the FEKEK. And after the Vold acquires the FEKEK from the keymaster TA, setting the FEKEK to the keying, acquiring the FEKEK from the keying by the file system, decrypting the FEK, and decrypting the decrypted file in the SD card by using the FEK.
For example, when eCryptfs opens an encrypted file, the metadata of the header of the encrypted file is read through the lower file system, and the metadata is delivered to the Keystore module (module containing the keymaster TA); the Keystore module acquires the FEKEK from the keyring, and decrypts the encrypted FEK in the metadata by using the FEKEK to generate the FEK; subsequently, eCryptfs decrypts the encrypted file using FEK. When decrypting an encrypted file, each logical block (extend) of the encrypted file is read into a cache page (page cache) and decrypted through a Kernel Crypto API.
When the device 100 performs a first type of reset (also referred to as "user-level reset", that is, the user resets the device 100 from the system setup menu), the data of the erasable area is cleared, and at this time, the device 100 may back up the ciphertext 1 and the keymaster _ key _ blob, so as to prevent the ciphertext 1 and the keymaster _ key _ blob from being deleted, which may result in the file in the SD card being unable to be decrypted. The backup flow for user level reset is shown in fig. 8.
The user controls the apparatus 100 to restore factory settings through the setting interface. The device 100 checks the screen locking password input by the user, for example, the device 100 calculates the screen locking password input by the user to obtain a password hash value, then compares the calculated password hash value with the stored password hash value, and if the two password hash values are the same, it is determined that the check is passed.
After the verification is passed, the application framework layer (framework) sends a broadcast message for restoring factory settings. And starting a backup key process after the Vold receives the broadcast message, decrypting the FEKEK from the erasable partition by calling the keymaster TA through the CA, then encrypting the FEKEK by using a default value (empty auth), encrypting the default value by using the HUK, and storing the encrypted FEKEK and the default value (an example of a seventh ciphertext and an eighth ciphertext) in the non-erasable partition.
In this application, the non-erasable partition refers to a storage area where data is not erased during the second type of reset (also referred to as "factory level reset", that is, the user does not reset the apparatus 100 through the system setting menu), and the non-erasable partition may be a/sec _ store, or other secure storage areas in the TEE, such as a playback protected memory block (RPMB).
After the device 100 is restored to factory settings and restarted, it is detected whether the SD card is in place. When the SD is in place, the keymaster TA copies the encrypted FEKEK and the default value from the non-erasable partition to the erasable partition, so that the encrypted FEKEK and the default value can be used for recovering the FEK and decrypting the file in the SD card.
In summary, the key change situation stored in the storage area before and after the device 100 performs the user-level reset is shown in fig. 9.
After the user instructs device 100 to perform a user-level reset, device 100 is triggered to perform a key backup. In the key backup stage, the ciphertext 1 and the keymaster _ key _ blob are stored in the erasable partition, and the ciphertext 1 and the keymaster _ key _ blob are decrypted and encrypted and stored in the non-erasable partition in the form of 'default value encrypted FEKEK and HUK encrypted default value'.
After the key backup is complete, the device 100 enters the formatting phase. During the formatting phase, data in the erasable partition is cleared and data in the non-erasable partition is preserved.
After the formatting is complete, the device 100 enters a key recovery phase. In the key recovery phase, the ciphertext (default values for FEKEK and HUK encryption encrypted) in the non-erasable partition is copied to the erasable partition, thereby completing the key recovery.
In the user-level reset process, the user needs to format the device 100 through the system setup menu, and the device 100 has an opportunity to backup the ciphertext (encrypted FEKEK) in the erasable partition, so that the file in the SD card can still be decrypted after the device 100 is formatted. However, when the user does not perform the second type of reset (i.e., factory level reset) on the device 100 through the system setup menu, the ciphertext in the erasable partition may be deleted without being copied to the non-erasable partition, thereby rendering the file in the SD card un-decryptable after the device 100 is formatted.
Another embodiment of the method for saving ciphertext provided by the present application is described below, which enables the device 100 to decrypt the file in the SD card after the device has undergone a factory level reset. This embodiment may be applied to the apparatus 100 in common with the "user level reset" embodiment described above, or may be applied to the apparatus 100 separately.
After the user triggers the encryption of the SD card in the setting interface shown in fig. 3, the device 100 executes the key backup process shown in fig. 10. As shown in fig. 10, the SD card encryption setting module calls the account login module for subsequent processing through an encryption command. Based on the account login condition, the account login module has the following two processing modes.
Case three: the user does not log in to the account.
The account login module displays an account login interface shown in fig. 11, and prompts the user to login an account (e.g., a glory account). After the account login is successful, the account login module calculates a hash value of an account Identifier (ID), and then transmits the hash value of the account ID to Vold.
Case four: the user has logged into the account.
The account login module acquires the hash value of the account ID and transmits the hash value of the account ID to Vold. Optionally, if the account login module does not calculate the hash value of the account ID before the user triggers the SD card encryption, the account login module calculates the hash value of the account ID when the user triggers the SD card encryption; if the account login module calculates the hash value of the account ID before the user triggers the SD card encryption, the account login module directly acquires the hash value of the account ID when the user triggers the SD card encryption.
And after the Vold obtains the hash value of the account ID, calling the keymaster TA through the CA, and encrypting and backing up the FEKEK by the keymaster TA.
The keymaster TA may encrypt FEKEK according to AES using the hash value of the account ID to generate ciphertext 2 (one example of the first ciphertext). Subsequently, the keymaster TA may encrypt the hash value of the account ID according to AES using the HUK to generate a keymaster _ blob _ bak (an example of the second ciphertext). The keymaster TA calls the TEE API to store the ciphertext 2 and the keymaster _ key _ blob _ bak in the unerasable partition (/ sec _ storage path), thereby completing the FEKEK backup.
Because the HUKs of different devices have uniqueness, the HUK is used for encrypting the hash value of the account ID, and the key master _ key _ blob _ bak can only be decrypted on the device 100, so that the security of the encrypted file in the SD card is ensured.
In the method shown in fig. 10, after the user triggers the encryption of the SD card through the setting interface, the device 100 may back up the FEKEK at any time before performing the factory level reset, and even if the subsequent device 100 performs the factory level reset, the FEKEK may be recovered after the restart, thereby solving the problem that the file in the SD card cannot be decrypted after the factory level reset.
Optionally, after the device 100 executes the method shown in fig. 10, if the user switches the login account ID, Vold obtains a hash value of the new account ID, and updates the ciphertext 2 and the keymaster _ key _ blob _ bak by using the hash value of the new account ID, where the updating process is shown in fig. 12.
The following describes a process of decrypting a file in an SD card after the device 100 performs a factory level reset.
The user first locks (or shuts down) the device 100 and then may press a combination key (e.g., "volume key" + "power key") to place the device 100 in recovery mode, displaying the factory level reset settings interface shown in fig. 13. Subsequently, the user clicks "restore factory setting" and the device 100 displays a confirmation interface shown in fig. 14. After the user clicks "restore factory settings" on the interface shown in fig. 13, the apparatus 100 performs factory level reset, and displays the factory level reset interface shown in fig. 15.
The device 100 restarts after completing the factory level reset, runs the boot wizard, and executes the key recovery process shown in fig. 16.
The boot wizard calls the handset recovery module to determine whether a Factory Reset Protection (FRP) state has been triggered. The mobile phone retrieving module calls the anti-theft TA through the anti-theft CA to determine whether the FRP state has been triggered, and if the FRP state has been triggered, the mobile phone retrieving module displays an account verification interface shown in fig. 17, where an account verified by the account verification interface is an account associated with the FRP state (i.e., an account last logged in before the device 100 performs factory-level reset). After the user inputs the correct password on the interface, the mobile phone retrieving module informs the Vold account number of successful verification. Subsequently, Vold invokes keymaster TA via CA to perform the following key recovery steps.
The keymaster TA acquires the keymaster _ key _ blob _ bak and the ciphertext 2 from the non-erasable partition, decrypts the keymaster _ key _ blob _ bak by using the HUK to obtain a hash value of the account ID, and then decrypts the ciphertext 2 by using the hash value of the account ID to obtain the FEKEK.
The keymaster TA re-encrypts the FEKEK using a default value (empty auth) to generate a third ciphertext, and encrypts the default value using the HUK to generate a fourth ciphertext. The encrypted FEKEK and default values are saved as backup keys in the non-erasable partition (/ sec _ storage path). Subsequently, the keymaster TA copies the encrypted FEKEK and default values to the erasable partition (/ data path) for use in encrypting or decrypting files in the SD card. The above embodiment allows the device 100 to decrypt the SD card using the default value as a key without setting a new screen lock password, since the device 100 clears the old screen lock password after performing the factory level reset.
Alternatively, the keymaster TA may not encrypt the FEKEK using the default value, and directly copy the keymaster _ key _ blob _ bak and the ciphertext 2 from the non-erasable partition to the erasable partition, in which case the device 100 may prompt the user to set a new lock screen password in order to encrypt the FEKEK using the new lock screen password.
When the file in the SD card needs to be encrypted, the keymaster TA decrypts the FEKEK from the erasable partition and transmits the FEKEK to the key ring through Vold. The file system uses the FEK to encrypt the file in the SD card, then obtains the FEKEK from the key ring, uses the FEKEK to encrypt the FEK, and the encrypted FEK is stored in the metadata of the file.
When the file in the SD card needs to be decrypted, the keymaster TA decrypts the FEKEK from the erasable partition and transmits the FEKEK to the key ring through Vold. The file system decrypts the FEK from the metadata of the file of the SD card using the FEKEK, and then decrypts the file using the FEK.
In summary, the key change situation stored in the storage area before and after the device 100 performs the factory level reset is shown in fig. 18.
When the user instructs the device 100 to encrypt a file in the SD card, the device 100 is triggered to perform a key backup. In the key backup stage, an erasable partition is stored with a ciphertext 1 and a keymaster _ key _ blob, and an unerasable partition is stored with a ciphertext 2 and a keymaster _ key _ blob _ bak, where the ciphertext 1 is FEKEK encrypted using a password hash value, the keymaster _ key _ blob is a password hash value encrypted using a HUK, the ciphertext 2 is FEKEK encrypted using a hash value of an account ID, and the keymaster _ key _ blob _ bak is a hash value of the account ID encrypted using the HUK.
After the user instructs the device 100 to perform the factory level reset, the device 100 enters the factory level reset phase and performs the formatting. During the factory level reset phase, data in the erasable partition is cleared and data in the non-erasable partition is retained.
After the formatting is complete, the device 100 enters a key recovery phase. In the key recovery phase, the ciphertext (ciphertext 2 and keymaster _ key _ blob _ bak) in the non-erasable partition is decrypted and encrypted, and copied to the erasable partition in the form of "default value encrypted FEKEK and HUK encrypted default value", thereby completing the key recovery.
Examples of the methods for saving ciphertext provided herein are described in detail above. It is understood that the corresponding apparatus contains hardware structures and/or software modules corresponding to the respective functions for implementing the functions described above. Those of skill in the art would readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The present application may divide the functional units of the device for storing the ciphertext according to the above method, for example, each function may be divided into each functional unit, or two or more functions may be integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit. It should be noted that the division of the units in the present application is schematic, and is only one division of logic functions, and there may be another division manner in actual implementation.
Fig. 19 is a schematic structural diagram of an apparatus for saving a ciphertext according to the present application. The apparatus 1900 includes a processing unit 1910 and an input unit 1920.
The input unit 1920 is configured to: acquiring an encryption instruction, wherein the encryption instruction indicates to encrypt a file in an external memory;
processing unit 1910 is to: acquiring a characteristic value of a first account identifier according to the encryption instruction; encrypting a first key by using the characteristic value of the first account identifier to generate a first ciphertext, wherein the first key is used for encrypting a second key, and the second key is used for encrypting a first file in the external memory; encrypting the characteristic value of the first account identification to generate a second ciphertext; storing the first ciphertext and the second ciphertext in an unerasable partition.
Optionally, the input unit 1920 is further configured to: acquiring indication information of account switching;
the processing unit 1910 is further configured to: checking the first account identification according to the indication information; after the first account identification passes the verification, acquiring a characteristic value of a second account identification; and updating the first ciphertext and the second ciphertext according to the characteristic value of the second account identifier.
Optionally, the processing unit 1910 is further configured to: determining whether the FRP state has been triggered; when the FRP state is triggered, checking the first account identification; and when the first account identification is successfully verified, decrypting the first ciphertext and the second ciphertext to generate the first key.
Optionally, the processing unit 1910 is further configured to: encrypting the first key by using a default value to generate a third ciphertext; encrypting the default value to generate a fourth ciphertext; storing the third ciphertext and the fourth ciphertext in the unerasable partition.
Optionally, the processing unit 1910 is further configured to: copying the third ciphertext and the fourth ciphertext from the non-erasable partition to an erasable partition; generating the first key according to the third ciphertext and the fourth ciphertext in the erasable partition; and decrypting the file in the external memory according to the first key.
The specific manner in which the apparatus 1900 performs the method for saving ciphertext and the resulting beneficial effects may be referred to in the description of the method embodiments.
Fig. 20 shows a schematic structural diagram of an electronic device provided in the present application. The dashed lines in fig. 20 indicate that the unit or the module is optional. The apparatus 2000 may be used to implement the methods described in the method embodiments above.
The apparatus 2000 includes one or more processors 2001, which one or more processors 2001 may support the apparatus 2000 to implement the methods in the method embodiments. The processor 2001 may be a general-purpose processor or a special-purpose processor. For example, the processor 2001 may be a Central Processing Unit (CPU), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic device, such as a discrete gate, a transistor logic device, or a discrete hardware component.
The processor 2001 may be used to control the device 2000, execute software programs, and process data of the software programs. The device 2000 may further include a communication unit 2005 to enable input (reception) and output (transmission) of signals.
For example, the device 2000 may be a chip and the communication unit 2005 may be an input and/or output circuit of the chip, or the communication unit 2005 may be a communication interface of the chip, which may be a component of a terminal device or other electronic devices.
For another example, the device 2000 may be a terminal device, and the communication unit 2005 may be a transceiver of the terminal device, or the communication unit 2005 may be a transceiver circuit of the terminal device.
The apparatus 2000 may comprise one or more memories 2002 having stored thereon programs 2004, the programs 2004 being executable by the processor 2001 to generate instructions 2003, such that the processor 2001 performs the methods described in the above method embodiments in accordance with the instructions 2003. Optionally, the memory 2002 may also have data stored therein. Alternatively, the processor 2001 may also read data (e.g., the first ciphertext and the second ciphertext) stored in the memory 2002, which may be stored at the same memory address as the program 2004, or which may be stored at a different memory address from the program 2004.
The processor 2001 and the memory 2002 may be provided separately or integrated together, for example, on a System On Chip (SOC) of the terminal device.
The present application also provides a computer program product which, when executed by the processor 2001, implements the method according to any of the method embodiments of the present application.
The computer program product may be stored in the memory 2002, for example, as a program 2004, and the program 2004 is finally converted into an executable object file capable of being executed by the processor 2001 through processes such as preprocessing, compiling, assembling, and linking.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a computer, implements the method of any of the method embodiments of the present application. The computer program may be a high-level language program or an executable object program.
The computer-readable storage medium is, for example, the memory 2002. The memory 2002 may be either volatile memory or nonvolatile memory, or the memory 2002 may include both volatile and nonvolatile memory. The non-volatile memory may be a read-only memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an electrically Erasable EPROM (EEPROM), or a flash memory. Volatile memory can be Random Access Memory (RAM), which acts as external cache memory. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), double data rate SDRAM, enhanced SDRAM, SLDRAM, Synchronous Link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes and the generated technical effects of the above-described apparatuses and devices may refer to the corresponding processes and technical effects in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, the disclosed system, apparatus and method can be implemented in other ways. For example, some features of the method embodiments described above may be omitted, or not performed. The above-described embodiments of the apparatus are merely exemplary, the division of the unit is only one logical function division, and there may be other division ways in actual implementation, and a plurality of units or components may be combined or integrated into another system. In addition, the coupling between the units or the coupling between the components may be direct coupling or indirect coupling, and the coupling includes electrical, mechanical or other connections.
It should be understood that, in the various embodiments of the present application, the sequence numbers of the processes do not mean the execution sequence, and the execution sequence of the processes should be determined by the functions and the inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Additionally, the terms "system" and "network" are often used interchangeably herein. The term "and/or" herein is merely an association relationship describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
In short, the above description is only a preferred embodiment of the present disclosure, and is not intended to limit the scope of the present disclosure. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.