Patent Publication Number: US-8527835-B2

Title: Method for secure data transfer

Description:
BACKGROUND OF THE INVENTION 
     The chip of a smart card typically contains a processor or microcontroller together with a volatile memory such as a random access memory (RAM), and a non-volatile memory such as a flash memory, an electrically erasable programmable read-only memory (EEPROM), or indeed a read-only memory (ROM). 
     The execution of an operation by software in the smart card requires numerous exchanges of data from the non-volatile memory to the volatile memory of the chip. Thus, any use that is made of data stored in the non-volatile memory requires a transfer to the volatile memory. 
     This applies when reading a file that might in particular contain data associated with a secret code in order to compare it with a value that is provided via an input, and when reading a key in order to perform a cryptographic calculation. 
     This also applies when reading a static table of constants stored in ROM, e.g. containing data representative of access rights to files recorded in the card. 
     This transfer stage, which takes place via a data bus in the chip, is sensitive to disturbances of an electromagnetic kind. There thus exists a fraudulent technique that consists in subjecting the card to a source of electromagnetic radiation while it is transferring data, thus enabling the fraudulent person to access data that should normally remain hidden. 
     By way of example, such disturbances may cause data to be modified while it is being transferred, in which case the data loaded into the volatile memory differs from the source data in the non-volatile memory. 
     This sensitivity offers the potential of fraudulently recovering a key or a secret code of the card, of bypassing access rights to files contained in the card, and/or of modifying configuration parameters of the card. 
     That is why measures are provided to detect such modifications in order to prevent an operation being executed in the event of such a modification being detected. 
     One method consists in verifying, after transfer, that the data as transferred is identical to the source data. The data may comprise some or all of an element, i.e. some or all of the data constituting one or more files. 
     Specifically, after transfer, it is verified that each byte of the element written in the volatile memory is identical to each byte of the source element, with this corresponding to an operation of the read and verification type. 
     That known method nevertheless remains ineffective against certain attacks. If an attacker knows how to disturb a transfer so as to modify the data copied into the non-volatile memory, and if the attacker knows how to reproduce the same disturbance during the read and verification operation, then the modification may pass undetected. 
     Under such circumstances, the read and verification operation does not detect an anomaly since it verifies only that data previously disturbed during copying was also disturbed during the read operation preceding verification. 
     OBJECT OF THE INVENTION 
     The object of the invention is to propose a solution for remedying the above-mentioned drawbacks by proposing a method that provides a better level of security in transferring data between the components of the chip. 
     SUMMARY OF THE INVENTION 
     To this end, the invention provides a method of comparing source data stored in a source memory of a smart card with transferred data copied from the source memory into a “destination” memory of the smart card, wherein an integrity value associated with a source element such as a file containing the source data is read from the source memory, wherein the integrity value is calculated for a reconstituted element corresponding to the source element, said element being reconstituted from the transferred data plus, where appropriate, any data in the source element other than the transferred data, and wherein it is decided that the transferred data is identical to the source data when the integrity calculation gives a value that is identical to the integrity value of the source element. 
     During copying, it is the source data that travels via the data bus, however during verification, it is the integrity value that travels via the data bus. The values traveling via the bus are therefore not the same during copying and during verification, such that an attack that consists in applying the same disturbances to the data bus during copying and during verification is completely ineffective. 
     The invention also provides a method as defined above, wherein the integrity value of the element containing the source data and the integrity value calculated for the reconstituted element are cyclic redundancy check values for the data. 
     The invention also provides a method as defined above, wherein a reference value distinct from the data for transfer is copied from the non-volatile memory to the volatile memory, said reference value being firstly pre-stored in the non-volatile memory and secondly pre-stored in read software of the smart card, and wherein the transferred value in the volatile memory is compared with the value stored in the read software to determine whether the transferred data is identical to the source data. 
     The invention also provides a method as defined above, wherein the reference value is copied while copying the source data. 
    
    
     
       BRIEF DESCRIPTION OF THE FIGURES 
       
           
           
             
                 FIG. 1  is a diagrammatic representation of a source element stored in a non-volatile source memory. 
                 FIG. 2  is a diagrammatic representation of transferring a portion of the data from the source element of  FIG. 1  to a volatile memory. 
                 FIG. 3  is a flow chart representing the steps of the method according to the invention. 
             
           
         
      
     
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The idea on which the invention is based is to proceed, after transfer, with a calculation concerning the integrity of the transferred data, in such a manner as to detect that a modification has occurred during transfer in the event that the value given by the integrity calculation based on the transferred data does not correspond to the integrity value associated with the source data. 
     The method applies to transferring some or all of the data from an element having its integrity value stored in source memory. 
     By way of example, the integrity value is a check sum of the data of the element under consideration, which element is generally a file. This integrity value may be of the longitudinal redundancy check (LRC) type, involving a cross-parity check, or it may be of the hash type. 
     This integrity value is advantageously a cyclic redundancy check (CRC) value, i.e. an integrity test that is specifically designed for detecting errors in data transmission. It may be constituted by a CRC 16  value corresponding to a cyclic redundancy check on 16 binary flags. 
     In the example below, the method comprises three steps for transferring data from a source element present in non-volatile memory, represented diagrammatically in  FIG. 1  where it is referenced ELEMENT_X_NV_MEM, and for verifying that the data as transferred is identical with the source data. 
     The integrity value PI_ELT_X for the entire element ELEMENT_X_NV_MEM is previously stored in the non-volatile memory, with this being done for example when this element was initially written into the non-volatile memory NV_MEM. 
     As shown diagrammatically in  FIG. 2 , some or all of the data in this source element ELEMENT_X_NV_MEM is initially copied from the non-volatile memory NV_MEM to the volatile VM_MEM. The data written in the destination memory, i.e. in the volatile memory, is referenced COPY_ELT_X_V_MEM. 
     Advantageously, correct copying of this data COPY_ELT_X_V_MEM is verified by comparing each copy byte with each corresponding byte in the source element ELEMENT_X_NV_MEM, thus constituting a read and verification operation. 
     The verification may be performed when a portion of the data has been transferred, in order to stop transfer before all of the data has been written in the volatile memory. 
     In a last stage, the integrity of the transferred data is verified. If it is all of the data in the source element ELEMENT_X_NV_MEM that has been written in the volatile memory, then this verification consists in calculating the integrity of the data written in the volatile memory, and in comparing the integrity value given by said calculation with the integrity value PI_ELT_X written in the non-volatile memory NV_MEM. 
     If the transferred data COPY_ELT_X_V_MEM corresponds to only some of the data constituting the element ELEMENT_X_NV_MEM, then the integrity is calculated of a reconstituted element. This element is reconstituted on the basis of the transferred data COPY_ELT_X_V_MEM having added thereto data that was not transferred from the element ELEMENT_X_NV_MEM, i.e. the shaded portions in  FIG. 2 . 
     This reconstituted element corresponds to the memory element ELEMENT_X_NV_MEM but comprising the transferred data COPY_ELT_X_V_MEM as written in the volatile memory V_MEM in association with the non-transferred data as written in the non-volatile memory NV_MEM. 
     When the data transfer has taken place normally, the source data written in the non-volatile memory NV_MEM is identical to the transferred data written in the volatile memory V_MEM. 
     Consequently, under normal circumstances, i.e. when the data is transferred without being modified, the integrity for the reconstituted element is identical to the integrity PI_ELT_X for the memory element ELEMENT_X_NV_MEM as written in the non-volatile memory. 
     In contrast, when the data has been modified during transfer, i.e. while it was being copied, the integrity calculated for the reconstituted element gives a value that differs from PI_ELT_X, thus making it possible to detect this anomaly or modification. 
     As mentioned above, the read and verification step is optional, insofar as it is not effective against a disturbance applied to the transfer bus identically during copying and during the read and verification operation. Nevertheless, this step makes it possible to detect as early as possible any brief disturbance to which the data bus might be subjected, so as to stop the process as early as possible in the event of an anomaly. 
     The method of the invention thus makes it possible to detect a disturbance applied to the data bus: since it includes verification by an integrity check, the data transferred for this verification, i.e. the value PI_ELT_X is not the same as the data transferred for copying. An attack that consists in applying the same disturbances to the bus during copying and during verification is therefore completely ineffective. 
     The method may also be associated with a “false read” operation performed during the copying of the source data from the non-volatile memory NV_MEM to the volatile memory V_MEM. Under such circumstances, a predetermined reference value, written VR_NV_MEM, is provided that is pre-stored in the non-volatile memory throughout the lifetime of the card, and that is also incorporated in the code of the card&#39;s reader program. This value corresponds for example to one data byte. 
     Prior to making the copy, a rank, written i, is determined randomly for the false read. 
     The copying operation is then launched, beginning with the initial bytes from the source data ELEMENT_X_NV_MEM that are transferred one after another to the volatile memory. 
     However, the i th  byte to be transferred is the “false read” byte, i.e. the byte corresponding to the reference value VR_NV_MEM. Once this byte has been transferred, copying continues as normal, transferring successively the i th  byte from the source data ELEMENT_X_NV_MEM, and then the following bytes. 
     Once the false read byte has been written in the volatile memory VR_V_MEM, it may be compared with the value that is incorporated in the card&#39;s read program, which value is necessarily identical to VR_NV_MEM. This makes it possible to detect certain disturbances that might occur during transfer. 
     This additional mechanism enables certain types of disturbance to be detected sooner than they would have been detected by the integrity check. Indeed, by means of this mechanism, disturbances can be detected before the end of data being copied into the volatile memory, with this consequently being more reliable since the transfer may be stopped immediately, i.e. before reaching the end of data copying to the volatile memory. 
     It should also be observed that in the above-described example, the optional read and comparison step takes place before the step of checking the integrity of the transferred data. However this optional step may also be implemented after the step of checking the integrity, insofar as it makes it possible, under certain circumstances, to detect errors that are not detected by the integrity value. 
     The invention provides various advantages since it makes it possible to combat effectively an attack by disturbing the data bus, and it is inexpensive in terms of execution time. Finally, it does not require additional data to be stored in the memory(ies) of the smart card.