Disk encryption method and device, electronic equipment and storage medium
By verifying the startup image after detecting the power-on event in an embedded device, obtaining the encryption status and automatically performing encryption operations, the problem that traditional technology cannot automatically implement disk encryption is solved, and a unique encryption key management and compatible service is realized Functions to improve the safety and reliability of the equipment.
Patent Information
- Application Number
- CN202410946418.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-11-12
AI Technical Summary
Traditional disk encryption technology cannot automatically implement disk encryption in the production line generation environment of embedded devices on the vehicle and roadsides, cannot generate a unique encryption key, and cannot be compatible with the device's own business functions such as OTA upgrade and A/B partition support. .
After detecting the device power-on event, the general boot loader image and kernel image are verified step by step, and the kernel auxiliary system image is entered to obtain the disk encryption switch status and encryption status. Based on these states, encryption or decryption operations are automatically performed, including generation and management, Encrypt the key, ensuring that the device does not require manual intervention when booting.
Implement automated disk encryption in embedded devices on the vehicle and roadside, ensuring the uniqueness and security of the encryption key, compatible with the service functions of the equipment, improving the automation and security of the encryption process, and supporting A/B partitions Updates and OTA upgrades.
Smart Images

Figure CN118940326A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a disk encryption method, device, electronic equipment and storage medium. Background Art
[0002] In Linux systems, although disk encryption technology is relatively mature, the usage scenarios and business requirements of vehicle-side and roadside embedded devices are quite different from those of traditional PCs. For example, traditional disk encryption technology usually requires complex manual configuration when it is enabled. However, manual configuration is not feasible for mass-produced vehicle-side and roadside embedded devices. Enabling disk encryption needs to be implemented in an automated manner in the production line generation environment, which requires consideration of encryption key generation technology, how to securely generate device-unique encryption keys, and how to manage and securely store keys. At the same time, it is also necessary to take into account the business functions of the vehicle-side and roadside embedded devices themselves, such as OTA upgrades and A / B partition support. These new requirements cannot be directly met by traditional disk encryption technology solutions. Summary of the invention
[0003] In view of this, the embodiments of the present invention provide a disk encryption method, device, electronic device and storage medium to solve the problem that traditional disk encryption technology solutions cannot directly meet the new requirements of vehicle-side and roadside embedded devices in the production line generation environment to automatically implement disk encryption, generate unique encryption keys, manage and securely store keys, and be compatible with the device's own business functions.
[0004] In a first aspect, an embodiment of the present invention provides a disk encryption method, the method comprising:
[0005] After detecting a power-on event on the device, the universal boot loader image and the kernel image are verified step by step;
[0006] If the universal loader image and the kernel image are verified, the kernel auxiliary system image is entered, and the switch state of the disk encryption switch in the device is obtained in the kernel auxiliary system image, and the disk encryption state is obtained from the boot partition;
[0007] A corresponding encryption operation is performed on the disk based on the switch state and the disk encryption state.
[0008] Further, performing a corresponding encryption operation on the disk based on the switch state and the disk encryption state includes:
[0009] If the switch state is enabled and the disk encryption state is encrypted, obtaining a disk encryption key;
[0010] For each encrypted partition that needs to be mounted, create a corresponding encrypted logical device using the disk encryption key, and mount the encrypted logical device to the corresponding partition;
[0011] After determining that the encryption logic device is mounted, an initialization script is executed in the mounted partition to continue starting the device.
[0012] Further, performing a corresponding encryption operation on the disk based on the switch state and the disk encryption state includes:
[0013] If the switch state is the start state, and the disk encryption state is unencrypted, obtaining the target encryption key of the disk;
[0014] Using the target encryption key, create encryption logical devices of all partitions that need to be encrypted, wherein the logical devices correspond one-to-one to blocks of the plaintext partitions;
[0015] Read the data in the plaintext partition, and write the read data into the corresponding encryption logic device, wherein when the read data is written into the encryption logic device, the kernel will first encrypt the IO request generated by the data by block, and then forward the IO request to the plaintext partition for writing, thereby realizing the operation of encrypting the data of the plaintext partition;
[0016] Repeat the above steps for all partitions that need to be encrypted.
[0017] Further, obtaining the target encryption key of the disk includes:
[0018] Generate a black key and a disk encryption key, wherein the black key is used to protect the security of the disk encryption key;
[0019] The disk encryption key is encrypted using the black key to obtain the target encryption key.
[0020] Further, performing a corresponding encryption operation on the disk based on the switch state and the disk encryption state includes:
[0021] If the switch state is disabled and the disk encryption state is encrypted, obtaining a target encryption key of the disk;
[0022] Decrypting the target encryption key to obtain a decryption key for mounting the encrypted partition, and determining the partition to be mounted;
[0023] The partition to be mounted is mounted using the decryption key, and an initialization script is executed in the partition to continue the startup of the device.
[0024] Further, performing a corresponding encryption operation on the disk based on the switch state and the disk encryption state includes:
[0025] If the switch state is disabled and the disk encryption state is unencrypted, determining a partition to be mounted;
[0026] The partition to be mounted is mounted, and the initialization script is executed in the partition to continue to start the device.
[0027] Furthermore, before entering the kernel-assisted system image, the method further includes:
[0028] The auxiliary system image is packaged and compiled into the kernel image, wherein after the kernel image is successfully loaded, the control right is transferred to the auxiliary system.
[0029] In a second aspect, an embodiment of the present invention provides a disk encryption device, characterized in that the device comprises:
[0030] The signature verification module is used to verify the signature of the universal boot loader image and the kernel image step by step after detecting that the device generates a power-on event;
[0031] An encryption and decryption status acquisition module, used for entering the kernel auxiliary system image if the universal loader image and the kernel image are verified, and obtaining the switch status of the disk encryption switch in the device in the kernel auxiliary system image, and obtaining the disk encryption status from the boot partition;
[0032] An execution module is used to perform a corresponding encryption operation on the disk based on the switch state and the disk encryption state.
[0033] In a third aspect, an embodiment of the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, computer instructions being stored in the memory, and the processor executing the method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0034] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method of the first aspect or any corresponding embodiment thereof.
[0035] After detecting that the device has generated a power-on event, this application verifies the universal boot loader image and the kernel image step by step, ensuring that the device starts security verification when it is powered on. If the universal loader image and the kernel image are verified, the kernel auxiliary system image is entered, and the switch status of the disk encryption switch in the device is obtained in the kernel auxiliary system image, and the disk encryption status is obtained from the boot partition, so that the device can automatically obtain the switch status and encryption status of the disk encryption without manual intervention, meeting the requirements of vehicle-side and roadside embedded devices to automatically implement disk encryption in the production line generation environment. Then, according to the status of the disk encryption switch and the encryption status of the current disk, the corresponding encryption operation is automatically performed, including encryption, decryption or no operation. It solves the problem of manual configuration required in traditional solutions and makes the encryption process more automated. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 is a flowchart of a disk encryption method according to some embodiments of the present invention;
[0038] Figure 2 is a schematic diagram of system startup according to some embodiments of the present invention;
[0039] Figure 3 is a complete flowchart of a disk encryption method according to some embodiments of the present invention;
[0040] Figure 4 is a structural block diagram of a disk encryption device according to an embodiment of the present invention;
[0041] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0043] According to an embodiment of the present invention, a disk encryption method, device, electronic device and storage medium are provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0044] In this embodiment, a disk encryption method is provided, which can be used in the above-mentioned mobile terminals, such as mobile phones, tablet computers, etc. (the execution subject is described in combination with actual conditions). Figure 1 is a flow chart of a disk encryption method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0045] Step S11, after detecting that a power-on event occurs in the device, the signatures of the universal boot loader image and the kernel image are verified step by step.
[0046] In this application example, in an embedded Linux device with full disk encryption enabled, the universal boot loader image (uboot image) and the kernel image (kernel image) are verified step by step, following the steps below:
[0047] The device detects a power-on event and triggers the boot process. Uboot image verification: The device reads the public key hash or other verification information solidified in the chip to verify the uboot image. Use a hardware security module or similar mechanism to perform verification operations to ensure the integrity and authenticity of the uboot image. Kernel image verification: After uboot is started, the kernel image is verified again through a similar security mechanism. The verification process involves checking the digital signature, hash value, etc. of the kernel image. If any level of verification fails, the device takes corresponding security measures, such as stopping the boot, issuing an alarm, etc. This helps prevent unauthorized modifications or the loading of malware. Successful startup: If both levels of verification are successful, the device continues the normal boot process. Uboot loads and starts the kernel, and the operating system begins to run.
[0048] Step S12: If the universal loader image and the kernel image are verified, the kernel auxiliary system image is entered, and the switch state of the disk encryption switch in the device is obtained in the kernel auxiliary system image, and the disk encryption state is obtained from the boot partition.
[0049] In an embodiment of the present application, before entering the kernel auxiliary system image, the method also includes: compiling the auxiliary system image into the kernel image, completing the auxiliary system loading after the kernel image is loaded, and automatically switching to the auxiliary system for execution after the kernel is executed to transfer the control right to the auxiliary system image, and the auxiliary system image performs disk encryption. That is, the auxiliary system image is packaged and compiled, and then integrated into the kernel image. When the kernel image is loaded, the auxiliary system will also complete the loading. After the kernel is executed, it will automatically switch to the auxiliary system for execution, so that the control right is transferred to the auxiliary system image, and then the auxiliary system image will perform the disk encryption operation.
[0050] Specifically, the file system of the partition where the kernel image is located needs to be recognized by uboot. The common boot partition file system is fat32. The auxiliary system image is packaged into the kernel image. Uboot loads the kernel into the memory through initial configuration. By modifying the uboot configuration, the rootfs needs to be mounted to / dev / ram0. After the kernel is started, it can be automatically transferred to the temporary auxiliary system in the memory for execution. Using the mechanism provided by the system, create a virtual device file (such as / dev / ram0), which will be used to mount the auxiliary system image. Use the file system driver to mount the auxiliary system image on the virtual device file. This will make the auxiliary system image an accessible file system in the system. Once the auxiliary system image is mounted, the system can transfer control to the image. This is usually achieved by executing a specific startup script or entry point to enter the execution environment of the auxiliary system.
[0051] It should be noted that if Figure 2 As shown in the figure, in an embedded Linux device with full disk encryption enabled, the boot process is complicated. Since the rootfs partition is encrypted, the kernel image cannot directly load init in the rootfs, so an intermediate transition system is required. After the actual kernel is started, it will first transfer to the auxiliary system to perform the key functions of disk encryption. The auxiliary system image generally contains information such as the decryption software required to decrypt the rootfs. After the kernel is loaded, the auxiliary system image will be mounted to the / dev / ram0 virtual device file, and then transferred to the auxiliary system image for execution. The advantage of this is that after the kernel is started, the key functions in the auxiliary system are first executed to ensure the smooth progress of disk encryption. When executing the key functions of disk encryption, the auxiliary system will use the interfaces and resources provided by the kernel to complete the work. Specifically, the auxiliary system will read the encrypted data in the disk and use the key to perform the decryption operation. The decrypted data will be written to the memory for subsequent system initialization and boot process.
[0052] Step S13: performing corresponding encryption operations on the disk based on the switch state and the disk encryption state.
[0053] In an embodiment of the present application, corresponding encryption operations are performed on the disk based on the switch state and the disk encryption state, including: if the switch state is enabled and the disk encryption state is encrypted, the disk encryption key is obtained; for each encrypted partition that needs to be mounted, a corresponding encryption logical device is created using the disk encryption key, and the encryption logical device is mounted to the corresponding partition; after determining that the encryption logical device is mounted, an initialization script is executed in the mounted partition to continue the startup of the device.
[0054] Specifically, store the disk encryption key in the device configuration. Read the encryption key from the key repository or other secure location. Verify the integrity and correctness of the key. For each encrypted partition that needs to be mounted, create an encryption logical device using the obtained disk encryption key. This can be achieved using the encryption device creation tool provided by the operating system or the relevant encryption library. Assign a unique encryption logical device identifier to each partition. Use the file system mount command of the operating system to mount the encryption logical device to the corresponding partition. Map the encrypted partition to the specified mount point for subsequent access. Ensure that the mount operation is successful and verify the accessibility of the file system. Determine the location of the initialization script in the mounted partition. The initialization script can be placed in a specific directory of the partition. Execute the initialization script to start the further initialization and startup process of the device. The initialization script can perform various operations, such as starting services, loading configuration files, and performing system settings.
[0055] As an example, when the device boots, read the switch status and disk encryption status. If the switch status is enabled and the disk encryption status is encrypted: Get the disk encryption key from secure storage. For each encrypted partition that needs to be mounted: Create an encrypted logical device using the key. Mount the encrypted logical device to the corresponding partition. Confirm that all encrypted logical devices are mounted successfully. Find and execute the initialization script in the mounted partition. Continue the device boot process and perform other necessary initialization and startup tasks.
[0056] In an embodiment of the present application, a corresponding encryption operation is performed on the disk based on the switch state and the disk encryption state, including: if the switch state is the start state and the disk encryption state is unencrypted, then the target encryption key of the disk is obtained; the target encryption key is used to create encryption logic devices for all partitions that need to be encrypted, wherein the logic device corresponds to the block of the plaintext partition one by one; the data in the plaintext partition is read, and the read data is written into the corresponding encryption logic device, wherein when the read data is written into the encryption logic device, the kernel will first encrypt the IO request generated by the data by block, and then forward the IO request to the plaintext partition for writing, so as to realize the operation of encrypting the data of the plaintext partition; for all partitions that need to be encrypted, the above steps are repeated to perform encryption processing. Among them, obtaining the target encryption key of the disk includes: generating a black key and a disk encryption key, wherein the black key is used to protect the security of the disk encryption key; encrypting the disk encryption key using the black key to obtain the target encryption key.
[0057] Specifically, if the switch state is the start state and the disk encryption state is unencrypted, a black key and a disk encryption key are generated. The black key is a security key used to protect the disk encryption key. The security key function supported by the SoC must be used. The key is strongly associated with the SoC and can only correctly decrypt data in the current device. The disk encryption key is encrypted using the black key to obtain the target encryption key. Ensure the security of the disk encryption key. Then use the target encryption key to create the corresponding encryption logical device. The logical device corresponds to the blocks of the plaintext partition one by one, which means that the data of each logical device comes from the plaintext partition. The difference is that the data of the logical partition will be encrypted and decrypted by the kernel. Read the data in the plaintext partition, and its data is in an encrypted state. The encryption logical device will encrypt the data and write the encrypted data to the corresponding position of the corresponding plaintext partition. Repeat the above steps for all partitions that need to be encrypted. Until all plaintext partitions are encrypted. After the encryption process is completed, perform necessary cleanup and save operations.
[0058] It should be noted that the black key is an additional key generated to protect the security of the disk encryption key. It can be generated by a random number generator or other secure key generation algorithm, which depends on the internal implementation of the SoC manufacturer. Disk encryption key: The disk encryption key is the key used to encrypt and decrypt the disk. Use the black key as the encryption key to encrypt the disk encryption key. Symmetric encryption algorithms such as AES can be used for encryption. The encrypted disk encryption key is the target encryption key.
[0059] The security of the disk encryption key can be increased by generating a black key and using it to encrypt the disk encryption key. Even if an attacker obtains the disk encryption key, they cannot decrypt the disk data due to the lack of the black key. This dual key mechanism provides a higher level of protection, ensuring that only the correct black key and disk encryption key in the SoC device to which it is bound can decrypt and access the data on the disk. At the same time, the black key needs to be properly kept and managed to ensure the security of the entire encryption system. The specific implementation details may vary depending on the encryption technology and security strategy used.
[0060] In an embodiment of the present application, corresponding encryption operations are performed on the disk based on the switch state and the disk encryption state, including: if the switch state is disabled and the disk encryption state is encrypted, the target encryption key of the disk is obtained; the target encryption key is decrypted to obtain a decryption key for mounting the encrypted partition, and the partition that needs to be mounted is determined; the partition that needs to be mounted is mounted using the decryption key, and the initialization script is executed in the partition to continue the startup of the device.
[0061] Specifically, if the switch state is disabled and the disk encryption state is encrypted, obtain the target encryption key of the disk from the secure storage. Use the corresponding decryption algorithm and key to decrypt the target encryption key to obtain the decryption key for mounting the encrypted partition. Determine the encrypted partition to be mounted according to the device configuration or user specification. Use the decryption key to mount the partition to be mounted, and mount the encrypted partition to the file system. Execute the initialization script in the mounted partition, for example: including restoring the system configuration, loading necessary drivers, or performing other startup-related tasks. After completing the initialization script, continue the normal startup process of the device.
[0062] In an embodiment of the present application, corresponding encryption operations are performed on the disk based on the switch state and the disk encryption state, including: if the switch state is disabled and the disk encryption state is unencrypted, determining the partition that needs to be mounted; mounting the partition that needs to be mounted, and executing the initialization script in the partition to continue the startup of the device.
[0063] Specifically, if the switch status is disabled and the disk encryption status is unencrypted, determine the partition that needs to be mounted based on the device configuration or user specification. Use the appropriate file system driver or tool to mount the partition that needs to be mounted. This will make the partition available in the operating system and access the files and data therein. Execute the initialization script in the mounted partition. This script can contain various operations required for device startup, such as loading drivers, setting environment variables, starting services, and so on. The initialization script is usually written according to the specific requirements of the device and can be found in a specific location of the partition (such as ` / etc / init.d` or a custom script directory). After completing the initialization script, the device startup process will continue. There may be other subsequent startup tasks, startup of system services, and full initialization of the device.
[0064] After detecting that the device has generated a power-on event, this application verifies the universal boot loader image and the kernel image step by step, ensuring that the device starts security verification when it is powered on. If the universal loader image and the kernel image are verified, the kernel auxiliary system image is entered, and the switch status of the disk encryption switch in the device is obtained in the kernel auxiliary system image, and the disk encryption status is obtained from the boot partition, so that the device can automatically obtain the switch status and encryption status of the disk encryption without manual intervention, meeting the requirements of vehicle-side and roadside embedded devices to automatically implement disk encryption in the production line generation environment. Then, according to the status of the disk encryption switch and the encryption status of the current disk, the corresponding encryption operation is automatically performed, including encryption, decryption or no operation. It solves the problem of manual configuration required in traditional solutions and makes the encryption process more automated.
[0065] like Figure 3 As shown in the figure, after entering the auxiliary system image, the program first checks the current disk encryption switch status and disk encryption status. According to the activation of the encryption switch and the encryption status of the disk, corresponding processing is performed. If the encryption switch is enabled and the disk is not encrypted, the encryption process will be called; if the switch is not enabled, or the disk is encrypted, the AB partition startup judgment will be performed directly. The AB partition startup judgment is performed for both encrypted partitions and non-encrypted partitions. Execute the init script in rootfs to continue the system startup process.
[0066] Next is the encryption and decryption process: Generate the black key (BlackKey) and the disk encryption key (DiskEncryptionKey). Use the black key that is strongly associated with the device to protect the disk encryption key. Get the encrypted disk encryption key and use the black key to decrypt it to get the real disk encryption key. Use the disk encryption key to create all logical devices for the partitions that need to be encrypted. Read the data in the partition and write it to the corresponding encrypted logical device file. When writing data, the kernel will automatically encrypt the data. Repeat this operation to encrypt all partitions that need to be encrypted. Similar to the encryption process, just perform the decryption process and use the same key to decrypt the data. Get the disk encryption key. Create encrypted logical devices for all encrypted partitions that need to be mounted. The read and write operations of the encrypted logical device are consistent with the plaintext virtual file block device. At startup, directly mount the encrypted logical device to the corresponding partition, for example, mount the encrypted rootfs to the location of the root partition. Execute the init script and continue the system startup process. In this way, the data security is guaranteed through the encryption process, and the system startup and operation are achieved through the decryption and mounting processes. In the specific implementation, it is necessary to make appropriate adjustments and optimizations according to the characteristics of the operating system and the requirements of the encryption algorithm. At the same time, it is necessary to ensure the management and protection of keys to prevent key leakage from causing data security problems.
[0067] This solution has the following beneficial effects:
[0068] The disk encryption solution is seamlessly integrated with the secure boot function to ensure that after the device is powered on, it is verified step by step, starting from the hardware security anchor as the root of trust, all the way to the kernel, and finally decrypting the real root file system (rootfs). This integration can prevent firmware leaks, protect binary programs and intellectual property, while preventing data leakage and unauthorized access, and improving the overall security of the device. The secure upgrade function can be combined with disk encryption to ensure the security and integrity of the device during the upgrade process.
[0069] This solution supports the use of vehicle-side and roadside embedded devices, including A / B partition updates and OTA upgrades. A / B partition updates allow devices to be updated on different partitions without affecting the currently running system, improving system reliability and maintainability. OTA upgrades can be performed over wireless networks, facilitating remote management and updates of devices while ensuring security during the upgrade process.
[0070] The disk encryption solution is based on block-layer encryption technology, which is not sensitive to upper-layer applications and does not require additional integration work by the business group. This enables the product development team to advance their work more easily, reducing development costs and time. Block-layer encryption technology can encrypt at the disk level, without the need to encrypt each file separately, improving encryption efficiency and performance.
[0071] By saving key files based on the hardware security features of the SoC (system on chip), the device's disk encryption key does not require additional hardware for storage and management. This reduces hardware cost and complexity while ensuring the security of the key. The key for each device is unique, reducing the risk of key leakage.
[0072] You can also flexibly specify encryption and decryption algorithms and select them according to specific security needs and performance requirements. It has high encryption and decryption performance and I / O performance, and has little impact on the overall system performance. The actual test results on the IMX8 platform show that the encryption and decryption speed of a single-core CPU can reach more than 200MB per second, and the CPU increases by less than 5% in actual operation. The actual startup time of a device with full disk encryption enabled increases by less than 2 seconds. In special scenarios, the encryption and decryption algorithms and key lengths can be customized to better balance security and performance.
[0073] Based on block layer encryption technology, it effectively prevents file system damage caused by data loss or asynchrony due to power outages. After a one-week long random power outage stress test, the device disk runs well, there is no file system damage and other problems, and the device can continue to operate normally. This ensures the stability and reliability of the device in harsh environments.
[0074] In this embodiment, a disk encryption device is also provided, which is used to implement the above embodiments and preferred implementations, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0075] This embodiment provides a disk encryption device, such as Figure 4 As shown, including:
[0076] The signature verification module 41 is used to verify the signatures of the universal boot loader image and the kernel image step by step after detecting that the device generates a power-on event;
[0077] The encryption and decryption status acquisition module 42 is used to enter the kernel auxiliary system image if the universal loader image and the kernel image are verified, and obtain the switch status of the disk encryption switch in the device in the kernel auxiliary system image, and obtain the disk encryption status from the boot partition;
[0078] The execution module 43 is used to perform corresponding encryption operations on the disk based on the switch state and the disk encryption state.
[0079] In an embodiment of the present application, the execution module 43 is used to obtain the disk encryption key if the switch state is enabled and the disk encryption state is encrypted; for each encrypted partition that needs to be mounted, a corresponding encryption logical device is created using the disk encryption key, and the encryption logical device is mounted to the corresponding partition; after determining that the encryption logical device is mounted, the initialization script is executed in the mounted partition to continue the startup of the device.
[0080] In the embodiment of the present application, the execution module 43 is used to obtain the target encryption key of the disk if the switch state is the start state and the disk encryption state is unencrypted; use the target encryption key to create encryption logic devices for all partitions that need to be encrypted, wherein the logical devices correspond one-to-one to the blocks of the plaintext partitions; read the data in the plaintext partition, write the read data to the corresponding encryption logic device, encrypt the data in the encryption logic device, and write the encrypted data to the corresponding plaintext partition; for all partitions that need to be encrypted, repeat the above steps to perform encryption processing.
[0081] In an embodiment of the present application, the execution module 43 is used to generate a black key and a disk encryption key, wherein the black key is used to protect the security of the disk encryption key; the disk encryption key is encrypted using the black key to obtain a target encryption key.
[0082] In an embodiment of the present application, the execution module 43 is used to obtain the target encryption key of the disk if the switch state is disabled and the disk encryption state is encrypted; decrypt the target encryption key to obtain the decryption key for mounting the encrypted partition, and determine the partition that needs to be mounted; use the decryption key to mount the partition that needs to be mounted, and execute the initialization script in the partition to continue to execute the device startup.
[0083] In an embodiment of the present application, the execution module 43 is used to determine the partition that needs to be mounted if the switch state is disabled and the disk encryption state is unencrypted; mount the partition that needs to be mounted, and execute the initialization script in the partition to continue the startup of the device.
[0084] In an embodiment of the present application, the device also includes: a processing module, which is used to use a file system driver to mount the auxiliary system image to a virtual device file to transfer control to the auxiliary system image, and the auxiliary system image performs disk encryption.
[0085] See also Figure 5 , Figure 5is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0086] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0087] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0088] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of a computer device based on the presentation of a small program landing page, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0089] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0090] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0091] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0092] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A disk encryption method, characterized in that: The method comprises: After detecting a power-on event on the device, the universal boot loader image and the kernel image are verified and signed step by step; If the universal loader image and the kernel image are verified, the kernel auxiliary system image is entered, and the switch state of the disk encryption switch in the device is obtained in the kernel auxiliary system image, and the disk encryption state is obtained from the boot partition; A corresponding encryption operation is performed on the disk based on the switch state and the disk encryption state.
2. The method according to claim 1, characterized in that The performing a corresponding encryption operation on the disk based on the switch state and the disk encryption state includes: If the switch state is enabled and the disk encryption state is encrypted, obtaining a disk encryption key; For each encrypted partition that needs to be mounted, create a corresponding encrypted logical device using the disk encryption key, and mount the encrypted logical device to the corresponding partition; After determining that the encryption logic device is mounted, an initialization script is executed in the mounted partition to continue starting the device.
3. The method according to claim 1, characterized in that The performing a corresponding encryption operation on the disk based on the switch state and the disk encryption state includes: If the switch state is the start state, and the disk encryption state is unencrypted, obtaining the target encryption key of the disk; Using the target encryption key, create encryption logical devices of all partitions that need to be encrypted, wherein the logical devices correspond one-to-one to blocks of the plaintext partitions; Read the data in the plaintext partition, and write the read data into the corresponding encryption logic device, wherein when the read data is written into the encryption logic device, the kernel will first encrypt the IO request generated by the data by block, and then forward the IO request to the plaintext partition for writing, thereby realizing the operation of encrypting the data of the plaintext partition; Repeat the above steps for all partitions that need to be encrypted.
4. The method according to claim 3, characterized in that The obtaining of the target encryption key of the disk comprises: Generate a black key and a disk encryption key, wherein the black key is used to protect the security of the disk encryption key; The disk encryption key is encrypted using the black key to obtain the target encryption key.
5. The method according to claim 1, characterized in that The performing a corresponding encryption operation on the disk based on the switch state and the disk encryption state includes: If the switch state is disabled and the disk encryption state is encrypted, obtaining a target encryption key of the disk; Decrypting the target encryption key to obtain a decryption key for mounting the encrypted partition, and determining the partition to be mounted; The partition to be mounted is mounted using the decryption key, and an initialization script is executed in the partition to continue the startup of the device.
6. The method according to claim 1, characterized in that The performing a corresponding encryption operation on the disk based on the switch state and the disk encryption state includes: If the switch state is disabled and the disk encryption state is unencrypted, determining a partition to be mounted; The partition to be mounted is mounted, and the initialization script is executed in the partition to continue to start the device.
7. The method according to claim 1, characterized in that Before entering the kernel-assisted system image, the method further includes: The auxiliary system image is packaged and compiled into the kernel image, wherein after the kernel image is successfully loaded, the control right is transferred to the auxiliary system.
8. A disk encryption device, characterized in that: The device comprises: The signature verification module is used to verify the signature of the universal boot loader image and the kernel image step by step after detecting that the device generates a power-on event; An encryption and decryption status acquisition module, used for entering the kernel auxiliary system image if the universal loader image and the kernel image are verified, and obtaining the switch status of the disk encryption switch in the device in the kernel auxiliary system image, and obtaining the disk encryption status from the boot partition; An execution module is used to perform a corresponding encryption operation on the disk based on the switch state and the disk encryption state.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.
