# US 2021/0173946 A1 · Method for executing a computer program by means of an electronic apparatus

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0173946 A1
- Document ID: US20210173946A1
- Status: Published application
- Kind: A1
- Application number: 17/109,424
- Filed: 2020-12-02
- Published: 2021-06-10
- Earliest claimed: 2019-12-04
- Assignees: Commissariat A L'energie Atomique Et Aux Energies Alternatives
- Applicants: Commissariat a l'Energie Atomique et aux Energies Alternatives
- Inventors: Olivier SAVRY; Thomas HISCOCK
- Web page: https://patentgrep.com/patent/US20210173946A1

## CPC

- G06F 21/602: {Providing cryptographic facilities or services}
- H04L 9/0637: {Modes of operation, e.g. cipher block chaining [CBC], electronic codebook [ECB] or Galois/counter mode [GCM]}
- G06F 12/1408: {by using cryptography (for digital transmission H04L9/00)}
- G06F 21/31: User authentication
- G06F 21/64: Protecting data integrity, e.g. using checksums, certificates or signatures
- G06F 21/78: to assure secure storage of data (address-based protection against unauthorised use of memory G06F12/14; record carriers for use with machines and with at least a part designed to carry digital markings G06K19/00)
- G06F 21/79: in semiconductor storage media, e.g. directly-addressable memories
- G09C 1/00: Apparatus or methods whereby a given sequence of signs, e.g. an intelligible text, is transformed into an unintelligible sequence of signs by transposing the signs or groups of signs or by replacing them by others according to a predetermined system (cryptographic typewriters G09C3/00)
- H04L 9/3242: {involving keyed hash functions, e.g. message authentication codes [MACs], CBC-MAC or HMAC}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)
- G09C: CIPHERING OR DECIPHERING APPARATUS FOR CRYPTOGRAPHIC OR OTHER PURPOSES INVOLVING THE NEED FOR SECRECY

## Abstract

A method for executing a computer program, wherein when a microprocessor writes a block of No bytes of a datum of a block of cleartext data stored in an unencrypted memory, a security module switches a validity indicator associated with this block of No bytes to an active state wherein it indicates that this block of bytes is valid, and each time a block of No bytes of a datum of the block of cleartext data is loaded by the microprocessor from the unencrypted memory, the hardware security module verifies whether the validity indicator associated with this block of No bytes is in its active state and, if such is the case, processing, by the microprocessor, of this block of No bytes is permitted, and, if such is not the case, processing, by the microprocessor, of this block of No bytes is forbidden.

## Claims

### Claim 1

A method for executing a computer program with an electronic apparatus comprising a microprocessor, an unencrypted memory, an encrypted memory and a hardware security module, wherein, during the execution of the computer program, the transfer of data between the unencrypted memory and the encrypted memory is carried out in entire blocks of a plurality of encrypted and authenticated data, each datum being composed of one or more blocks of No bytes, where No is equal to the lowest number of bytes that can be written, independently of the other bytes of the datum, by the microprocessor when it executes a write instruction of its instruction set architecture, the method comprising:
a) during the transfer of a block of cleartext data from the unencrypted memory to the encrypted memory:
converting the block of cleartext data into a block of encrypted and authenticated data, said conversion comprising:
encrypting the block of cleartext data to obtain a cryptogram of said block of cleartext data, said cryptogram being able to be decrypted solely in its entirety and not datum by datum,
computing an authentication code using the data of the block of cleartext data or using the cryptogram of said block of cleartext data, and
grouping, in the same block, the obtained cryptogram, the computed authentication code and metadata to obtain the block of encrypted and authenticated data, then
storing the obtained block of encrypted and authenticated data in the encrypted memory,
b) during the transfer of a block of encrypted and authenticated data from the encrypted memory to the unencrypted memory:
verifying the integrity of the block of cleartext data or of the cryptogram of the block of cleartext data using the authentication code contained in said block of encrypted and authenticated data,
when said verification fails, inhibiting processing, by the microprocessor, of the data of said block of data, and
when said verification succeeds:
decrypting the cryptogram contained in the block of encrypted and authenticated data to obtain the block of cleartext data,
storing the obtained block of cleartext data in the unencrypted memory and storing the metadata of the block of encrypted and authenticated data in a register that is not addressable by the microprocessor,
wherein the method comprises:
incorporating, into the metadata of each block of data and for each block of No bytes of each datum of said block of data, a validity indicator associated with said block of No bytes, said validity indicator being switchable between:
an active state, in which said validity indicator indicates that said block of bytes is valid, and
an inactive state, in which said validity indicator indicates that said block of bytes is invalid,
at least certain of the validity indicators initially being in their inactive state,
when the microprocessor writes a block of No bytes of a datum of the block of cleartext data stored in the unencrypted memory, the security module switches the validity indicator associated with said block of No bytes to its active state,
each time a block of No bytes of a datum of the block of cleartext data is loaded by the microprocessor from the unencrypted memory, the hardware security module verifies whether the validity indicator associated with said block of No bytes is in its active state and, if such is the case, processing, by the microprocessor, of said block of No bytes is permitted, and, if such is not the case, processing, by the microprocessor, of said block of No bytes is forbidden.

### Claim 2 (depends on 1)

The method as claimed in claim 1, wherein, during the computation of the authentication code, the authentication code is also computed using validity indicators associated with each group of No bytes of each datum of the block of cleartext data.

### Claim 3 (depends on 1)

The method as claimed in claim 1, wherein:
during the encryption of the cleartext data, the cleartext data are encrypted using a cryptographic key and an initialization vector, the cryptographic key used being the same on each transfer of a block of cleartext data from the unencrypted memory to the encrypted memory and the initialization vector being modified on each transfer of a block of cleartext data from the unencrypted memory to the encrypted memory, and
the initialization vector used to obtain the cryptogram of said block of data is incorporated into the metadata of the block of encrypted and authenticated data, and
during the decryption of the data, the hardware security module extracts from the metadata of the block of encrypted and authenticated data, the initialization vector to be used to carry out said decryption.

### Claim 4 (depends on 1)

The method as claimed in claim 1, wherein each block of encrypted and authenticated data is stored at an address @BDCi equal to @BDi·Tb/TBD,
where:
@BDi is the physical address of the start, in the unencrypted memory, of the block of cleartext data obtained by decrypting the cryptogram of said block of encrypted and authenticated data,
Tb is the size, in number of bytes, of the block of encrypted and authenticated data,
TBD is the size, in number of bytes, of the block of cleartext data.

### Claim 5 (depends on 4)

The method as claimed in claim 4, wherein:
each datum is associated, via a one-to-one relationship, with one physical address and each block of cleartext data contains only the Nd data associated, via said one-to-one relationship, with physical addresses contained in a respective and continuous range of Nd consecutive physical addresses, and the address @BDi of the start of said block of cleartext data is equal to the lowest physical address of said range of Nd physical addresses,
during the execution of the computer program, the microprocessor executes an instruction to access at least one block of No bytes of a first datum associated with a physical address @Di,j, said first datum belonging to none of the blocks of cleartext data currently stored in the unencrypted memory at the moment of the execution of said access instruction,
in response, the hardware security module computes an address @BDCi equal to E(@Di,j/TBD)·Tb, where
E( ) is the function that returns the integer part of the number located between the parentheses, and
@BDCi is the address of the start, in the encrypted memory, of the block of encrypted and authenticated data that contains the first datum, then
the block of encrypted and authenticated data that starts at the computed address @BDCi is transferred from the encrypted memory to the unencrypted memory so as to store, in the unencrypted memory, a new block of cleartext data that contains the first datum, then
said at least one block of No bytes is accessed using the first datum contained in said new block of cleartext data.

### Claim 6 (depends on 5)

The method as claimed in claim 5, wherein:
Tb and TBD are both powers of two and the address @BDCi is computed using the following first relationship @BDCi=E(@Di,j/TBD)·Tb, or
(Tb−TBD) and TBD are both powers of two and the address @BDCi is computed Using the following second relationship @BDCi=E(@Di,j/TBD)·TBD+E(@Di,j/TBD)·(Tb−TBD), and
each division and each multiplication of the first and second relationships are executed by shift registers of the hardware security module.

### Claim 7 (depends on 1)

The method as claimed in claim 1, wherein, when the verification of the integrity of the block of cleartext data or of the cryptogram of the block of cleartext data fails:
a virgin block of cleartext data is prepared and stored in the unencrypted memory in the same location as that where the block of cleartext data would have been stored if the verification of the integrity had succeeded, the data of said virgin block all being initialized to a preset value, and
the validity indicators associated with each of the blocks of No bytes of the virgin block are switched to their inactive state.

### Claim 8 (depends on 1)

A binary code able to be executed by a microprocessor by implementing a method as claimed in claim 1, wherein the binary code comprises blocks of encrypted and authenticated data, each block of encrypted and authenticated data containing:
a cryptogram of a block of cleartext data, said cryptogram being able to be decrypted solely in its entirety and not datum by datum,
an authentication code computed using the data of the block of cleartext data or using the cryptogram of the block of cleartext data,
metadata,
wherein the metadata comprise, for each block of No bytes of each datum of the block of cleartext data, a validity indicator associated with said block of No bytes, said validity indicator being switchable between:
an active state, in which said validity indicator indicates that said block of No bytes is valid, and
an inactive state, in which said validity indicator indicates that said block of No bytes is invalid.

### Claim 9 (depends on 1)

A hardware security module for implementing a method as claimed in claim 1, wherein the hardware module is configured to:
a) during the transfer of a block of cleartext data from the unencrypted memory to the encrypted memory:
convert the block of cleartext data into a block of encrypted and authenticated data, said conversion comprising:
encrypting the block of cleartext data to obtain a cryptogram of said block of cleartext data, said cryptogram being able to be decrypted solely in its entirety and not datum by datum,
computing an authentication code on the basis of the data of the block of cleartext data or on the basis of the cryptogram of the block of cleartext data, and
grouping, in the same block, the obtained cryptogram, the computed authentication code and metadata to obtain the block of encrypted and authenticated data, then
storing the obtained block of encrypted and authenticated data in the encrypted memory,
b) during the transfer of a block of encrypted and authenticated data from the encrypted memory to the unencrypted memory:
verify the integrity of the block of cleartext data or of the cryptogram of the block of cleartext data using the authentication code contained in said block of encrypted and authenticated data,
when said verification fails, inhibit processing, by the microprocessor, of the data of said block of data, and
when said verification succeeds:
decrypt the cryptogram contained in the block of encrypted and authenticated data to obtain the block of cleartext data,
store the obtained block of cleartext data in the unencrypted memory and store the metadata of the block of encrypted and authenticated data in a register that is not addressable by the microprocessor,
wherein:
when the microprocessor modifies a block of No bytes of a datum of the block of cleartext data stored in the unencrypted memory, the security module is configured to switch the validity indicator associated with said block of No bytes to its active state, and
each time a block of No bytes of a datum of the block of cleartext data is loaded by the microprocessor from the unencrypted memory, the hardware security module is configured to verify whether the validity indicator associated with said block of No bytes is in its active state and, if such is the case, processing, by the microprocessor, of said block of No bytes is permitted, and, if such is not the case, processing, by the microprocessor, of said block of No bytes is forbidden.

### Claim 10 (depends on 8)

A compiler able to automatically convert a source code of a computer program into a binary code of said computer program, wherein the compiler is able to automatically convert the source code into a binary code as claimed in claim 8, said compiler being configured to said end to automatically convert blocks of cleartext data into blocks of encrypted and authenticated data, and, to do this, said compiler is able, for each block of cleartext data:
to encrypt the block of cleartext data to obtain a cryptogram of said block of cleartext data, said cryptogram being able to be decrypted solely in its entirety and not datum by datum,
to compute an authentication code using the data of the block of cleartext data or using the cryptogram of said block of cleartext data, and
to group, in the same block, the obtained cryptogram, the computed authentication code and metadata to obtain the block of encrypted and authenticated data,
wherein the compiler is also configured to incorporate, into the metadata of each block of data and for each block of No bytes of each datum of said block of data, a validity indicator associated with said block of No bytes, said validity indicator being switchable between:
an active state, in which said validity indicator indicates that said block of bytes is valid, and
an inactive state, in which said validity indicator indicates that said block of bytes is invalid,
at least certain of the validity indicators initially being in their inactive state.
