A method for executing a binary code of a secure function with a microprocessor, said method comprising the following steps:
- a) storing, in a memory, a line of code, said line of code containing a cryptogram of the code and a first integrity tag allowing the integrity of the line of code to be verified,
- b) obtaining, with the microprocessor, a first pointer containing the address at which said line of code is stored, then
- c) executing, with the microprocessor, an instruction to read said line of code using the first pointer and, to said end, executing the following operations with the microprocessor:
- c1) loading the first pointer into a register of the microprocessor,
- c2) loading the line of code stored at the address contained in the first pointer, then
- c3) verifying the integrity of the loaded line of code, said verification comprising constructing a second integrity tag from the cryptogram contained in the loaded line of code, then comparing said second integrity tag to the first integrity tag contained in the loaded line of code, then
- c4) when the second integrity tag does not correspond to the first integrity tag, i.e. when the verification of the integrity of the loaded line of code fails, the microprocessor systematically triggers the flagging of an execution fault, and
- c5) when the second integrity tag corresponds to the first integrity tag, i.e. when the loaded line of code is of integrity, the cryptogram of the code is decrypted to obtain a cleartext code and the triggering of an execution fault is inhibited;
- wherein:
- obtaining the first pointer comprises obtaining a first pointer containing:
- a first range of bits containing the address of the line of code, and
- a second, different range of bits containing an identifier of the first pointer, the identifier of said first pointer allowing said first pointer to be uniquely identified among a set that contains a plurality of different pointers employed during the same execution of the binary code by the microprocessor,
- storing the line of code comprises storing a line of code wherein the first integrity tag is constructed or encrypted using the identifier of the first pointer,
- during the loading of the line of code, it is the address contained in the first range of bits of the loaded first pointer that is used and the identifier of the first pointer contained in the second range of bits is not used,
- during the verification of the integrity of the loaded line of code, the second integrity tag is constructed, in addition, using the identifier of the first pointer contained in the second range of bits of the loaded first pointer, so that if a second pointer, different from the first pointer, is used instead of the first pointer to read or write said line of code, the verification of the integrity of the line of code fails.