A copy-proof RFID smart card initialization and dynamic encryption method and system

By introducing encryption factors and dynamic access addresses into RFID smart cards, the problem of batch replication after the key is cracked is solved, and the effect of significantly enhancing security while reducing deployment costs.

CN119272260BActive Publication Date: 2025-03-04SHENZHEN CARD SMART TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411803858.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-03-04
Estimated Expiration
2044-12-10

AI Technical Summary

Technical Problem

The prior art is difficult to effectively avoid batch copying after the key is cracked while reducing deployment costs, especially in the application scenarios of Mifare 1K cards.

Method used

By introducing encryption factors and dynamic access addresses, an anti-copy-proof RFID smart card initialization and dynamic encryption method is provided. The method includes obtaining a preset initial encryption factor, writing it into the preset sector, and obtaining a unique identifier of the RFID smart card. According to the encryption function, the unique identifier and the initial encryption factor are encrypted to determine the initial sector address and initial key for the card number data storage. The dynamic encryption method includes reading the real-time encryption factor, comparing it with the initial encryption factor, if the same is, it is the first card swiping, obtaining a unique identifier, generating the first key and sector address according to the encryption function, reading the card number data, updating the target encryption factor and key, and dynamically changing the storage location of the card number data.

Benefits of technology

By changing the encryption factor and dynamically adjusting the access address every time you swipe the card, it effectively prevents batch copying of the key after being cracked, enhances the security of the RFID smart card, ensures that the access rights of legitimate users are not tampered with or imitated by illegal cards, and reduces the cost of hardware deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119272260B_ABST
    Figure CN119272260B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of RFID smart cards, solves the problem in the prior art that it is impossible to effectively avoid the occurrence of batch duplication after the key is cracked while reducing the deployment cost, and provides an anti-copy RFID smart card initialization and dynamic encryption method and system. The method includes: comparing the real-time encryption factor and the initial encryption factor; if they are the same, obtaining a unique identifier; processing the real-time encryption factor and the unique identifier according to a first encryption function to obtain a first key and a first sector address; processing the first sector address and the unique identifier according to a second encryption function to determine a target encryption factor; writing the target encryption factor into a sector, processing the target encryption factor and the unique identifier according to the first encryption function to determine a second key and a second sector address; and writing the card number data into the sector where the second sector address is located. The present invention can effectively avoid the occurrence of batch duplication after the key is cracked.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of RFID smart cards, and in particular to an anti-copying RFID smart card initialization and dynamic encryption method and system. Background Art

[0002] At present, RFID smart cards based on Mifare 1K have been widely used in various access control systems, public transportation payment systems, campus cards and other application scenarios due to their low cost and basic security. The storage space of Mifare 1K cards is divided into 16 sectors, each sector has 4 blocks, and the length of each block is 16 bytes. The last block of each sector is used to store the key of the sector, and the key is used to control the external read and write permissions of the sector. The traditional application form is to assign one or more sectors to a specific application. For example, the access control system uses sector 2 to store the application data of this system, and ensures secure access to the data by setting a specific key.

[0003] However, as the encryption algorithm of Mifare 1K is cracked, the keys of applications such as access control systems can be easily obtained by attackers through simple and cheap tools, which greatly reduces the security of the system. Attackers can copy RFID smart cards and perform illegal card swiping operations to obtain improper access rights, causing potential security risks. This problem makes Mifare 1K cards pose a greater risk in some application scenarios with high security requirements, especially when the card key is cracked, the security of the entire system is almost completely destroyed.

[0004] In order to improve the security of RFID smart cards, existing solutions are mainly implemented by upgrading to chips with higher security levels, such as CPU cards. However, although these chips with higher security levels can effectively resist cracking and copying attacks, their high cost leads to a significant increase in the deployment and maintenance costs of the entire application system. This makes many application scenarios, such as access control systems and parking lot management, face the difficult trade-off between cost and security.

[0005] The existing Chinese patent CN106529651A discloses a radio frequency card using a double encryption algorithm. The radio frequency card uses double encryption. The first encryption method is: using encryption key 1, encrypting the card ID number through encryption algorithm 1 to obtain the card reading and writing password, the password is 32 bits, and the 32-bit password is written into the storage block block7; the second encryption method is: using encryption key 2 different from the first encryption key, obtaining a data password through encryption algorithm 2, and encrypting the user data into exchange data through the data password and then writing it into the card data storage blocks block1-block6. Although the above patent encrypts the read and write passwords through the ID number of the radio frequency card, and the password of each card is generated based on the unique ID number, so the password of each card is different, the encryption of the card ID number is static in nature, that is, once the ID number is cracked or leaked, the attacker can deduce the corresponding password based on the ID of the card; if the attacker obtains the ID number of a certain card and related information of encryption algorithm 1, such as key 1 and encryption algorithm, he can use the same algorithm to crack it, thereby avoiding password reset or additional encryption steps when copying in batches.

[0006] Therefore, how to reduce the deployment cost while effectively avoiding the mass duplication of keys after they are cracked is an urgent problem to be solved. Summary of the invention

[0007] In view of this, the present invention provides an anti-copying RFID smart card initialization and dynamic encryption method and system to solve the problem in the prior art that it is impossible to effectively avoid batch copying after the key is cracked while reducing the deployment cost.

[0008] The technical solution adopted by the present invention is:

[0009] In a first aspect, the present invention provides a method for initializing an anti-copying RFID smart card, wherein the RFID smart card includes a plurality of sectors, wherein the sectors are used to store and access encryption factors or card number data, wherein each sector includes a key block, wherein the key block is used to store and access a key for accessing the sector, wherein the encryption factor is an encrypted string, and is used to calculate a sector address for accessing the card number data, wherein the method includes:

[0010] Obtain a preset initial encryption factor;

[0011] Writing the initial encryption factor into a preset sector and obtaining a unique identifier of the RFID smart card;

[0012] According to the first encryption function, the unique identifier and the initial encryption factor in the preset sector are encrypted to determine the initial sector address and initial key where the card number data is stored.

[0013] Preferably, the step of encrypting the unique identifier and the initial encryption factor in the preset sector according to the first encryption function to determine the initial sector address and the initial key for storing the card number data comprises:

[0014] Performing an XOR operation on the unique identifier and the initial encryption factor to determine a first character string;

[0015] Performing an XOR operation on the character at the first preset position in the unique identifier and the character at the second preset position in the initial encryption factor to determine a second character string;

[0016] Combining the first character string and the second character string to determine the initial key;

[0017] Performing an XOR operation on the character at the third preset position in the unique identifier and the character at the third preset position in the initial encryption factor to determine a third character string;

[0018] The initial sector address is determined according to the third character string.

[0019] In a second aspect, the present invention provides a dynamic encryption method for an anti-copying RFID smart card, wherein the RFID smart card is initialized by the initialization method of the RFID smart card as described above, and the dynamic encryption method comprises:

[0020] Reading the real-time encryption factor in the preset sector, and comparing the real-time encryption factor with the initial encryption factor;

[0021] If the initial encryption factor is the same as the real-time encryption factor, it is the first time to swipe the card, and the unique identifier of the RFID smart card is obtained;

[0022] According to the first encryption function, the real-time encryption factor and the unique identifier are encrypted to obtain a first sector address for accessing a first key and card number data;

[0023] Reading the card number data according to the first key and the first sector address;

[0024] When the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function to determine a new target encryption factor;

[0025] Writing the target encryption factor into the sector where the real-time encryption factor is located, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining the second sector address where the second key and the card number data are stored;

[0026] The card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address.

[0027] Preferably, after reading the real-time encryption factor and comparing the real-time encryption factor with the initial encryption factor, the method further comprises:

[0028] If the initial encryption factor is different from the real-time encryption factor, the real-time encryption factor is compared with the historical encryption factor, and the unique identifier of the current RFID smart card is compared with the historical identifier;

[0029] When the real-time encryption factor is the same as the historical encryption factor and the unique identifier is the same as the historical identifier, encrypting the real-time encryption factor and the unique identifier according to a first encryption function to obtain a first sector address where a first key and card number data are stored;

[0030] Reading the card number data according to the first key and the first sector address;

[0031] When the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function to determine a new target encryption factor;

[0032] Replacing the original historical encryption factor with the target encryption factor, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining a second sector address where a second key and card number data are stored;

[0033] The card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address.

[0034] Preferably, when the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function, and determining a new target encryption factor comprises:

[0035] performing multiplication calculation on the first sector address and the unique identifier to determine a fourth character string;

[0036] The characters at the fourth preset position in the fourth character string are extracted, and the extraction result is used as the target encryption factor.

[0037] Preferably, after completely copying the RFID smart card, the following steps are included:

[0038] reading the copy data on the copy card, wherein the copy data includes a first copy encryption factor and a copy identifier;

[0039] Compare the copied data with the historical data in the card reader, if the copied data is consistent with the historical data, the first swipe of the copied card passes the verification, wherein the historical data includes the target encryption factor and the unique identifier;

[0040] According to a first encryption function, the first copy encryption factor and the copy identifier are encrypted to determine a copy sector address for accessing the copy key and the card number data;

[0041] Reading the card number data according to the duplicate key and the duplicate sector address;

[0042] When the card number data is successfully read, the copy identifier and the copy sector address are encrypted according to a second encryption function, a second copy encryption factor is determined, and the target encryption factor is replaced with the second copy encryption factor;

[0043] When a legitimate original RFID smart card is swiped, the target encryption factor is compared with the second duplicate encryption factor to determine that the original RFID smart card is an illegal card.

[0044] Preferably, after replacing the original historical encryption factor with the target encryption factor, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining the second sector address where the second key and the card number data are stored, the method further includes:

[0045] According to the second sector address, obtaining a target read frequency of the sector corresponding to the second sector address, and obtaining read frequencies and preset frequency thresholds corresponding to the remaining sectors respectively;

[0046] Calculating an average value of the reading frequencies of each sector according to the target reading frequency and the reading frequencies corresponding to the remaining sectors;

[0047] If the target reading frequency is less than the average value and the target reading frequency is less than the frequency threshold, the card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address;

[0048] If the target reading frequency is greater than or equal to the average value and / or the target reading frequency is greater than or equal to the frequency threshold, the second sector address is updated by a hash function and a pseudo-random algorithm to determine a third sector address where the card number data is stored;

[0049] The card number data at the first sector address is deleted, and according to the third sector address, the card number data is written into a new sector corresponding to the third sector address.

[0050] Preferably, if the target reading frequency is greater than or equal to the average value or the target reading frequency is greater than or equal to the frequency threshold, the second sector address is updated by a hash function and a pseudo-random algorithm to determine the third sector address where the card number data is stored, including:

[0051] Combining the unique identifier and the target encryption factor to determine a target character string;

[0052] Processing the target string through a hash function to determine a hash value;

[0053] Performing standardization processing on the hash value to convert the hash value into a hash integer value;

[0054] According to the hash integer value and a preset sector address interval, the hash integer value is mapped to the sector address interval to determine a target sector address;

[0055] The third sector address is determined according to the hash integer value, the first sector address, the sector address interval and the target sector address in combination with the pseudo-random number generation algorithm.

[0056] Preferably, determining the third sector address according to the hash integer value, the first sector address, the sector address interval and the target sector address in combination with the pseudo-random number generation algorithm comprises:

[0057] Initializing a preset pseudo-random number generator according to the hash integer value;

[0058] Inputting the first sector address into the initialized pseudo-random number generator to determine a pseudo-random number;

[0059] According to the sector address interval, performing modulo processing on the pseudo-random number to determine an offset, wherein the offset is within the sector address interval;

[0060] The offset and the target sector address are added and modulo processed to determine the third sector address.

[0061] In a third aspect, an embodiment of the present invention further provides an anti-copying RFID smart card initialization and dynamic encryption system, wherein the dynamic encryption system comprises an RFID smart card and a card reader, wherein the RFID smart card is initialized by the RFID smart card initialization method as described above, and the card reader dynamically encrypts the RFID smart card by the RFID smart card dynamic encryption method as described above.

[0062] In summary, the beneficial effects of the present invention are as follows:

[0063] The present invention provides an anti-copying RFID smart card initialization and dynamic encryption method and system, the method comprising: reading the real-time encryption factor in the preset sector, comparing the real-time encryption factor with the initial encryption factor; if the initial encryption factor is the same as the real-time encryption factor, it is the first time to swipe the card, and obtaining the unique identifier of the RFID smart card; encrypting the real-time encryption factor and the unique identifier according to the first encryption function, and obtaining the first sector address for accessing the first key and card number data; reading the card number data according to the first key and the first sector address; when the card number data is successfully read, encrypting the first sector address and the unique identifier according to the second encryption function, and determining a new target encryption factor; writing the target encryption factor into the sector where the real-time encryption factor is located, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining the second sector address where the second key and card number data are stored; deleting the card number data at the first sector address, and writing the card number data into a new sector corresponding to the second sector address according to the second sector address. On the one hand, the present invention effectively solves the problem of batch duplication after the RFID smart card key is cracked by introducing the mechanism of encryption factor and dynamic access address. In this solution, the encryption factor of each card will change each time the card is swiped, causing the sector address and key for accessing the card number to change accordingly. Even if the copied card successfully swipes the card by copying the UID and key of the legitimate card, the sector address for accessing the card number will no longer match the encryption factor when the card is swiped the next time, causing the copied card to be unable to access the legitimate data stored in the new location, thereby rendering it invalid. In addition, since the key and storage address of each card are based on the UID and key, the sector address for accessing the card number will no longer match the encryption factor. The dynamic calculation result of the encryption factor means that the encryption method of each card is different, which means that even if an attacker cracks the key of a certain card, he still cannot copy other cards in batches, because each card has an independent access address and key. Through this dynamic encryption and address change design, the long-term use of copied cards is effectively prevented, and the security risks caused by batch copying are avoided, thereby significantly enhancing security and ensuring that the access rights of legitimate users are not tampered with or imitated by illegal cards; on the other hand, since the present invention does not need to configure a physical key for each card separately, but generates a dynamic key and storage address through an algorithm, the hardware deployment cost is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings required for use in the embodiment of the present invention will be briefly introduced below. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work, and these are all within the protection scope of the present invention.

[0065] Figure 1It is a schematic diagram of the overall working process of the anti-copying RFID smart card initialization method in Example 1 of the present invention;

[0066] Figure 2 This is a schematic diagram of a process for determining an initial sector address and an initial key for storing card number data in Embodiment 1 of the present invention;

[0067] Figure 3 This is a schematic diagram of the overall working process when a legitimate card is swiped for the first time in Example 2 of the present invention;

[0068] Figure 4 This is a schematic diagram of the overall working process when a legitimate card is subsequently swiped in Embodiment 2 of the present invention;

[0069] Figure 5 This is a schematic diagram of a process for determining a new target encryption factor in Embodiment 2 of the present invention;

[0070] Figure 6 This is a schematic diagram of the overall working process when swiping a duplicate card in Embodiment 2 of the present invention;

[0071] Figure 7 It is a flow chart of determining the sector address for accessing the card number data according to the reading frequency of each sector in Embodiment 2 of the present invention;

[0072] Figure 8 This is a flow chart of updating the second sector address and determining the third sector address where the card number data is stored by using a hash function and a pseudo-random algorithm in Embodiment 2 of the present invention;

[0073] Fig. 9 A schematic diagram of a process for determining the third sector address according to the hash integer value, the first sector address, the sector address interval and the target sector address in combination with the pseudo-random number generation algorithm in Embodiment 2 of the present invention;

[0074] Fig.10 This is a schematic diagram of the structure of the anti-copying RFID smart card initialization and dynamic encryption system in Example 3 of the present invention. DETAILED DESCRIPTION

[0075] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described in conjunction with the drawings in the embodiment of the present invention. It should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. In the description of the present invention, it should be understood that the orientation or position relationship indicated by the terms "center", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such a process, method, article or device. In the absence of further restrictions, the elements defined by the phrase "comprising..." do not exclude the existence of other identical elements in the process, method, article or device comprising the elements. If there is no conflict, the embodiments of the present invention and the various features in the embodiments can be combined with each other, all within the protection scope of the present invention.

[0076] Example 1

[0077] See also Figure 1Embodiment 1 of the present invention discloses an anti-copying RFID smart card initialization method, wherein the RFID smart card includes a plurality of sectors, wherein the sectors are used to store and access encryption factors or card number data, wherein each sector includes a key block, wherein the key block is used to store and access a key for accessing the sector, wherein the encryption factor is an encrypted string, and is used to calculate a sector address for accessing the card number data; specifically, the RFID smart card includes a plurality of sectors, wherein the key block is the last block of each sector, and is used to store key information required for accessing the current sector, and each key block can store two groups of keys, namely KeyA and KeyB, and the length of each group of keys is 6 bytes, so as to ensure that data access to a specific sector is controlled. Some sectors are used to store encryption factors, which are random strings generated by encryption algorithms. The length of the string can be selected between 1 and 16 bytes according to requirements. The main function of the encryption factor is to dynamically calculate the access sector address of the card number data according to the algorithm, so that the access location of the card number data changes continuously to ensure the security of access; some sectors are used to store card number data. The sectors where the card number data is accessed and the sectors where the encryption factor is accessed can be the same or different. The card number data is fixed content and is used for the authentication control process in the access control system or other applications. The sector key where the card number data is located is encrypted in a one-card-one-key manner, that is, the sector where the card number data of each card is located uses a unique encryption key to ensure security. According to design requirements, the encryption factor will be regenerated and stored in the sector each time the card is swiped, and the new card number data access sector address will be calculated by the algorithm to ensure the dynamic change of the card number access location, effectively preventing the data from being easily cracked and copied.

[0078] The method comprises:

[0079] Obtain a preset initial encryption factor;

[0080] Specifically, during the initialization phase of the RFID smart card, in order to ensure the consistency and security of the card's encryption process, a default initial encryption factor is preset. The initial encryption factor is a fixed string of characters, such as 16 Fs, which is used as the initial encryption basis. The encryption factor is equivalent to a default security mark, which provides a baseline encryption value for encryption calculations when the card is first activated. It ensures the consistency of the initial encryption environment and an encryption starting point that is easy to operate.

[0081] Writing the initial encryption factor into a preset sector and obtaining a unique identifier of the RFID smart card;

[0082] Specifically, before writing the initial encryption factor, a sector address is designated, such as the first block of the 0th sector as the encryption factor access area, and the initial encryption factor is written into the sector. The encryption factor access location is fixed in each card, ensuring that the factor can be quickly located and accessed in any read-write device. At the same time, the unique identifier of the RFID smart card is obtained. The unique identifier is a unique serial number at the hardware level. The unique identifier is combined with the initial encryption factor during the encryption process of the RFID smart card, which enhances the anti-copying and security of the card.

[0083] According to the first encryption function, the unique identifier and the initial encryption factor in the preset sector are encrypted to determine the initial sector address and initial key where the card number data is stored.

[0084] Specifically, the first encryption function is called to combine the UID of the card and the initial encryption factor in the preset sector. The design of the first encryption function supports multiple encryption algorithms, such as DES or AES, to generate a dedicated initial key and the initial sector address for accessing the card number data. The first encryption function will first use the UID and the initial encryption factor as input parameters, perform encryption operations such as XOR operation and hash generation, and generate a 6-byte initial key to protect the read and write permissions of the card number data; at the same time, the first encryption function calculates the storage sector address of the card number data based on the UID and the encryption factor. This method improves the anti-cracking ability of each RFID smart card.

[0085] In one embodiment, see Figure 2 , the encrypting process of the unique identifier and the initial encryption factor in the preset sector according to the first encryption function to determine the initial sector address and the initial key for storing the card number data comprises:

[0086] Performing an XOR operation on the unique identifier and the initial encryption factor to determine a first character string;

[0087] Specifically, in the first step of the encryption process, in order to generate intermediate data for card encryption, the unique identifier UID of the RFID smart card and the initial encryption factor are XORed. This operation compares and converts each bit of the unique identifier UID and the encryption factor bit by bit to output a new string, namely the first string S1, which serves as the basis for subsequent key calculation; for example, assuming that the UID is 0x1A2B3C4D and the initial encryption factor is 0x1F2F3F4F, then 0x1A2B3C4D and 0x1F2F3F4F are XORed, namely S1=0x1A2B3C4D xor 0x1F2F3F4F=0x05040302, and the calculation result is obtained, namely the first string 0x05040302.

[0088] Performing an XOR operation on the character at the first preset position in the unique identifier and the character at the second preset position in the initial encryption factor to determine a second character string;

[0089] Specifically, in order to further improve the security of key generation, the character extracted from the first preset position in the unique identifier is XORed with the character extracted from the second preset position in the initial encryption factor to generate the second character string S2. For example, the first two characters 0x1A2B are extracted from the UID, i.e., 0x1A2B3C4D, and the last two bytes 0x3F4F are extracted from the initial encryption factor, i.e., 0x1F2F3F4F, and XORed, i.e., S2=0x1A2B xor 0x3F4F=0x2564, and the result 0x2564 obtained by this XOR operation is used as the second character string.

[0090] Combining the first character string and the second character string to determine the initial key;

[0091] Specifically, the first character string S1 and the second character string S2 are combined in sequence to generate an initial key S3; for example, the first character string is placed in front and the second character string is placed in the back to form an initial key S3 of 0x050403022564, with a length of 6 bytes, which meets the key requirements of the Mifare 1K card. The combined initial key S3 is used to encrypt and control the read and write access rights of the sector. Since the initial key S3 is related to the UID and the initial encryption factor of the RFID smart card, the unpredictability of the initial key greatly enhances the security of the card and effectively prevents unauthorized access.

[0092] Performing an XOR operation on the character at the third preset position in the unique identifier and the character at the third preset position in the initial encryption factor to determine a third character string;

[0093] Specifically, the characters at the third preset position are extracted from the UID and the initial encryption factor respectively, and an XOR operation is performed to generate a third character string SecAdr, which is used to determine the specific sector address for accessing the card number data. For example, assuming that the first byte of the UID is 0x1A and the first byte of the encryption factor is 0x1F, an XOR operation is performed to obtain the third character string 0x05. Through this operation, the generated third character string SecAdr is used as the basis for the sector address for subsequent access to the card number data, ensuring the dynamic change and uniqueness of the sector address for accessing the card number data.

[0094] The initial sector address is determined according to the third character string.

[0095] Specifically, the specific position of the initial sector address is determined according to the last bit of the third character string. If the last bit of SecAdr is 0, the initial sector address is set to 15 to avoid the special state of address 0; for example, if the current SecAdr calculation result is 0x05, the card number data will be stored in the 5th sector. By dynamically allocating sector addresses, the fixed storage of the card number data is effectively prevented, further improving the security and anti-cracking capabilities of the card.

[0096] Example 2

[0097] See also Figure 3 Embodiment 2 of the present invention discloses a dynamic encryption method for an anti-copying RFID smart card. The RFID smart card is initialized by the initialization method of the RFID smart card described in Embodiment 1. The dynamic encryption method includes:

[0098] Reading the real-time encryption factor in the preset sector, and comparing the real-time encryption factor with the initial encryption factor;

[0099] Specifically, when the RFID smart card enters the radio frequency signal range of the card reader, the card reader reads the real-time encryption factor data stored in the preset sector of the RFID card, such as sector 0, block 1. The encryption factor is usually a 16-byte character string, and the real-time encryption factor is compared with the initial encryption factor. If the real-time encryption factor value read is the preset initial default value, such as 0xFFFFFFFFFFFFFFFF, it is determined that the current RFID smart card is swiped for the first time. If the real-time encryption factor value read is not the preset initial default value, it indicates that the current RFID smart card has been used.

[0100] If the initial encryption factor is the same as the real-time encryption factor, it is the first time to swipe the card, and the unique identifier of the RFID smart card is obtained;

[0101] Specifically, if the initial encryption factor is the same as the real-time encryption factor, it is the first time to swipe the card, and the unique identifier UID of the card is obtained from the RFID smart card. The UID is data specific to each RFID smart card, usually a 4-byte or 7-byte unique serial number. The UID will be used as an input parameter together with the real-time encryption factor in the encryption calculation to generate a key and a sector address for accessing the card number data that are specific to this card, so that the card number data storage address and key of each card are unique.

[0102] According to the first encryption function, the real-time encryption factor and the unique identifier are encrypted to obtain a first sector address for accessing a first key and card number data;

[0103] Specifically, the real-time encryption factor and the UID are used as inputs, and the real-time encryption factor and the unique identifier are encrypted using the first encryption function to generate a first key and a first sector address for accessing the card number data. Through this encryption process, a unique 6-byte first key is obtained for encrypting the access rights of the card, and a first sector address for accessing the card number data is determined. This calculation ensures that the key and card number data access locations of each card are different, thereby effectively avoiding the security risk of repeated use.

[0104] Reading the card number data according to the first key and the first sector address;

[0105] Specifically, after obtaining the first key and the first sector address, the first key is used to access the card number data in the sector corresponding to the first sector address. The first key controls the data access rights of the sector, and the first sector address controls the address for reading the card number data, ensuring that the card number data can be successfully read only when the key and the sector address are correct.

[0106] When the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function to determine a new target encryption factor;

[0107] Specifically, according to the first key and the first sector address, after successfully reading the card number data, in order to further improve data security, the first sector address and UID are processed according to the second encryption function to generate a new target encryption factor. This operation ensures that the encryption factor changes after each card swipe, so that the card presents new data access rules when it is used next time. This dynamic update mechanism can effectively prevent security vulnerabilities caused by fixed encryption factors and enhance the flexibility of card access control.

[0108] Writing the target encryption factor into the sector where the real-time encryption factor is located, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining the second sector address where the second key and the card number data are stored;

[0109] Specifically, after the new target encryption factor is generated, it is written back to the preset sector location, such as sector 0, block 1, to replace the original real-time encryption factor, and then the first encryption function is used again, with the updated target encryption factor and UID as input to calculate the new storage location of the second key and card number data, i.e., the second sector address. This operation ensures that the sector address and encryption key are different each time the card is swiped, thereby further improving the anti-counterfeiting and security performance of the card.

[0110] The card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address.

[0111] Specifically, after the key and sector address are updated, the card number data originally stored in the first sector address is deleted to avoid the security risks caused by duplicate storage, and then the card number data is rewritten to the sector corresponding to the second sector address. Through this operation, dynamic data migration is achieved, which effectively prevents multiple accesses to the same sector and ensures that the card number data storage location is different each time the card is swiped, thereby further enhancing the data security and flexibility of the card.

[0112] In one embodiment, the deleting the card number data at the first sector address and writing the card number data into a new sector corresponding to the second sector address according to the second sector address further comprises:

[0113] The card number data at the first sector address is deleted, the card number data to be written is standardized, and the standard card number data is determined;

[0114] Specifically, use a low-level storage interface, such as a direct sector access command to locate the first sector address and perform a data erase operation. The erase methods include: Overwrite method: overwrite the data in the first sector with all zeros (0x00) or all ones (0xFF); Marking method: mark the first sector as invalid to prevent data recovery; after the erase is completed, verify whether the first sector is clear. Assume that the card number data was originally stored in the first sector at address 0x0010. After performing the erase operation, the original data cannot be read. By clearing sensitive data, data leakage caused by misuse or attack is prevented. Collect the card number data to be written and perform a format check (such as length, character set). Perform standardization operations on the data to ensure that the data conforms to a unified format. For example: if the card number length is less than 16 bits, fill it with zeros; or convert all data to uppercase letters or a specified encoding format.

[0115] After the standardized card number data is determined, its verification information is recorded for subsequent verification; for example, the original card number data 1234-5678-90 is standardized to 1234567890000000, and the MD5 checksum is recorded; this is to ensure that different data sources have a unified format, avoid writing failures, and reduce data errors or omissions caused by non-standard formats.

[0116] Using a splitting function, the standard card number data is split to determine a number of partial card number data;

[0117] Specifically, the standardized card number data is divided into several fixed-size parts, usually based on the size of the storage sector, such as 512 bytes. The segmentation methods include: string segmentation: segmentation by the number of characters; binary segmentation: directly split into blocks by the number of bytes, and generate independent metadata for each part of the card number data, such as an index number or identifier; for example, the standardized card number data 1234567890000000 is divided into two parts: 12345678 (the first part) and 90000000 (the second part). On the one hand, the segmented data is easier to store in a dispersed manner, which is beneficial to data security. On the other hand, some data can be stored in different areas to reduce the risk of data loss.

[0118] According to the second sector address, determining a plurality of preset associated sector addresses corresponding to the second sector address;

[0119] Specifically, a preset mapping table is used to derive the associated sector address based on the second sector address, for example, by simple increment or hash calculation: the second sector address is 0x0020, and the associated sector addresses are 0x0030 and 0x0040. At the same time, the mapping relationship table is regularly and dynamically updated to ensure that subsequent data can be accurately located; for example, the second sector address 0x0020 determines the associated addresses as 0x0030 and 0x0040 through the mapping relationship table.

[0120] According to the preset mapping relationship between the card number data and the sector address, each part of the card number data is written into each of the associated sector addresses.

[0121] Specifically, traverse each part of the card number data, and perform the data writing operation according to its corresponding associated sector address: check whether the associated sector is free, if not, erase the old data first; write each part of the data to the corresponding sector in order, and after the data is written, generate index information to mark the storage location of each part of the data. For example, the first part of the data 12345678 is written to address 0x0030, and the second part of the data 90000000 is written to address 0x0040. This decentralized storage method can reduce the risk of single point failure. At the same time, the associated sector layout can be dynamically adjusted to meet different storage needs.

[0122] In one embodiment, see Figure 4 After reading the real-time encryption factor and comparing the real-time encryption factor with the initial encryption factor, the method further includes:

[0123] If the initial encryption factor is different from the real-time encryption factor, the real-time encryption factor is compared with the historical encryption factor, and the unique identifier of the current RFID smart card is compared with the historical identifier;

[0124] Specifically, after reading and comparing the initial encryption factor and the real-time encryption factor, if the two are different, this means that the current RFID smart card is not being used for the first time. The currently read real-time encryption factor will be further compared with the historical encryption factor stored in the EEPROM of the card reader to determine whether the current encryption factor is the same as the historical encryption factor used last time. In addition, the current unique identifier of the RFID card and the historical identifier recorded in the EEPROM will be compared to confirm the identity of the RFID smart card, which helps to verify the legitimacy of the card and avoid security risks caused by counterfeit cards or data tampering.

[0125] When the real-time encryption factor is the same as the historical encryption factor and the unique identifier is the same as the historical identifier, encrypting the real-time encryption factor and the unique identifier according to a first encryption function to obtain a first sector address where a first key and card number data are stored;

[0126] Specifically, if the real-time encryption factor is consistent with the historical encryption factor and the unique identifier is consistent with the historical identifier, it is confirmed that the RFID smart card is not the first card to be swiped. Next, the first encryption function is used to generate the first key of the card and the storage address of the card number data, that is, the first sector address, with the real-time encryption factor and the unique identifier as input parameters. The first key will be used to unlock the card data to ensure the access security of the card information, and the first sector address indicates the card number data storage location of the card.

[0127] Reading the card number data according to the first key and the first sector address;

[0128] Specifically, after obtaining the first key and the first sector address, the first key is used to access the address corresponding to the first sector address to read the card number data stored therein. The first key controls the access rights to the sector to ensure that the data can be successfully read only when the key verification is passed. This step ensures that the card's identity authentication information can be correctly accessed for subsequent encryption update operations.

[0129] When the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function to determine a new target encryption factor;

[0130] Specifically, when the card number data is successfully read, the current RFID smart card is verified, and the first sector address and the unique identifier are encrypted according to the second encryption function to generate a new target encryption factor, which is intended to replace the existing historical encryption factor and real-time encryption factor to ensure that the encryption factor and the card number data access address will be different after each card swipe. The generation of a new target encryption factor can further improve the security of card information, prevent the potential safety hazards caused by the repeated use of fixed factors, and enhance the dynamic and flexibility of the card swiping process.

[0131] In one embodiment, see Figure 5 , when the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function, and determining a new target encryption factor includes:

[0132] performing multiplication calculation on the first sector address and the unique identifier to determine a fourth character string;

[0133] Specifically, when the card number data is successfully read, that is, the current RFID smart card is verified, the unique identifier of the current RFID smart card is multiplied by the first sector address obtained, and a new target encryption factor is determined according to the calculation result. The result of the multiplication of the unique identifier and the first sector address obtained generates a temporary string, that is, the fourth string, for example, the fourth string Kn=0x1A2B3C4D*0x05=0x82D82D81. By combining the unique identifier of the RFID smart card and the first sector address accessed by the card number data, it is ensured that the new target encryption factor and the sector address accessed by the card number data are unique, thereby improving data security and preventing the encryption factor from being reused.

[0134] The characters at the fourth preset position in the fourth character string are extracted, and the extraction result is used as the target encryption factor.

[0135] Specifically, from the calculated fourth character string, the character at the fourth preset position is extracted and used as the new target encryption factor. For example, the last 4 bytes of the fourth character string are extracted as the target encryption factor, which ensures that the generated target encryption factor is within a certain length and has high uniqueness. By extracting the character at the specified fourth preset position, an encryption factor with sufficient complexity can be obtained to replace the old factor. This new target encryption factor will be stored in a specific sector and used in the next verification, further improving the security and dynamism of card information protection.

[0136] Replacing the original historical encryption factor with the target encryption factor, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining a second sector address where a second key and card number data are stored;

[0137] Specifically, after determining the new target encryption factor, the historical encryption factor stored in the EEPROM of the card reader is replaced with the target encryption factor, and the new target encryption factor and the unique identifier are processed by the first encryption function to generate a new second key and a second sector address for storing the card number data. The second key is used to access the new card number data storage address, thereby enhancing the security of the card data. The use of a dynamic target encryption factor can effectively avoid the security risks caused by swiping a duplicate card. At the same time, the generated second sector address will dynamically adjust the storage location of the card number data, further enhancing the card's protection capabilities.

[0138] The card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address.

[0139] Specifically, the card number data is first deleted from the sector corresponding to the old first sector address to prevent the card data from being read repeatedly or leaking data; then, the card number data is written to the location specified by the second sector address. This operation causes the storage location of the card number data to change every time the card is swiped, increasing data security, and in conjunction with the dynamic key update mechanism, further improving the protection and verification management of card data.

[0140] In one embodiment, see Figure 6 , after completely copying the RFID smart card, including:

[0141] reading the copy data on the copy card, wherein the copy data includes a first copy encryption factor and a copy identifier;

[0142] Specifically, when the copied card enters the radio frequency signal range of the card reader, the card reader reads the copied data on the copied card, especially the sensitive information related to encryption, including the first copied encryption factor and the copied identifier of the copied card; these copied data are used to verify whether the card is a legitimate card in subsequent steps.

[0143] Compare the copied data with the historical data in the card reader, if the copied data is consistent with the historical data, the first swipe of the copied card passes the verification, wherein the historical data includes the target encryption factor and the unique identifier;

[0144] Specifically, the first copy encryption factor and copy identifier of the read copy card are compared with the historical data stored in the EEPROM of the card reader. This step is mainly used to detect whether the card data is consistent with the previously recorded legal information.

[0145] According to a first encryption function, the first copy encryption factor and the copy identifier are encrypted to determine a copy sector address for accessing the copy key and the card number data;

[0146] Specifically, according to the first encryption function, the first copy encryption factor and copy identifier of the copy card are encrypted to generate a copy key and a copy sector address. Since the first copy encryption factor and the copy identifier are consistent with the historical data stored inside the EEPROM of the card reader, the calculated copy key is consistent with the second key, and the copy sector address for accessing the card number data is consistent with the second sector address where the card number data is stored.

[0147] Reading the card number data according to the duplicate key and the duplicate sector address;

[0148] When the card number data is successfully read, the copy identifier and the copy sector address are encrypted according to a second encryption function, a second copy encryption factor is determined, and the target encryption factor is replaced with the second copy encryption factor;

[0149] Specifically, after the card number data of the duplicate card is successfully read, the duplicate identifier and the duplicate sector address are encrypted according to the second encryption function to generate a second duplicate encryption factor. This new second encryption factor is used to replace the target encryption factor after the replacement operation and is saved in the card reader head EEPROM. The design purpose of this step is to update the unique second duplicate encryption factor to a new verification identification mark after the duplicate card is swiped for the first time.

[0150] After the duplicate card is swiped for the first time, the card reader has stored the newly generated second duplicate encryption factor in its EEPROM as an identification mark, but the encryption factor inside the duplicate card itself cannot be changed dynamically and remains the original first duplicate encryption factor. This means that when the duplicate card is swiped again, although the UID of the duplicate card is the same as that of the original RFID smart card, the encryption factor on the duplicate card read by the card reader, that is, the first duplicate encryption factor, does not match the second duplicate encryption factor stored in the EEPROM, resulting in verification failure. This mechanism ensures that the duplicate card can only be swiped for the first time and cannot be swiped repeatedly, thereby effectively avoiding the situation where the card is copied in batches after the key is cracked.

[0151] When a legitimate original RFID smart card is swiped, the target encryption factor is compared with the second duplicate encryption factor to determine that the original RFID smart card is an illegal card.

[0152] Specifically, when a legitimate original RFID smart card is swiped, the target encryption factor of the original RFID smart card is read and compared with the second duplicate encryption factor. Because the duplicate card has replaced the target encryption factor with the second duplicate encryption factor when it was swiped for the first time, the original RFID smart card will no longer match when it is swiped; this mismatch will be identified as illegal card behavior, and a warning message will be recorded in the background or a reminder will be sent to the original card holder. In this way, after the activity of the duplicate card is detected, the original card can be blocked from normal access and the original card holder can be reminded, thereby improving security and preventing further unauthorized access.

[0153] In one embodiment, see Figure 7 After replacing the original historical encryption factor with the target encryption factor, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining the second sector address where the second key and the card number data are stored, the method further includes:

[0154] According to the second sector address, obtaining a target read frequency of the sector corresponding to the second sector address, and obtaining read frequencies and preset frequency thresholds corresponding to the remaining sectors respectively;

[0155] Specifically, the target reading frequency of the sector corresponding to the second sector address is read, that is, the number of times the sector is accessed by the card reader and the reading frequency of the remaining sectors, and these frequency data are compared with the preset frequency threshold. The preset frequency threshold is a limit value set by security management, and different values ​​can be set according to different actual security management needs. The preset frequency threshold is used to determine whether the access frequency of a certain sector exceeds the safety range. For example, the second sector reading frequency is obtained as 5 times, and the reading frequencies of other sectors are 2, 4, and 6 times respectively, and the frequency threshold is set to 10 times. By obtaining and comparing the reading frequency information and the threshold, the access location of the card number data is dynamically adjusted to avoid risk exposure and damage to the RFID smart card caused by frequent access to a certain sector, thereby ensuring data security and balanced reading distribution.

[0156] Calculating an average value of the reading frequencies of each sector according to the target reading frequency and the reading frequencies corresponding to the remaining sectors;

[0157] Specifically, based on the reading frequency of all sectors, including the target sector and the remaining sectors, the average reading frequency is calculated as a basis for whether to migrate data. For example, if the reading frequency of each sector is 2, 4, 5, and 6 times respectively, the average value is 2+4+5+6 / 4 = 4.25 times; the calculation of the average reading frequency helps determine the access distribution of card number data in each sector, prevents excessive concentration of access to a specific sector, ensures that card data is evenly distributed among multiple sectors, and improves security and anti-attack capabilities.

[0158] If the target reading frequency is less than the average value and the target reading frequency is less than the frequency threshold, the card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address;

[0159] Specifically, the target reading frequency, the average value and the frequency threshold are compared. If the target reading frequency is less than the average value and the target reading frequency is less than the frequency threshold, the data access frequency of the new sector corresponding to the second sector address is considered safe, and the card number data of the sector corresponding to the first sector address is deleted and migrated to the new sector corresponding to the second sector address, so as to store the data in the sector with lower reading frequency to disperse the risk. For example, if the target reading frequency is 3 times, which is lower than the average value of 4.25 and less than the frequency threshold of 10 times, the card number data of the first sector will be deleted and written to the second sector.

[0160] By balancing the reading frequency of each sector, the card service life is extended.

[0161] If the target reading frequency is greater than or equal to the average value and / or the target reading frequency is greater than or equal to the frequency threshold, the second sector address is updated by a hash function and a pseudo-random algorithm to determine a third sector address where the card number data is stored;

[0162] Specifically, if the target reading frequency is greater than or equal to the average value and / or the target reading frequency is greater than or equal to the frequency threshold, the hash function and pseudo-random algorithm are used to recalculate the sector address to determine the new card number data access location, that is, the third sector address. A new address that is not easy to predict is calculated by the hash and pseudo-random algorithm to store the card number data, so as to prevent the data location from being pre-judged.

[0163] Assuming that the target reading frequency is 8 times, it exceeds the average value of 4.25 or approaches the threshold of 10 times, the third sector address will be regenerated, for example, sector 8 is calculated as the new storage address. By dynamically updating the sector address, the storage location after each read and write operation is different, which enhances the unpredictability of data access, greatly improves the security of data, and effectively prevents potential targeted attacks. At the same time, the scheme of determining the third sector address through hash function and pseudo-random algorithm can effectively generate uniformly distributed sector addresses, avoiding the risk of frequent access to a fixed sector. The hash function can generate an unpredictable and relatively uniformly distributed address based on the input, ensuring that the address generation does not rely on specific rules, reducing the possibility of being cracked, and with the use of pseudo-random algorithm, further breaking the patterned distribution, so that the results of each address calculation are different, avoiding concentrated access to a single sector. The advantage of this method is that it balances the reading frequency of each sector and reduces the physical loss caused by frequent access to the same sector, thereby effectively extending the service life of the card and improving security and data anti-interference capabilities.

[0164] In one embodiment, see Figure 8 , if the target reading frequency is greater than or equal to the average value or the target reading frequency is greater than or equal to the frequency threshold, the second sector address is updated by a hash function and a pseudo-random algorithm, and the third sector address where the card number data is stored is determined to include:

[0165] Combining the unique identifier and the target encryption factor to determine a target character string;

[0166] Specifically, the unique identifier and the target encryption factor are concatenated or combined in other rules to form a unique target string. For example, if the unique identifier is 0x1A2B3C4D and the target encryption factor is 0x123456, the two values ​​are combined in a certain order to form 0x1A2B3C4D123456. This combination ensures the uniqueness and dynamism of the input, because the target string generated each time is different, providing a diverse input for subsequent hash operations.

[0167] Processing the target string through a hash function to determine a hash value;

[0168] Specifically, the target string is used as input and a fixed-length hash value is generated through a hash function such as SHA-256 or MD5. For example, the hash value generated by processing 0x1A2B3C4D123456 through SHA-256 is: 5e884898da28047151d0e56f8dc6292773603dcfc1e004a6bbcbaf58d6a8. The main advantages of this hash value are irreversibility, uniqueness and unpredictability, which can ensure the security and uniqueness of the output results and provide a random and uniformly distributed data foundation for subsequent mapping.

[0169] Performing standardization processing on the hash value to convert the hash value into a hash integer value;

[0170] Specifically, the generated hash value needs to be standardized, that is, the hash value is converted into digital form for easy operation; for example, the first 8 characters of the hash value are intercepted and converted into a hexadecimal integer or a decimal integer, thereby converting the complex hash value 5e884898 into an integer 1581254296. The standardized hash integer value simplifies subsequent calculations and lays the foundation for mapping to a specific sector address range.

[0171] According to the hash integer value and a preset sector address interval, the hash integer value is mapped to the sector address interval to determine a target sector address;

[0172] Specifically, by mapping the standardized hash integer value to the sector address range of the card, the dynamic positioning of the sector is realized. For example, within the range of 16 sectors, the hash integer value is modulo 16 to obtain the sector number. The hash integer value modulo 16 to obtain the sector number includes performing a modulo operation on the standardized hash integer value and 16, that is, calculating the remainder after the integer value is divided by 16. Since the address range of 16 sectors is 0 to 15, by taking the modulo of the hash integer value, it can be ensured that the result is always between 0 and 15, thereby obtaining a valid sector number. For example, if the hash integer value is 1581254296, after the operation of 1581254296 divided by 16, the remainder is 8, which means that the hash value is mapped to the 8th sector. In this way, a uniform mapping of hash values ​​and specific sectors is achieved, thereby avoiding frequent access to certain sectors, dispersing the storage load, and increasing the stability and durability of the storage system. This ensures that the sector address generated each time is different while covering all available sectors, avoiding frequent access to a fixed sector, and reducing the risk of physical damage to the card.

[0173] The third sector address is determined according to the hash integer value, the first sector address, the sector address interval and the target sector address in combination with the pseudo-random number generation algorithm.

[0174] Specifically, finally, the final third sector address is generated by combining the hash integer value, the first sector address, the target sector address, and the pseudo-random algorithm. The introduction of the pseudo-random algorithm can further disturb the target sector address generated by the basic hash and break the single mapping rule. For example, by generating an offset and adding it to the target sector address, the third sector address is finally obtained. This process further improves the randomness of the distribution of access sectors, avoids the security risks caused by specific rules, and realizes decentralized storage distribution, reducing the risk of centralized reading of cards, and effectively improving the service life of cards.

[0175] In one embodiment, see Fig. 9 , determining the third sector address according to the hash integer value, the first sector address, the sector address interval and the target sector address in combination with the pseudo-random number generation algorithm includes:

[0176] Initializing a preset pseudo-random number generator according to the hash integer value;

[0177] Specifically, the hash integer value is input as a seed into a preset pseudo-random number generator to ensure that the generated pseudo-random number sequence is closely related to the hash integer value. The pseudo-random number generator can generate different random number sequences by different initial seed values, while the same seed value will generate the same sequence, ensuring consistency and predictability in different environments. This method helps to improve data security and avoid different cards from generating duplicate sector addresses.

[0178] Inputting the first sector address into the initialized pseudo-random number generator to determine a pseudo-random number;

[0179] Specifically, the first sector address, such as 0x05, is used as input data to further enhance the unpredictability of the random number. The input data is combined with the seed value, that is, the hash integer value, and the pseudo-random number generator calculates and generates a new pseudo-random number. This process ensures that the access data and offset of each card are unique. Even if the card uses the same hash value, the change of the first sector address will affect the final pseudo-random number. For example, the hash integer value 1581254296 is input as a seed to the pseudo-random number generator, and the generated random number sequence will always be associated with the seed value. If the first sector address is 0x05, the generated pseudo-random number will depend on the combination of this address and the previously generated random number sequence. The core of the pseudo-random number generator is to recursively generate pseudo-random numbers through mathematical algorithms, such as the linear congruential method, so as to ensure that each access to the card has a certain difference and security.

[0180] According to the sector address interval, performing modulo processing on the pseudo-random number to determine an offset, wherein the offset is within the sector address interval;

[0181] Specifically, the pseudo-random number is modulo processed with a preset sector address interval to ensure that the offset is always within the valid sector address interval. The sector address interval is usually 0 to 15, corresponding to the 16 sectors of the RFID smart card. By performing a modulo operation on the pseudo-random number, it can be ensured that the generated offset is within the interval. For example, assuming that the generated pseudo-random number is 35, the result after modulo 16 is 3, which means that the offset is 3.

[0182] The offset and the target sector address are added and modulo processed to determine the third sector address.

[0183] Specifically, by adding the offset and the target sector address, and performing a modulo operation on the result again, the final third sector address where the card number data is stored is determined. The addition calculation ensures that the target sector address changes under the influence of the offset, and the modulo operation keeps the result within the legal sector address range. Assuming that the target sector address is 5 and the offset is 3, the addition result is 8, and then performing a modulo operation on 8 by 16, the final third sector address is 8. This design makes the sector location of data storage more flexible, can effectively avoid excessive access to a certain sector, and reduce the burden on storage devices.

[0184] The card number data at the first sector address is deleted, and according to the third sector address, the card number data is written into a new sector corresponding to the third sector address.

[0185] Specifically, in order to ensure data update and card number data security, the old data in the first sector is first deleted, and then the card number data is written to the new address according to the newly calculated third sector address. This operation ensures that the data is always updated, avoiding the risk of card damage or storage performance degradation caused by long-term concentration of stored data in a certain sector. By distributing the storage of card number data among different sectors, the service life of the card can be effectively extended, while improving reading efficiency and security.

[0186] Example 3

[0187] Embodiment 3 of the present invention discloses an anti-copying RFID smart card initialization and dynamic encryption system, wherein the dynamic encryption system comprises an RFID smart card and a card reader, wherein the RFID smart card is initialized by the RFID smart card initialization method as described in Embodiment 1, and the card reader dynamically encrypts the RFID smart card by the RFID smart card dynamic encryption method as described in Embodiment 2.

[0188] Specifically, the anti-copying RFID smart card initialization and dynamic encryption system provided by the embodiment of the present invention is adopted, and the dynamic encryption system includes an RFID smart card and a card reader. The RFID smart card is initialized by the RFID smart card initialization method as described in Example 1, and the card reader dynamically encrypts the RFID smart card by the RFID smart card dynamic encryption method as described in Example 2. On the one hand, this system effectively solves the problem of batch copying after the RFID smart card key is cracked by introducing the mechanism of encryption factor and dynamic access address. In this scheme, the encryption factor of each card will change every time the card is swiped, resulting in the sector address and key for accessing the card number also changing accordingly. Even if the copied card successfully swipes the card by copying the UID and key of the legitimate card, the sector address for accessing the card number will no longer match the next time the card is swiped because the encryption factor has changed, resulting in the copy card being unable to access the legitimate data stored in the new location, thereby rendering it invalid. In addition, since the key and storage address of each card are based on the UID and key, the key and storage address of each card are based on the UID and key of the legitimate card. The encryption factor is dynamically calculated, and the encryption method of each card is different. This means that even if an attacker cracks the key of a certain card, he still cannot copy other cards in batches, because each card has an independent access address and key. Through this dynamic encryption and address change design, the long-term use of copied cards is effectively prevented, and the security risks caused by batch copying are avoided, thereby significantly enhancing security and ensuring that the access rights of legitimate users are not tampered with or imitated by illegal cards; on the other hand, since this system does not need to configure a physical key for each card separately, but generates dynamic keys and storage addresses through algorithms, the hardware deployment cost is reduced.

[0189] In summary, the embodiments of the present invention provide a method and system for initializing and dynamically encrypting an anti-copying RFID smart card.

[0190] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.

[0191] The functional blocks shown in the structural block diagram described above can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier. "Machine-readable medium" may include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memories, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0192] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant location, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0193] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.

[0194] The above is only a specific implementation of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the system, module and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It should be understood that the protection scope of the present invention is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be covered within the protection scope of the present invention.

Claims

1. A copy-proof RFID smart card dynamic encryption method, characterized in that: The RFID smart card includes several sectors, each of which is used to store and access encryption factors or card number data. Each sector includes a key block, and the key block is used to store and access a key for accessing the sector. The encryption factor is a character string generated by encryption and is used to calculate a sector address for accessing the card number data. The RFID smart card is initialized by an initialization method of the RFID smart card, and the initialization method includes: Obtain a preset initial encryption factor; Writing the initial encryption factor into a preset sector and obtaining a unique identifier of the RFID smart card; According to the first encryption function, the unique identifier and the initial encryption factor in the preset sector are encrypted to determine the initial sector address and initial key where the card number data is stored; The dynamic encryption method comprises: Reading the real-time encryption factor in the preset sector, and comparing the real-time encryption factor with the initial encryption factor; If the initial encryption factor is the same as the real-time encryption factor, it is the first time to swipe the card, and the unique identifier of the RFID smart card is obtained; According to the first encryption function, the real-time encryption factor and the unique identifier are encrypted to obtain a first sector address for accessing a first key and card number data; Reading the card number data according to the first key and the first sector address; When the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function to determine a new target encryption factor; Writing the target encryption factor into the sector where the real-time encryption factor is located, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining the second sector address where the second key and the card number data are stored; The card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address.

2. The anti-copying RFID smart card dynamic encryption method according to claim 1, characterized in that: The step of encrypting the unique identifier and the initial encryption factor in the preset sector according to the first encryption function to determine the initial sector address and the initial key for storing the card number data comprises: Performing an XOR operation on the unique identifier and the initial encryption factor to determine a first character string; Performing an XOR operation on the character at the first preset position in the unique identifier and the character at the second preset position in the initial encryption factor to determine a second character string; Combining the first character string and the second character string to determine the initial key; Performing an XOR operation on the character at the third preset position in the unique identifier and the character at the third preset position in the initial encryption factor to determine a third character string; The initial sector address is determined according to the third character string.

3. The dynamic encryption method according to claim 1, characterized in that: After reading the real-time encryption factor in the preset sector and comparing the real-time encryption factor with the initial encryption factor, the method further includes: If the initial encryption factor is different from the real-time encryption factor, the real-time encryption factor is compared with the historical encryption factor, and the unique identifier of the current RFID smart card is compared with the historical identifier; When the real-time encryption factor is the same as the historical encryption factor and the unique identifier is the same as the historical identifier, encrypting the real-time encryption factor and the unique identifier according to a first encryption function to obtain a first sector address where a first key and card number data are stored; Reading the card number data according to the first key and the first sector address; When the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function to determine a new target encryption factor; Replacing the original historical encryption factor with the target encryption factor, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining a second sector address where a second key and card number data are stored; The card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address.

4. The dynamic encryption method according to claim 1, characterized in that: When the card number data is successfully read, the first sector address and the unique identifier are encrypted according to a second encryption function, and determining a new target encryption factor includes: performing multiplication calculation on the first sector address and the unique identifier to determine a fourth character string; The characters at the fourth preset position in the fourth character string are extracted, and the extraction result is used as the target encryption factor.

5. The RFID smart card dynamic encryption method according to claim 1, after completely copying the RFID smart card, comprises: reading the copy data on the copy card, wherein the copy data includes a first copy encryption factor and a copy identifier; Compare the copied data with the historical data in the card reader, if the copied data is consistent with the historical data, the first swipe of the copied card passes the verification, wherein the historical data includes the target encryption factor and the unique identifier; According to a first encryption function, the first copy encryption factor and the copy identifier are encrypted to determine a copy sector address for accessing the copy key and the card number data; Reading the card number data according to the duplicate key and the duplicate sector address; When the card number data is successfully read, the copy identifier and the copy sector address are encrypted according to a second encryption function, a second copy encryption factor is determined, and the target encryption factor is replaced with the second copy encryption factor; When a legitimate original RFID smart card is swiped, the target encryption factor and the second duplicate encryption factor are compared to determine that the original RFID smart card is an illegal card.

6. The dynamic encryption method according to claim 3, characterized in that: After replacing the original historical encryption factor with the target encryption factor, encrypting the target encryption factor and the unique identifier according to the first encryption function, and determining the second sector address where the second key and the card number data are stored, the method further includes: According to the second sector address, obtaining a target read frequency of the sector corresponding to the second sector address, and obtaining read frequencies and preset frequency thresholds corresponding to the remaining sectors respectively; Calculating an average value of the reading frequencies of each sector according to the target reading frequency and the reading frequencies corresponding to the remaining sectors; If the target reading frequency is less than the average value and the target reading frequency is less than the frequency threshold, the card number data at the first sector address is deleted, and the card number data is written into a new sector corresponding to the second sector address according to the second sector address; If the target reading frequency is greater than or equal to the average value and / or the target reading frequency is greater than or equal to the frequency threshold, the second sector address is updated by a hash function and a pseudo-random algorithm to determine a third sector address where the card number data is stored; The card number data at the first sector address is deleted, and according to the third sector address, the card number data is written into a new sector corresponding to the third sector address.

7. The dynamic encryption method according to claim 6, characterized in that: If the target reading frequency is greater than or equal to the average value or the target reading frequency is greater than or equal to the frequency threshold, the second sector address is updated by a hash function and a pseudo-random algorithm to determine the third sector address where the card number data is stored, including: Combining the unique identifier and the target encryption factor to determine a target character string; Processing the target string through a hash function to determine a hash value; Performing standardization processing on the hash value to convert the hash value into a hash integer value; According to the hash integer value and a preset sector address interval, the hash integer value is mapped to the sector address interval to determine a target sector address; The third sector address is determined according to the hash integer value, the first sector address, the sector address interval and the target sector address in combination with the pseudo-random algorithm.

8. The dynamic encryption method according to claim 7, characterized in that: Determining the third sector address according to the hash integer value, the first sector address, the sector address interval and the target sector address in combination with the pseudo-random algorithm includes: Initializing a preset pseudo-random number generator according to the hash integer value; Inputting the first sector address into the initialized pseudo-random number generator to determine a pseudo-random number; According to the sector address interval, performing modulo processing on the pseudo-random number to determine an offset, wherein the offset is within the sector address interval; The offset and the target sector address are added and modulo processed to determine the third sector address.

9. An anti-copying RFID smart card initialization and dynamic encryption system, characterized in that: The dynamic encryption system comprises an RFID smart card and a card reader, and the card reader initializes and dynamically encrypts the RFID smart card by using the RFID smart card dynamic encryption method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Radio frequency card with double encryption algorithm

    CN106529651A

  • Updating method and device for authorization data in access control machine and electronic equipment

    CN115424381A

  • M1 card multi-security encryption method and system

    CN116367147A