Method of speeding up secure boot process and electronic device using the same
A method of speeding up a secure boot process and an electronic device using the method. The method includes the following. Whether a storage medium stores a pre-stored hash value corresponding to an image file for the secure boot process is determined. A hash value of the image file is calculated to determine whether the hash value matches the pre-stored hash value in response to the storage medium storing the pre-stored hash value. Firmware in the image file is executed to boot up the electronic device in response to the hash value matching the pre-stored hash value.
1 . An electronic device speeding up a secure boot process, the electronic device comprising:
a storage medium storing a bootloader; and
a processor coupled to the storage medium and accessing and executing the bootloader, wherein the bootloader is configured to:
determine whether the storage medium stores a pre-stored hash value corresponding to an image file for the secure boot process;
calculate a hash value of the image file to determine whether the image hash value matches the pre-stored hash value in response to the storage medium storing the pre-stored hash value; and
execute firmware in the image file to boot up the electronic device in response to the image hash value matching the pre-stored hash value,
wherein the bootloader is further configured to:
determine whether the secure boot process is initiated based on a cold reset command or a warm reset command in response to the image hash value not matching the pre-stored hash value;
obtain the firmware and a FW hash value from the image file in a buffer, and calculate a hash value of the firmware;
in response to the calculated firmware hash value matching the FW hash value, determine the calculated firmware hash value passes verification;
in response to the calculated firmware hash value not matching the FW hash value, determine the secure boot process fails, cease the secure boot process, and output an alert through a transceiver; and
verify the image file in response to the secure boot process being initiated based on the cold reset command.
2 . The electronic device of claim 1 , wherein the bootloader is further configured to:
verify the image file in response to the image hash value not matching the pre-stored hash value;
calculate the hash value of the image file in response to the image file passing verification; and
store the hash value calculated in response as the pre-stored hash value in the storage medium.
3 . The electronic device of claim 1 , wherein the bootloader is further configured to:
delete the pre-stored hash value from the storage medium in response to the image hash value not matching the pre-stored hash value.
4 . The electronic device of claim 1 , wherein the bootloader is further configured to:
determine that the secure boot process fails in response to the secure boot process being initiated based on the warm reset command.
5 . The electronic device of claim 1 , wherein the bootloader is further configured to:
determine whether the secure boot process is initiated based on the cold reset command or the warm reset command in response to the storage medium not storing the pre-stored hash value; and
verify the image file in response to the secure boot process being initiated based on the cold reset command.
6 . The electronic device of claim 5 , wherein the bootloader is further configured to:
determine that the secure boot process fails in response to the secure boot process being initiated based on the warm reset command.
7 . The electronic device of claim 1 , wherein the bootloader is further configured to:
verify a firmware public key in the image file; and
determine whether the storage medium stores the pre-stored hash value in response to the firmware public key passing verification.
8 . A method of speeding up a secure boot process, the method being applicable to an electronic device comprising a storage medium, and the method comprising:
determining whether the storage medium stores a pre-stored hash value corresponding to an image file for the secure boot process;
calculating a hash value of the image file to determine whether the image hash value matches the pre-stored hash value in response to the storage medium storing the pre-stored hash value;
executing firmware in the image file to boot up the electronic device in response to the image hash value matching the pre-stored hash value;
determining whether the secure boot process is initiated based on a cold reset command or a warm reset command in response to the image hash value not matching the pre-stored hash value;
obtaining the firmware and a FW hash value from the image file in a buffer, and calculate a hash value of the firmware;
in response to the calculated firmware hash value matching the FW hash value, determine the calculated firmware hash value passes verification;
in response to the calculated firmware hash value not matching the FW hash value, determine the secure boot process fails, cease the secure boot process, and output an alert through a transceiver; and
verifying the image file in response to the secure boot process being initiated based on the cold reset command.