METHOD FOR EXECUTING A MACHINE CODE BY A COMPUTER

The method enhances machine code execution by constructing and verifying signatures for each instruction, addressing vulnerabilities to fault injection attacks and ensuring the integrity and security of the execution process.

FR3139214B1Active Publication Date: 2024-11-22COMMISSARIAT A LENERGIE ATOMIQUE ET AUX ENERGIES ALTERNATIVES +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
FR2022008504
Authority / Receiving Office
FR · FR
Patent Type
Patents
Current Assignee / Owner
Filing Date
2022-08-24
Publication Date
2024-11-22
Estimated Expiration
2042-08-24

AI Technical Summary

Technical Problem

Existing methods for executing machine code are vulnerable to fault injection attacks, which can alter the integrity and security of the code, particularly by modifying instructions or causing unexpected behavior, and existing encryption techniques do not adequately protect against errors during decoding.

Method used

A method for executing machine code that includes constructing a signature for each instruction based on previous instructions, verifying the integrity of the code before decrypting the next instruction, and using a hardware processing chain with a signature constructor and verifier to ensure the integrity of the code, even in the presence of decoding errors.

Benefits of technology

The method effectively detects and prevents alterations in the machine code, ensuring the integrity and security of the execution process by triggering integrity defects and reducing unexpected behavior, even when the instruction set is not sparse.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000030_0000
    Figure 00000030_0000
  • Figure 00000030_0001
    Figure 00000030_0001
  • Figure 00000031_0000
    Figure 00000031_0000
Patent Text Reader

Abstract

Method for executing machine code by a computer. This method comprises: - the construction (162) of a signature for a current instruction: - from signals generated by a stage of a hardware processing chain, this stage being a decoder or a stage following the decoder in the hardware processing chain, and - from the previous signature constructed for a preceding instruction, then - the verification (163) of the integrity of the executed machine code by comparing (170) the signature constructed for the current instruction to a pre-recorded reference signature, then - only when the verification of the integrity of the current instruction is successful, the decryption (156) of a cryptogram of the next instruction using the signature constructed for the current instruction. Fig. 4
Need to check novelty before this filing date? Find Prior Art

Description

Title of the invention: METHOD OF EXECUTION FROM A MACHINE CODE TO A COMPUTER

[0001] The invention relates to a method for executing a machine code by a computer as well as the machine code executed by this method. The invention also relates to:

[0002] - an information recording medium and a computer for implementing it of this execution process, and

[0003] - a compiler to generate this machine code.

[0004] To obtain information about a machine code or to cause unexpected operation of the machine code, it is known to subject it to attacks known as "fault injection" or "fault attack" in English. These attacks consist of disrupting the operation of the computer during the execution of the machine code by various physical means such as modifications to the supply voltages, modifications to the clock signal, exposure of the computer to electromagnetic waves and others.

[0005] Using such disturbances, an attacker can alter the integrity of machine instructions or data to, for example, recover a secret key of a cryptographic system, bypass security mechanisms such as the verification of a PIN code during authentication or simply prevent the execution of a function essential for the security of a critical system.

[0006] A fault injection attack can cause an alteration of the operation of the computer, for example, by modifications of the instructions which are executed by the arithmetic and logic unit. For this, it is common for the injected faults to aim at disrupting the operation of the instruction decoder of the computer to produce faulty instructions.

[0007] When the disturbance of the decoder only prevents the execution of one or more of the instructions of the machine code or when the alteration has an effect on the processor equivalent to not executing the faulty instruction, this is called an instruction skip. When the disturbance of the decoder leads to the replacement of one or more of the instructions of the machine code by other instructions executable by the computer, this is called an instruction replacement.

[0008] When the decoder disturbance modifies a branch instruction, a control flow diversion effect is observed. The control flow corresponds to the execution path followed during the execution of the machine code. The control flow is classically represented in the form of a directed graph known as a control flow graph. The effect Control flow hijacking can be observed when a branch instruction is altered or when the condition involved in a conditional branch is changed or when the return address of a function is changed.

[0009] Such attacks are made easier if the machine code can be analyzed beforehand. Thus, to make these attacks more difficult, it has been proposed to encrypt the machine code instructions in order to make its analysis more complicated. An example of a method for executing encrypted machine code is described in the following article: M. Wemer, T. Unterluggauer, D. Schaenrath, and S. Mangard: “Sponge-Based Control-Flow Protection for loT Devices”, EuroS&P, 2018. Hereinafter, this article is referred to as “Werner2018”.

[0010] The method described in Werner2018 is particularly interesting because the cryptogram of each instruction is decrypted from an internal state of the computer which is updated according to the cryptogram of the previous decrypted instruction. Thus, the cryptogram of the current instruction to be executed can only be decrypted correctly if the cryptograms of all the previous instructions are intact, i.e. they have not been modified, for example, by fault injection. This is advantageous but does not protect against an attack which only causes an error when decoding an instruction. Indeed, in the latter case, since the decoding is carried out after the decryption of the instruction, the cryptogram of the instruction is not modified.To overcome this drawback, Werner2018 further suggests, without describing it in detail, building the internal state of the computer based on the signals generated by the instruction decoder when decoding the previous instruction. This ensures the integrity of the signals generated by the instruction decoder in addition to the integrity of its cryptogram.

[0011] More precisely, in Wemer2018, a faulty cryptogram of a current instruction li or an error introduced during the decoding of the instruction li, results in an incorrect decryption of the cryptogram Ii+1 * of the following instruction. Thus, the decryption of the cryptogram Ii+1* produces an erroneous instruction I'i+1 different from the expected instruction Ii+1. Since the signals generated by the decoder during the execution of the instruction I'i+1 are taken into account to update the state of the computer used to decrypt the cryptogram of the instruction Ii+2, from the instruction li, the computer generates only erroneous instructions. The first erroneous instruction l'i+n produced which does not belong to the instruction set of the computer, causes an execution fault which stops the execution of the machine code. In the case where the computer's instruction set is sparse, the index n of the instruction that causes the execution fault is small.On the other hand, if the computer's instruction set is not sparse, then the index n can be very large. which delays, or even makes impossible, the detection of the integrity defect. In addition, if the instruction I'i+1 belongs to the instruction set of the computer, this causes unexpected behavior of the computer since the executed instruction I'i+1 is different from the expected instruction Ii+1. Such unexpected behavior can compromise the security of the machine code.

[0012] The invention aims to improve the method described in Werner2018. In particular, the invention therefore aims to propose a method for executing a machine code which makes it possible to signal an alteration of an instruction, an instruction jump and an alteration of the operation of the instruction decoder of the computer without having the drawbacks of the method of Werner2018.

[0013] Its subject is therefore such a method for executing a machine code by a computer comprising a hardware instruction processing chain, this hardware processing chain comprising a succession of stages which process one after the other each instruction to be executed of the machine code, this succession of stages comprising at least the following stages: an instruction loader, a decoder and an arithmetic and logic unit, this method comprising the execution of the following steps for each cryptogram of an instruction of a sequence of consecutive instructions of the machine code:

[0014] - the loading, by the instruction loader, of the cryptogram of an instruction designated by an ordinal counter to obtain a loaded cryptogram, then

[0015] - decryption of the loaded cryptogram to obtain a decrypted instruction, Then

[0016] - decoding the decrypted instruction, by the decoder, to generate signals which configure the computer to execute the decrypted instruction, then,

[0017] - the execution, by the arithmetic and logic unit, of the decrypted instruction,

[0018] in which the method also comprises the following steps for at least one current instruction of the sequence of consecutive instructions:

[0019] - after the decoding operation of the current instruction and before decryption from the cryptogram of the next instruction in the sequence of consecutive instructions, the construction of a signature for the current instruction:

[0020] - from a set of signals generated by a stage of the succession of stages in response to the processing of this current instruction by this stage, this stage which generates this set of signals being the decoder or a stage following the decoder in the succession of stages, and

[0021] - from the previous signature constructed for the instruction preceding it in the sequence of consecutive instructions,

[0022] this signature for the current instruction thus varying as a function of the current instruction and as a function of all the instructions preceding the current instruction in the sequence of consecutive instructions, then

[0023] - verification of the integrity of the executed machine code by comparing the signature constructed for the current instruction to a pre-recorded reference signature, then

[0024] - only when the integrity check of the current instruction is successful, decrypting the cryptogram of the next instruction using the signature constructed for the current instruction.

[0025] Embodiments of this method may include one or more of the following features:

[0026] 1) the integrity verification step comprises:

[0027] - loading a cryptogram of the reference signature, then

[0028] - decryption of this cryptogram using one of the signatures constructed for one of the instructions in the instruction sequence.

[0029] 2)

[0030] - the cryptogram of the reference signature is loaded from the address contained in the ordinal counter after loading the cryptogram of the current instruction and before loading the cryptogram of the next instruction, and

[0031] - the cryptogram of the reference signature is decrypted using the signature constructed for the current instruction or for the instruction preceding this current instruction in the sequence of consecutive instructions.

[0032] 3) when constructing the signature for the current instruction, this signature is also constructed from a secret key pre-recorded in a computer memory.

[0033] 4) the stage that generates the set of signals used to construct the signature is the decoder.

[0034] 5) when constructing a signature for the current instruction, this signature is constructed from signals, generated by the decoder in response to the decoding of the current instruction, which vary depending on the opcode of the current instruction and depending on each operand of the current instruction.

[0035] 6) decryption of the cryptogram of each instruction using the signature constructed consists of carrying out an "EXCLUSIVE OR" between the bits of the instruction cryptogram and the bits of the signature constructed for the instruction which precedes this instruction in the sequence of consecutive instructions.

[0036] 7) when the signature constructed for the current instruction is different from the pre-recorded reference signature to which it is compared, the step of verification of the integrity of the current instruction continues with a step of reporting an integrity defect.

[0037] The invention also relates to a machine code capable of being executed by implementing the above execution method, this machine code comprising a cryptogram for each instruction of a sequence of consecutive instructions, in which

[0038] - each of these cryptograms is the cipher of a corresponding instruction of this sequence of consecutive instructions using a constructed signature:

[0039] - from the signals generated by a stage of the succession of stages in response to the decoding of this corresponding instruction by this stage, this stage which generates this set of signals being the decoder or a stage following the decoder in the succession of stages, and

[0040] - from the previous signature constructed for the instruction preceding it in the sequence of consecutive instructions,

[0041] this signature for the corresponding instruction thus varying as a function of the corresponding instruction and as a function of all the instructions preceding the corresponding instruction in the sequence of consecutive instructions, and

[0042] - the machine code also includes the pre-recorded reference signature at which the signature constructed for a current instruction is compared when executing this machine code by implementing the above method.

[0043] The invention also relates to an information recording medium readable by a microprocessor of a computer, this information recording medium containing the above machine code.

[0044] The invention also relates to a computer for implementing the above execution method, this computer comprising a hardware instruction processing chain, this hardware processing chain comprising a succession of stages which process one after the other each instruction to be executed from the machine code, this succession of stages comprising at least the following stages: an instruction loader, a decoder and an arithmetic and logic unit, this hardware processing chain being capable, for each cryptogram of an instruction of a sequence of consecutive instructions of a machine code, of executing the following operations:

[0045] - the loading, by the instruction loader, of the cryptogram of an instruction designated by an ordinal counter to obtain a loaded cryptogram, then

[0046] - decryption of the loaded cryptogram to obtain a decrypted instruction, Then

[0047] - decoding the decrypted instruction, by the decoder, to generate signals which configure the computer to execute the decrypted instruction, then,

[0048] - the execution, by the arithmetic and logic unit, of the decrypted instruction,

[0049] wherein the processing hardware chain is also configured to execute the following steps for at least one current instruction of the sequence of consecutive instructions:

[0050] - after the decoding operation of the current instruction and before decryption from the cryptogram of the next instruction in the sequence of consecutive instructions, the construction of a signature for the current instruction:

[0051] - from the signals generated by a stage of the succession of stages in response to the decoding of this current instruction by this stage, this stage which generates this set of signals being the decoder or a stage following the decoder in the succession of stages, and

[0052] - from the previous signature constructed for the instruction preceding it in the sequence of consecutive instructions,

[0053] this signature for the current instruction thus varying as a function of the current instruction and as a function of all the instructions preceding the current instruction in the sequence of consecutive instructions, then

[0054] - checking the integrity of the current instruction by comparing the signature constructed for the current instruction to a pre-recorded reference signature, then

[0055] - only when the integrity check of the current instruction is successful, decrypting the cryptogram of the next instruction using the signature constructed for the current instruction.

[0056] Finally, the invention also relates to a compiler capable of automatically transforming a source code of a computer program into a binary code comprising a machine code executable by a computer comprising a hardware instruction processing chain, this hardware processing chain comprising the following stages: an instruction loader, a decoder and an arithmetic and logic unit, this compiler being capable of automatically transforming the source code into a machine code conforming to the above machine code.

[0057] The invention will be better understood on reading the description which follows, given solely by way of non-limiting example and made with reference to the drawings in which:

[0058] - [Fig.l] is a schematic illustration of the architecture of a computer electronics capable of executing machine code;

[0059] - [Fig.2] is a schematic illustration of a compiler capable of generating the code machine executed by the calculator of [Fig.l];

[0060] - [Fig.3] is a flowchart of a method of compiling machine code to the compiler help of [Fig.2];

[0061] - [Fig.4] is a flowchart of a method of executing machine code using of the calculator of [Fig.l].

[0062] CHAPTER I: Notations and definitions

[0063] In these figures, the same references are used to designate the same elements. In the remainder of this description, the characteristics and functions well known to those skilled in the art are not described in detail.

[0064] In this description, the following definitions are adopted.

[0065] A “program” designates a set of one or more predetermined functions that one wishes to have executed by a computer.

[0066] A “source code” is a representation of the program in a computer language, not being directly executable by a computer and being intended to be transformed, by a compiler, into a machine code directly executable by the computer.

[0067] A program or code is said to be “directly executable” when it is capable of being executed by a computer without this computer first needing the program to be compiled by means of a compiler or to interpret it by means of an interpreter.

[0068] An “instruction” means a machine instruction executable by a computer. Such an instruction consists of:

[0069] - an opcode, or operation code, encoding the nature of the operation to be executed, and

[0070] - one or more operands defining the value(s) of the parameters of this operation.

[0071] The “value of an instruction” is a numerical value obtained, using a bijective function, from the succession of “0” and “1” which codes, in machine language, this instruction. This bijective function can be the identity function.

[0072] A "machine code" is a set of machine instructions. It is typically a file containing a succession of bits bearing the value "0" or "1", these bits coding the instructions to be executed by the microprocessor. The machine code is directly executable by the computer, that is to say without requiring prior compilation or interpretation. The machine code comprises a succession of instructions classified one after the other and which forms, in the machine code, an ordered sequence of instructions. The machine code begins with an initial instruction and ends with a final instruction. With respect to a given instruction li of the machine code, the instruction li-1 located on the side of the initial instruction is called the "previous instruction" and the instruction Ii+1 located on the side of the final instruction is called the "next instruction". The index "i" is the order number of the instruction li in the machine code.

[0073] A “binary code” is a file containing a succession of bits bearing the value “0” or “1”. These bits encode data and instructions to be executed by the microprocessor. Thus, the binary code includes at least one machine code and, in addition, generally, digital data processed by this machine code.

[0074] An “instruction stream” is a succession of instructions executed one after the other.

[0075] The notation "li*" designates the cryptogram of the value of a li instruction in clear text.

[0076] In this text, a “sequence of consecutive instructions” is a group of instructions machine code that are systematically executed one after the other.

[0077] A "branch instruction" is an instruction which, when executed by the computer, is capable of replacing the address contained in the ordinal counter with another address. The branch instruction therefore includes at least this other address as a parameter. It is recalled that the ordinal counter contains the address of the next instruction to be executed by the computer. In the absence of a branch instruction, each time an instruction is executed, the ordinal counter is incremented by the size of the instruction currently executed. In the absence of a branch instruction, the instructions are systematically executed sequentially one after the other in the order in which they are recorded in a main memory, that is to say in the order of their index "i".

[0078] We speak of execution of a function to designate the execution of the instructions carrying out this function.

[0079] CHAPTER II: Examples of embodiments

[0080] [Fig.l] represents an electronic computer 1 comprising a microprocessor 2, a main memory 4 and a mass storage medium 6. For example, the computer 1 is a computer, a smartphone, an electronic tablet, a smart card or the like.

[0081] The microprocessor 2 here comprises:

[0082] - a hardware chain 10 for processing the instructions to be executed;

[0083] - a set 12 of registers;

[0084] - a control module 14,

[0085] - a data input / output interface 16, and

[0086] - a bus 17 which connects the different components of the microprocessor 2 to each other.

[0087] Memory 4 is configured to store instructions of a binary code 30 of a program to be executed by the microprocessor 2. The memory 4 is a random access memory. Typically, the memory 4 is a volatile memory. The memory 4 may be a memory external to the microprocessor 2 as shown in [Fig.l]. In this case, the memory 4 is, for example, produced on a substrate mechanically separated from the substrate on which the various elements of the microprocessor 2 are produced, such as the chain 10.

[0088] The medium 6 is typically a non-volatile memory. For example, it is a memory of the EEPROM or Flash type. Here, it contains a backup copy 40 of the binary code 30. Typically, it is this copy 40 which is automatically copied into the memory 4 to restore the code 30, for example, after a power outage or similar or just before the execution of the code 30 begins.

[0089] In this exemplary embodiment, the binary code 30 notably comprises an encrypted machine code 32. The machine code 32 contains a succession of words Wi, each of the same size as the instruction it contains. Typically, the size of each word Wi, in number of bits, is greater than eight or sixteen bits. Here, the size of each word Wi is equal to thirty-two bits. Subsequently, the index i is the order number of the word Wi in the machine code 32. Thus, the index i-1 corresponds to the word preceding the word Wi. Similarly, the index i+1 corresponds to the word following the word Wi. As explained later, each word Wi contains either a cryptogram li* of an instruction li to be executed or a cryptogram Srefi* of a reference signature. Here, the size of a word Wi is equal to the size of the cryptogram it contains.In this exemplary embodiment, the words Wi containing a cryptogram Srefi* represent less than 30% and, typically, less than 20% or less than 10% of the total number of words Wi of the machine code 32. The other words Wi of the machine code 32 each contain the cryptogram li* of an instruction to be executed.

[0090] By way of illustration, the microprocessor 2 complies with the ARM architecture (“Advanced Risk Machine”) version 7 and supports instruction sets such as Thumbl and / or Thumb2. An instruction set defines in a restrictive manner the syntax of the instructions that the microprocessor 2 is capable of executing. This instruction set therefore defines in particular all the possible opcodes for an instruction. The syntax of an instruction is incorrect if its syntax does not correspond to any of the possible syntaxes for an instruction executable by the microprocessor 2. For example, if the bit range of an instruction Id which corresponds to the bit range used to encode the Opcode of the instruction contains a value which is different from all the possible values ​​for an Opcode, then its syntax is incorrect.

[0091] In this exemplary embodiment, the assembly 12 comprises general registers that can be used to store any type of data and dedicated registers. Unlike the general registers, the dedicated registers are dedicated to the storage of particular data generally automatically generated by the microprocessor 2.

[0092] The module 14 is configured to move data between the set 12 of registers and the interface 16. The interface 16 is notably capable of acquiring data and instructions, for example, from the memory 4 and / or the support 6 external to the microprocessor 2.

[0093] Chain 10 is better known by the English term "pipeline". Chain 10 makes it possible to start executing an instruction of the machine code while the processing, by chain 10, of the previous instruction of this machine code is not yet finished. Such processing chains are well known and only the elements of chain 10 necessary for understanding the invention are described in more detail.

[0094] The chain 10 typically comprises the following stages:

[0095] - an 18 instruction loader,

[0096] - a decryption module 20,

[0097] - an instruction decoder 22, and

[0098] - an arithmetic and logic unit 24 which executes the instructions.

[0099] The loader 18 loads the next instruction to be executed by the unit 24 from the memory 4. More precisely, the loader 18 loads the word Wi of the machine code 32 to which an ordinal counter 26 points. Unless its value is modified by the execution of a branch instruction, the value of the ordinal counter 26 is incremented by a regular step each time an instruction is executed by the arithmetic and logic unit 24. The regular step is equal to the difference between the addresses of two immediately consecutive instructions in the machine code 32. This step is here called "unit step".

[0100] The decryption module 20 decrypts the loaded cryptogram li* and transmits the decrypted instruction li to the decoder 22. The decrypted instruction li is also called a “plaintext instruction”. For this, the module 20 implements and executes a pre-programmed decryption function gl(Ii*, Si-1), where:

[0101] - li* is the cryptogram of the instruction li in clear,

[0102] - Si-1 is a signature constructed for the previous instruction li-1, and

[0103] - gl() is the inverse of the encryption function g().

[0104] The construction of the Si-1 signature is described later.

[0105] In this first embodiment, the function g() is a function that limits the statistical dependence between the value of li and the value of li*. Here, the function g() is the “EXCLUSIVE OR” function represented by the symbol XOR. Thus, in this embodiment, the plaintext instruction li is obtained using the following relation: li = li* XOR Si-1.

[0106] The decoder 22 decodes the decrypted instruction li to obtain configuration signals which configure the microprocessor 2 to execute, typically during the next clock cycle, the decrypted instruction. One of these configuration signals encodes the nature of the operation to be executed by the unit 24. This configuration signal is derived from / is constructed from the opcode of the decrypted instruction. Other configuration signals indicate, for example, whether the decrypted instruction is an instruction to load data from memory 4 or to write data to memory 4. These configuration signals are transmitted to unit 24. Other configuration signals contain the values ​​of the loaded operands. Depending on the instruction to be executed, these signals are transmitted to the set 12 of registers or to unit 24.

[0107] When the decoder 22 fails to decode an instruction, it generates an error signal. Typically, this occurs if the syntax of the decrypted instruction is incorrect.

[0108] The unit 24 executes the decrypted instructions one after the other. The unit 24 is also capable of recording the result of the execution of these instructions in one or more of the registers of the set 12.

[0109] In this description, we will use as synonyms “execution by microprocessor 2” and “execution by unit 10”.

[0110] A given (machine) instruction li must be successively processed, in order, by the loader 18, the decryption module 20, the decoder 22 and the unit 24. In addition, the loader 18, the decryption module 20, the decoder 22 and the unit 24 are capable of working in parallel with each other during the same clock cycle. Thus, during the same clock cycle, the loader 18 may be loading the cryptogram Ii+1 * of the following instruction Ii+1, the decoder 22 decoding the decrypted instruction li and the unit 24 executing the instruction Ii-1. Chain 10 thus makes it possible to process several instructions of machine code 30 in parallel. Module 20 decrypts cryptogram Ii+1* after decoding instruction li by decoder 22.

[0111] To ensure the integrity of the machine code 32, the chain 10 additionally includes the following hardware modules:

[0112] - a signature constructor 42, and

[0113] - an integrity checker 44.

[0114] The constructor 42 is configured to perform the following operations:

[0115] 1) memorize the previous signature Si-1 constructed for the previous instruction Ii-1,

[0116] 2) construct a signature Si for the instruction li from the previous signature Si-1 constructed and signals generated by decoder 22 in response to decoding instruction li.

[0117] To perform operation 2) above, constructor 42 implements and executes a pre-programmed function f(Idi; Si-1), where:

[0118] - ldi is a set of signals generated by the decoder 22 in response to the decoding of the instruction li,

[0119] - Si-1 is the previous signature constructed for instruction Ii-1, and

[0120] - f() is a function of predetermined signature.

[0121] Each signal generated by the decoder is in the form of a bit vector composed of the values ​​0 and 1. The set ldi contains the current values ​​of each of the signals in the set. The set ldi is statically computable, that is, computable before the machine code 32 is deployed in the memory 4. In other words, the set ldi is computable at the time of compilation of the machine code 32. Furthermore, in this embodiment, if a useful bit of the instruction li changes, at least one bit of the set ldi also changes. The useful bits of the instruction li are those that contribute either to the definition of the opcode or to the definition of one of the operands of the instruction li. Thus, the set ldi varies depending on the opcode and the value of each operand of the instruction li. For example, the ldi set generally includes the operand selection signals and the control signals of unit 24.

[0122] The signature function f() has the following properties:

[0123] i) Collision resistance,

[0124] ii) Error preservation, and

[0125] iii) Non-associativity.

[0126] Collision resistance means that, knowing the signature Si of an instruction li, it is practically impossible to find an instruction l'i which is different from the instruction li and which has the same signature Si. In particular, it is practically impossible by modifying only a few bits of the instruction li to obtain an instruction l'i which has the same signature Si.

[0127] Error preservation means that if a signature S'i is erroneous, i.e., it is different from the expected signature Srefi, then all subsequent signatures Si+n are also erroneous, where n is an integer greater than zero. This is made necessary by the fact that the function f() is a recursive signature function that constructs the current signature from the previous signature.

[0128] Thanks to properties i) and ii), the integrity of an instruction li, can be confirmed or invalidated by checking the integrity of any following instruction li+n.

[0129] Non-associativity means that whatever the modification of the order of instructions II to Ii-1, the signature S'i constructed for instruction Ii is different from the signature Si constructed in the absence of modifications of the order of instructions II to Ii-1.

[0130] Furthermore, here, to ensure the confidentiality of the instructions of the machine code 32, the function f() has the following properties:

[0131] - associate a different signature Si for each different instruction Ii,

[0132] - behave as a safe pseudo-random number generator, i.e. a CSPRNG (“cryptographically secure pseudorandom number generator”), and

[0133] - generate a signature of size equal to or greater than the size of the instructions Ii.

[0134] For example, the function f() is a CBC-MAC function ("cipher block chaining message authentication code"). Still for illustration purposes, in this CBC-MAC function, the encryption algorithm used is a block cipher algorithm, for example, the encryption algorithm known as "Prince" (see for example about this algorithm, the following Wikipedia page: https: / / en.wikipedia.org / wiki / Prince_(cipher)). The "Prince" encryption algorithm is parameterized by a secret key ks which is only known to the computer 2 and the compiler which generated the machine code 32. Typically, the key ks is stored in a secure memory of the signature constructor 42. Here, the signature Si is coded on the same number of bits as the instruction li.

[0135] Preferably, there is no machine code for executing the gl() and f() functions in a memory located outside the microprocessor 2. Typically, they are implemented in hardware form within, respectively, the module 20 and the constructor 42.

[0136] The verifier 44 verifies the integrity of the machine code decrypted and executed by the microprocessor 2. To do this, the verifier 44 compares a signature Si constructed by the manufacturer 42 to a pre-recorded reference signature Srefi. If the signature Si is identical to the pre-recorded signature Srefi, then the machine code is intact. Otherwise, the verifier 44 triggers the reporting of an integrity defect. Typically, the signature Srefi is constructed during the compilation of the machine code 2.

[0137] In this embodiment, the signature Srefi is recorded in the machine code 32. More precisely, immediately after the word Wi of the machine code 32 which contains the cryptogram li*, the machine code comprises a word Wi+1 which contains the cryptogram Srefi* of the signature Srefi. Here, the cryptogram Srefi* is obtained using the same encryption function g() as that used to encrypt the instructions. For example, the cryptogram Srefi is obtained using the following relation: Srefi* = Srefi XOR Srefi-1, where the signature Srefi-1 is the one used when compiling the machine code to encrypt the instruction li. As explained previously in the case of the instructions li, an error in the decrypted or decoded instruction results in an error on all subsequent signatures Si+n constructed by the constructor 42.Thus, to detect an integrity defect, it is not necessary for the verifier 44 to check the integrity of the machine code after the execution of each li instruction. Here, the verifier 44 checks the integrity of the machine code at locations chosen as being relevant to ensure the security of the executed machine code. For example, in this embodiment, the verifier 44 checks the integrity of the machine code after the execution of each branch instruction. For this purpose, after each branch instruction, the machine code 32 comprises . a word Wi+1 containing the cryptogram Srefi*. In this embodiment, it is therefore the execution of a branch instruction which triggers the comparison of the signature Si constructed by the constructor 42, with the reference signature Srefi obtained by decrypting the cryptogram Srefi* contained in the word Wi+1.

[0138] [Fig. 2] represents a compiler 60 capable of automatically generating the machine code 32 from a source code 62. For this purpose, the compiler 60 typically comprises a programmable microprocessor 64 and a memory 66. The memory 66 contains the instructions and data necessary for, when executed by the microprocessor 64, automatically generating the machine code 32 from the source code 62. In particular, the memory 66 contains the instructions necessary for executing the method of [Fig. 3].

[0139] [Fig.3] represents a method of generating the machine code 32 from the source code 62 by the compiler 60.

[0140] During a step 70, the compiler 60 performs an initial compilation of the source code 62 to obtain a first plaintext machine code in which the instructions li are not encrypted. The first machine code does not, at this stage, include instructions that trigger the verification of the integrity of the machine code. The first machine code also does not include reference signatures.

[0141] During a step 72, the compiler 60 automatically transforms the first machine code into a second machine code which also contains the instructions which trigger the integrity check. For this purpose, the compiler 60 automatically identifies, in the first machine code, the locations where the instructions which trigger the integrity check must be inserted. Here, it identifies the locations of the branch instructions in the first code. Then, after each of these identified instructions, the compiler 60 automatically inserts a location allowing the subsequent insertion of a reference signature.

[0142] During a step 74, the compiler generates, from the second machine code, a third machine code 32 in which each instruction li is replaced by its corresponding cryptogram li*.

[0143] For example, during step 74, for each sequence of consecutive instructions, the compiler scans this sequence of instructions in the ascending order of the instructions li. Here, a sequence of consecutive instructions is a sequence of instructions of the second machine code which are systematically executed one after the other during the execution of the machine code 32 by the computer 2. For each plaintext instruction li encountered in this sequence of instructions, the compiler 60 constructs the signature Srefi to be used to obtain the corresponding cryptogram I*i+1. In the absence of an error, the signature Srefi constructed by the compiler 60 is the same as that which is constructed by the constructor 42 to decrypt the cryptogram I*i+1 during the execution of the machine code 32 by the microprocessor 2. For this, the compiler 60 constructs each signature Srefi using the same function f() as that used by the constructor 42. Thus, each signature Srefi is obtained using the following relation: Srefi = f(Idi; Srefi-1). For example, for this, the compiler 60 implements a simulator which reproduces the operation of the chain 10 and, in particular, of the decoder 22 and of the constructor 42. In particular, the emulator runs through the second machine code and for each instruction li of the second machine code:

[0144] - the simulator produces the same configuration signals as those generated by the decoder 22 when it has finished decoding the li instruction, then

[0145] - the simulator constructs the Srefi signature from the set ldi of these signals and of the previous Srefi-1 signature constructed using the f() function.

[0146] In this embodiment, to encrypt the first instruction II of the machine code, the compiler uses a reference signature SrefO predetermined and known to the microprocessor 2. Typically, the signature SrefO is a secret signature known only to the microprocessor 2 and the compiler 60. For example, the signature SrefO is recorded in a secure memory of the microprocessor 2 and used by the manufacturer 42 to decrypt the cryptogram contained in the first word W1 of the machine code 32.

[0147] Once the Srefi signature is constructed, the compiler 60 obtains the cryptogram li* using the relation li* = g(Ii; Srefi-1), where the function g() is the inverse of the function gl(), i.e. it verifies the following relation: li = gl(g(Ii)). In this example, the cryptogram li* is obtained using the following relation: li* = li XOR Srefi-1. Each instruction li of the second machine code is then replaced by its cryptogram li* to obtain the third machine code.

[0148] The second machine code may include branch instructions so that the instruction preceding an instruction li may be either instruction li-1 or another instruction Ij depending on the path taken. In this case, the instruction li has several preceding instructions li-1 and Ij. However, there can only be one cryptogram li*. Here, the cryptogram li* is either equal to g(Ii; Srefi-1) or equal to g(Ii; Srefj). For the cryptogram li* to be the same regardless of the path taken, the signature Srefj must be identical to the signature Srefi-1. For this purpose, a mechanism for updating the signature Srefj is implemented. For example, here, the signature update mechanism known by the acronym GPSA (“Generalized Path Signature Analysis”) is implemented.The GPSA mechanism is for example described in the following article: Mario Wemer et Al: "Protecting the Control Flow of Embedded Processors against F'ault Attacks", CARDIS 2015: Revised Selected Papers of the 14th International Conference on Smart Card Research and Advanced Applications - Volume 9514November 2015 Pages 161-176. Since the . mechanism for updating signatures is known, the updating of signatures in the case where an instruction has several preceding instructions is not described in this text. In other words, subsequently, the description is made in the particular case of a sequence of immediately consecutive instructions, knowing that the person skilled in the art knows how to apply this teaching in the case where the control flow of the machine code has several bifurcations corresponding, typically, to conditional branch instructions.

[0149] During a step 76, immediately after the cryptogram li* of each instruction which triggers the integrity check, the compiler automatically inserts a word Wi+1 containing the cryptogram Srefi* to obtain the machine code 32.

[0150] In this embodiment, the cryptogram Srefi* is obtained using the following relation: Srefi* = g(Srefi; Srefi-1), where Srefi and Srefi-1 are the signatures constructed, respectively, for the instructions li and li-1 during step 74.

[0151] [Fig.4] represents a method of executing the machine code 32 by the computer 2.

[0152] The method begins with a step 150 of providing the binary code 30 in the memory 4. For this, for example, the microprocessor 2 copies the copy 40 inside the memory 4 to obtain the binary code 30 recorded in the memory 4. Beforehand, this binary code 30 has been generated by the compiler 60 by implementing the method of [Fig.3].

[0153] Then, during a phase 152, the microprocessor 2 executes the binary code 30 and, in particular, the machine code 32.

[0154] To do this, for each word Wi pointed to by the ordinal counter 26, the chain 10 successively executes the following steps:

[0155] - a step 154 ​​of loading, by the loader 18, the word Wi pointed to by the value current ordinal counter 26, then

[0156] - a step 156 of decryption, by the module 20, of the cryptogram contained in the word Wi loaded to obtain a clear li instruction,

[0157] - a step 158 of decoding, by the decoder 22, of the instruction li in clear, then

[0158] - a step 160 of execution, by the unit 24, of the decoded instruction li.

[0159] Furthermore, for example in parallel with step 160, during a step 162, the constructor 42 constructs the signature Si from the set ldi of signals generated by the decoder 22 at the end of step 158 and from the previous signature Si-1 constructed. The signature Si thus constructed is then transmitted to the decryption module 20 which is then able to decrypt the cryptogram Ii+l* of the next instruction to be executed.

[0160] If during step 160, the executed instruction li is not an instruction which triggers the integrity check, then the ordinal counter 26 is incremented by the unit step to point to the next word Wi+1 and the method returns directly to step 154 ​​to execute the next instruction Ii+1.

[0161] If during step 160, the instruction li executed is an instruction which triggers the integrity check, then the processing chain 10 executes a step 163 of checking the integrity of the machine code executed up to now.

[0162] Here, this step 163 comprises the following operations:

[0163] - an operation 164 of loading, by the loader 18, the word Wi+1 which follows immediately the word Wi which contains the cryptogram li*, then

[0164] - an operation 168 of decryption, by the module 20, of the cryptogram Srefi* contained in the word Wi+1 to obtain the Srefi signature in clear, then

[0165] - an operation 170 of comparison, by the verifier 44, of the signature Si constructed for the li instruction with the Srefi signature obtained at the end of operation 168.

[0166] The address of the word Wi+1 containing the cryptogram Srefi* is deduced from the value of the ordinal counter 26. For example, here, the address of the word Wi+1 is equal to the address contained in the ordinal counter 26 after the instruction li has been executed.

[0167] Then, if the compared signatures Si and Srefi are identical, the method continues with a step 172 during which the ordinal counter 26 is incremented to point directly to the word Wi+2. After step 172, the method returns to step 154 ​​to execute the instruction Ii+2.

[0168] Conversely, if the compared signatures Si and Srefi are different, the method continues with a step 180 during which an integrity fault is signaled.

[0169] Furthermore, during step 158, if an li instruction cannot be decoded because its syntax is incorrect, the method also continues with step 180 of reporting an integrity fault. During this step 180, the decoder 22 triggers the reporting of an integrity fault.

[0170] In response to an integrity fault signal, during a step 182, the microprocessor 2 implements one or more countermeasures. A large number of countermeasures are possible. The countermeasures implemented may have very different degrees of severity. For example, the countermeasures implemented may range from the lifting of an interrupt to a permanent shutdown of the microprocessor 2 and the deletion of sensitive data. The microprocessor 2 is considered to be out of service when it is permanently placed in a state where it is incapable of executing any machine code. Between these extreme degrees of severity, there are many other possible countermeasures such as:

[0171] - the indication via a human-machine interface of the detection of mistakes,

[0172] - immediate interruption of the execution of the machine code 32 and / or its reinitialization, And

[0173] - the deletion of the machine code 32 from the memory 4 and / or the deletion of the copy 40 backup and / or deletion of secret data.

[0174] Steps 154, 156, 158 and 160 are typically each executed in one clock cycle. In addition, some of these steps are preferably executed in parallel for different successive instructions of the machine code 32. For example, chain 10 can execute in parallel:

[0175] - step 154 ​​to load the cryptogram Ii+1*,

[0176] - step 158 of decoding the instruction li, and

[0177] - step 160 of executing instruction Ii-1.

[0178] Chapter III: Variants

[0179] Calculator variants:

[0180] Memory 4 can also be a non-volatile memory. In this case, it is not necessary to copy the binary code 30 into this memory before launching its execution since it is already there.

[0181] The memory 4 can also be an internal memory integrated inside the microprocessor 2. In the latter case, it is produced on the same chip (“die” in English) as the other elements of the microprocessor 2. Finally, in other configurations, the memory 4 is composed of several memories, some of which are produced on the microprocessor chip and others are produced on another chip mechanically independent of the microprocessor chip.

[0182] Alternatively, the operation of loading the word Wi and the operation of decrypting the word Wi are performed during the same clock cycle by the loading stage. In other words, in this alternative, the decryption module 20 is integrated into the loader 18. In another alternative, the operation of decrypting the cryptogram Wi and the operation of decoding the instruction li are performed during the same clock cycle. In other words, in this alternative, the decryption module 20 is integrated into the decoder 22. It is also possible to place the decryption module 20 anywhere between the instruction memory and the instruction loader 18. In this case, the instruction loader 18 loads an instruction li that has already been decrypted and not the word Wi containing the cryptogram li*. However, this latter alternative may have a lower security level than the other alternative variants.

[0183] Alternatively, the processing hardware chain comprises a set of several arithmetic and logic units and not a single arithmetic and logic unit. In this case, in general, this set comprises arithmetic and logic units specialized in the execution of certain specific instructions. Thus, when one of these specific instructions is decoded, the signals generated by the decoder specifically activate the arithmetic and logic unit specialized in the execution of this specific instruction. For example, the set of several arithmetic and logic units may include:

[0184] - one or more co-processors,

[0185] - one or more IMC (“In Memory Computing”) memories each capable to perform processing on the data they store.

[0186] Alternatively, the processing chain is not located in a microprocessor but in a co-processor or in an IMC memory.

[0187] In another variant, the different stages of the processing hardware chain are distributed differently. In particular, it is not necessary for all the stages of the processing chain to be located on the same chip. For example, in one variant, the instruction loader and the decoder are located on the microprocessor chip while the arithmetic and logic unit is located on another chip such as, for example, the chip of an IMC memory. In another variant, it is the constructor 42 and the verifier 44 which are implemented on another chip.

[0188] Alternatively, the instructions li do not all have the same size. In this case, the words Wi do not all have the same size either.

[0189] Variants of the construction of the signature S i j.

[0190] Alternatively, the signature Si is constructed, in addition, from signals originating from one or more stages following the decoder 22 in the processing chain 10. For example, the signals generated by the unit 24 are used to construct the signature Si.

[0191] In a particular variant, only the signals generated by one or more stages following the decoder 22 are used to construct the signature Si. In this case, the signals generated by the decoder 22 are not used. For example, only the signals generated by the unit 24 when it executes the instruction li are used to construct the signature Si. In this particular variant, it is therefore necessary to wait until the instruction li is executed before the constructed signature Si can be compared to the signature Srefi. In other words, in this variant, the verification of the integrity of the instruction li cannot be executed immediately after its decoding by the decoder 22.

[0192] In a simplified embodiment, the signature Si is constructed solely from the configuration signal which codes the opcode of the instruction li or solely from the configuration signals which vary according to the value(s) of the operand(s) of the instruction li.

[0193] Other embodiments of the function f() are possible. For example, the CBC-MAC function is replaced by another message authentication function such as the function known by the acronym H-MAC (“Hash-based Message Authentication Code”).

[0194] In a simplified embodiment, the function f() does not use a secret key. In this case, the authenticity of the machine code is not guaranteed. For example, the function f() is a function known by the acronym CRC ("Cyclic Redundancy Check") or a function known by the acronym MISR ("Multiple-Input Signature Registers").

[0195] Alternatively, the f() function does not behave like a CSPRNG. In this case, the described method still allows the concealment of the machine code.

[0196] There are other possibilities for obtaining the initial signature SrefO. For example, the microprocessor 2 is configured to construct the initial signature SrefO from the first word WI of the machine code 32. For illustration purposes, the signature SrefO is taken equal to the first word W1. In the latter case, the signature SrefO is public.

[0197] Decryption variants:

[0198] Other gl() functions are possible. For example, the g-1() function is defined by the following relation: ii = (i*i + Si-1) modulo(n), where:

[0199] - "modulo" is the operation of modular arithmetic which to the pair (a, b) of integers, associates the remainder of the Euclidean division of a by b,

[0200] - n is the divisor of the modular operation, and

[0201] - (i*i + Si-1) is the result of the arithmetic addition of I*i and Si-1.

[0202] In this example, n is a predetermined integer greater than two. For example example, n is equal to 32.

[0203] Another possible example of a gl() function is that defined by the following relation: ii = i*i XOR Si-1 XOR ks, where ks is the secret key known only to the computer 2.

[0204] If computing power allows, the gl() function can also be a decryption function, for example, a symmetric one. The signature Si-1 can then be used as the decryption key. In another example, the decryption key is the secret key ks independent of the signatures Si. In this last example, it is a combination of the bits of the cryptogram Ii* and the signature Si-1 that is decrypted using the key ks. Each time the gl() function is modified, the encryption function g() must be adapted accordingly.

[0205] Other embodiments are possible for encrypting the reference signatures contained in the machine code. For example, as a variant, the cryptogram Srefi* contained in the word Wi+1 is obtained using the following relation: Srefi* = g(Srefi ; Srefi) and not the relation Srefi* = g(Srefi ; Srefi-1). This variant has the advantage that whatever the word Wi of the machine code, the key used to decrypt the cryptogram it contains is the signature Srefi-1. Thus, it is not necessary to know whether the word Wi contains the cryptogram of an instruction or a reference signature to be able to select the decryption key. However, in this case, this imposes additional constraints on the choice of the encryption function g(). For example, the encryption function g() can no longer be a simple "EXCLUSIVE OR" as previously described because the result of Srefi XOR Srefi is systematically zero. An example of a g() function that is suitable in this case is a symmetric encryption function.

[0206] Another decryption function g'-l() can be used instead of the gl() function when the cryptogram to be decrypted is that of a reference signature. For example, while the "EXCLUSIVE OR" function is used to decrypt li* cryptograms, the g'-l() function is a symmetric decryption function that uses a predetermined secret key kSref.

[0207] Variants of integrity verification:

[0208] Other solutions are possible to identify that the loaded word contains a reference signature and not an instruction. For example, in a particular embodiment, each word Wi containing the cryptogram li * of an instruction is followed by a word Wi+1 containing all or part of the cryptogram Srefi*. In this case, each even word loaded in the sequence of instructions contains a cryptogram of a reference signature. It is then not necessary for the instruction li to be a branch instruction which indicates that the following word of the machine code contains the cryptogram Srefi*. In a variant of the previous embodiment, the size of the words Wi is increased so as to record in each word Wi both the cryptogram li* and the cryptogram Srefi*. In this last variant, the cryptogram Srefi* is not recorded in the additional word Wi+1.

[0209] Instructions other than the branch instructions may be used to trigger the integrity check. For example, as a variant, the machine code includes a specific instruction which, when executed by the unit 24, indicates that the next word contains all or part of the cryptogram Srefi* and triggers the decryption of the cryptogram Srefi* and then its comparison with the constructed signature Si.

[0210] Alternatively, the cryptogram Srefi* is contained in the word Wi-1 which precedes the word Wi containing the cryptogram li* and not in the word Wi+1 as previously described. In this case, the instruction contained in the word Wi-2 causes the decryption and loading of the signature Srefi into the verifier 44 and the verifier compares the loaded signature Srefi to the signature Si constructed after the decoder 22 has decoded the instruction li.

[0211] In another variant, the reference signatures are not stored in the instruction memory that contains the machine code 32. For example, the reference signatures are stored in a secure memory independent of the instruction memory containing the cryptograms li*. Typically, the secure memory is a memory only accessible by the verifier 44. In this case, it is not necessary for the reference signatures to be stored in this secure memory in the form of cryptograms. In this variant, the machine code comprises load instruction cryptograms. After decryption, this load instruction is executed. Its execution causes the reference signature stored in the secure memory to be loaded. For example, in response to the execution of such a load instruction, the reference signature is loaded into the verifier 44 and then used to verify the signature constructed for a decoded instruction.

[0212] Alternatively, only part of the Srefi* cryptogram is recorded in a word of the machine code. The other part of this Srefi* cryptogram is recorded elsewhere, for example, in the secure memory mentioned in the previous paragraph.

[0213] Other signature update mechanisms, different from the GPSA mechanism, are possible. For example, as a variant, each time a branch instruction is executed, this triggers the loading, for example from a secure memory, of a reference signature associated with this branch instruction.

[0214] Other variants:

[0215] Alternatively, only certain instructions of the machine code are encrypted. For example, for this, a specific instruction is added to the instruction set of the microprocessor 2. When this specific instruction is executed by the unit 24, it indicates to the microprocessor that the next T instructions are not encrypted instructions and therefore must not be decrypted. Typically, the number T is an integer greater than or equal to 1 or 10 or 100.

[0216] Each word Wi may contain metadata in addition to the cryptogram li*. For example, this metadata makes it possible to verify the integrity or authenticity of the cryptogram li* before it is loaded by the processing chain 10. This metadata may also be used to indicate that the word Wi contains the cryptogram of a reference signature or, on the contrary, the cryptogram of an instruction.

[0217] According to another variant, it is a specific bit of a status or control register of the microprocessor 2 which indicates whether or not the loaded word contains the cryptogram of an instruction. More precisely, when this specific bit takes a predetermined value, the loaded word is treated by the chain 10 as an instruction. If this specific bit takes a value different from this predetermined value, then the loaded word is treated as a reference signature.

[0218] When compiling the machine code 30, step 76 can be performed at the same time as step 72. In this case, during step 72, for each branch instruction, the compiler 60 additionally calculates the corresponding Srefi signature and inserts it into the word Wi+1 which follows this branch instruction. In this case, preferably, during step 74 each Srefi signature is encrypted using exactly the same algorithm as that used to encrypt li instructions so that, at step 74, the compiler does not have to distinguish between words that contain a plaintext instruction and words that contain a plaintext signature.

[0219] Several of the different embodiments described herein may be combined with each other.

[0220] Chapter III: Advantages of the described embodiments

[0221] In the embodiments described here, the machine code instructions are not recorded in clear text in the main memory, which makes it more difficult to analyze the machine code. The signature Si is constructed from the signature Si-1, which is itself a function of the previous instruction li-1 and the previous signature Si-2. Thus, by recursion, the signature Si-1 used to decrypt the instruction li depends on all the previously executed instructions. Therefore, an error in the decryption of an instruction li makes it impossible to decrypt all the following instructions. The integrity of the code is therefore guaranteed with a very high level of security. In particular, the embodiments described here make it possible to trigger the reporting of an integrity fault in the event of modification of an instruction or instruction skipping. In addition, the signature Si depends on the set ldi of configuration signals.Therefore, the embodiments described here also make it possible to trigger the reporting of an integrity fault in the event of modification of the instruction after its decoding, i.e. typically in the event of an error in the decoding of the instruction.

[0222] Comparing the constructed signature Si to a pre-recorded reference signature Srefi makes it possible to detect an integrity fault without having to decrypt and execute the following instruction Ii+1. More precisely, this makes it possible to detect an integrity fault without relying on the fact that decrypting a cryptogram li+n* of a following instruction necessarily produces an erroneous instruction l'i+n which does not belong to the instruction set of the microprocessor 2 if the integrity of the instruction li has been compromised, where n is an integer greater than or equal to one. Thus, comparing the signature Si to the reference signature Srefi makes it possible to detect an integrity fault even when the instruction set of the computer is not sparse. This comparison also makes it possible to limit the number of unexpected behaviors of the computer and therefore to increase the security of the method.

[0223] Decrypting the reference signature using a signature constructed for one of the instructions in the instruction sequence increases the security of the method. Indeed, the reference signature is hidden and, moreover, it can be correctly decrypted only if the previously decrypted instruction sequence is intact.

[0224] Deciphering the cryptogram of the reference signature Srefi from the constructed signature Si-1 or Si makes it possible to simplify the operation of the calculator because the same function g() is used whether the cryptogram to be deciphered is that of an instruction or a reference signature.

[0225] Using a secret key to construct the signature Si also allows the code to be authenticated because only authentic machine code contains a series of instructions encrypted using this same secret key.

[0226] Using only the signals generated by the decoder to construct the signature Si makes it possible to speed up the execution of the machine code. Indeed, in this case, it is not necessary to wait for the instruction li to be processed by a stage following the decoder 22 so that the signature Si can be constructed and then compared to the signature Srefi.

[0227] Constructing the signature Si based on the opcode and operands of the li instruction strengthens the code integrity guarantee since any modification of the li instruction results in a modification of the signature Si.

Claims

1. Claims Method for executing a machine code by a computer comprising a hardware instruction processing chain, this hardware processing chain comprising a succession of stages which process one after the other each instruction to be executed of the machine code, this succession of stages comprising at least the following stages: an instruction loader, a decoder and an arithmetic and logic unit, this machine code comprising a cryptogram for each instruction of a sequence of consecutive instructions, this method comprising the execution of the following steps for each cryptogram of an instruction of a sequence of consecutive instructions of the machine code: - the loading (154), by the instruction loader, of the cryptogram of an instruction designated by an ordinal counter to obtain a loaded cryptogram, then - decryption (156) of the loaded cryptogram to obtain a decrypted instruction, then - decoding (158) the decrypted instruction, by the decoder, to generate signals which configure the computer to execute the decrypted instruction, then, - the execution (160), by the arithmetic and logic unit, of the decrypted instruction, characterized in that the method also comprises the following steps for at least one current instruction of the sequence of consecutive instructions: - after the decoding operation of the current instruction and before the decryption of the cryptogram of the following instruction in the sequence of consecutive instructions, the construction (162) of a signature for the current instruction: - from a set of signals generated by a stage of the succession of stages in response to the processing of this current instruction by this stage, this stage which generates this set of signals being the decoder or a stage following the decoder in the succession of stages, and - from the previous signature constructed for the instruction which precedes it in the sequence of consecutive instructions, this signature for the current instruction thus varying as a function of the current instruction and as a function of all the instructions preceding the current instruction in the sequence of consecutive instructions, then - the verification (163) of the integrity of the executed machine code by comparing (170) the signature constructed for the current instruction with a pre-recorded reference signature, then - only when the verification of the integrity of the current instruction is successful, the decryption (156) of the cryptogram of the following instruction using the signature constructed for the current instruction.

2. Method according to claim 1, in which the integrity verification step comprises: - loading (164) a cryptogram of the reference signature, then - decrypting (168) this cryptogram using one of the signatures constructed for one of the instructions of the sequence of instructions.

3. Method according to claim 2, in which: - the cryptogram of the reference signature is loaded from the address contained in the ordinal counter after loading the cryptogram of the current instruction and before loading the cryptogram of the following instruction, and - the cryptogram of the reference signature is decrypted using the signature constructed for the current instruction or for the instruction which precedes this current instruction in the sequence of consecutive instructions.

4. Method according to claim 1, in which during the construction (162) of the signature for the current instruction, this signature is additionally constructed from a secret key pre-recorded in a memory of the calculator.

5. A method according to any preceding claim, wherein the stage which generates the set of signals used to construct the signature is the decoder.

6. The method of claim 5, wherein, when constructing (162) a signature for the current instruction, this signature is constructed from signals, generated by the decoder in response to the decoding of the current instruction, which vary as a function of the opcode of the current instruction and according to each operand of the current instruction.

7. Method according to any one of the preceding claims, in which the decryption of the cryptogram of each instruction using the constructed signature consists of carrying out an "EXCLUSIVE OR" between the bits of the cryptogram of the instruction and the bits of the constructed signature for the instruction which precedes this instruction in the sequence of consecutive instructions.

8. Method according to any one of the preceding claims, in which, when the signature constructed for the current instruction is different from the pre-recorded reference signature to which it is compared, the step (163) of verifying the integrity of the current instruction continues with a step (180) of signaling an integrity defect.

9. Machine code (32) capable of being executed by implementing a method according to any one of the preceding claims, this machine code comprising a cryptogram for each instruction of a sequence of consecutive instructions, characterized in that: - each of these cryptograms is the cipher of a corresponding instruction of this sequence of consecutive instructions using a signature constructed: - from the signals generated by a stage of the succession of stages in response to the decoding of this corresponding instruction by this stage, this stage which generates this set of signals being the decoder or a stage following the decoder in the succession of stages, and - from the previous signature constructed for the instruction which precedes it in the sequence of consecutive instructions,this signature for the corresponding instruction thus varying as a function of the corresponding instruction and as a function of all the instructions preceding the corresponding instruction in the sequence of consecutive instructions, and - the machine code also comprises the pre-recorded reference signature to which the signature constructed for a current instruction is compared during the execution of this machine code by implementing a method in accordance with any one of the preceding claims.,

10. Information recording medium readable by a microprocessor of a computer, characterized in that it comprises a machine code in accordance with claim 9.

11. A computer for implementing an execution method according to any one of claims 1 to 8, this computer comprising a hardware chain (10) for processing instructions, this hardware processing chain comprising a succession of stages which process each instruction to be executed of the machine code one after the other, this succession of stages comprising at least the following stages: an instruction loader (18), a decoder (20) and an arithmetic and logic unit (22), this hardware processing chain being capable, for each cryptogram of an instruction of a sequence of consecutive instructions of a machine code, of executing the following operations: - the loading, by the instruction loader, of the cryptogram of an instruction designated by an ordinal counter to obtain a loaded cryptogram, then - the decryption of the loaded cryptogram to obtain a decrypted instruction,then - the decoding of the decrypted instruction, by the decoder, to generate signals which configure the computer to execute the decrypted instruction, then, - the execution, by the arithmetic and logic unit, of the decrypted instruction, characterized in that the hardware processing chain is also configured to execute the following steps for at least one current instruction of the sequence of consecutive instructions: - after the decoding operation of the current instruction and before the decryption of the cryptogram of the following instruction in the sequence of consecutive instructions, the construction of a signature for the current instruction: - from the signals generated by a stage of the succession of stages in response to the decoding of this current instruction by this stage, this stage which generates this set of signals being the decoder or a stage following the decoder in the succession of stages,and - from the previous signature constructed for the instruction preceding it in the sequence of consecutive instructions, this signature for the current instruction thus varying as a function of the current instruction and as a function of all the instructions preceding the current instruction in the sequence of consecutive instructions, then - the verification of the integrity of the current instruction by comparing the signature constructed for the current instruction with a pre-recorded reference signature, then - only when the verification of the integrity of the current instruction is successful, the decryption of the cryptogram of the following instruction using the signature constructed for the current instruction.

12. Compiler capable of automatically transforming a source code of a computer program into a binary code comprising a machine code executable by a computer comprising a hardware instruction processing chain, this hardware processing chain comprising the following stages: an instruction loader, a decoder and an arithmetic and logic unit, this compiler comprising a programmable microprocessor (64) and a memory (66), characterized in that the compiler is capable of automatically transforming the source code into a machine code in accordance with claim 9.