The invention discloses a method and a device for verifying the integrity of security critical data of a program in the process of running. The method comprises the following steps: 1) indicating a security critical variable in the program, generating a security critical
data set in the process of compiling, dividing a
virtual address space of the program into a
protected area and a non-
protected area in the process of loading the program, loading the security critical
data set to the
protected area, and constructing an integrity
verification tree for a virtual page of the protected area of the program; and 2) in the process of writing program data into a memory, updating a root
verification value; and in the process of reading program data from the memory, generating a new root
verification value, comparing the new root verification value with the original root verification value, if the two are equal, determining that the security critical
data set is not tampered, otherwise, determining that the security critical data set is tampered. The device comprises a
data integrity verification circuit, a root verification value storage module and a
comparator. The method and the device disclosed by the invention have the advantages of high safety performance, strong
attack prevention performance, small calculated amount, and less occupied storage space.