Summary of the invention:
The object of the present invention is to provide a kind of public key code hopping safety system and method, the present invention mainly comprises: the transmitting terminal of electron key and receiving terminal two parts constitute, transmitting terminal is by button, electricallyerasable ROM (EEROM) (EEPROM), randomizer, ciphering unit, shift register, oscillator, LED drives, power consumption control, control unit is formed, receiving terminal is by the radio frequency command receiver module, electricallyerasable ROM (EEROM) (EEPROM) and a single-chip microcomputer are formed, it is characterized in that: control program was carried out following step after transmitting terminal was received push button signalling: carry out and encrypt transmit operation, at first be the power consumption control that various piece is opened in the power consumption control unit, for each unit provides clock signal; Generate random number by randomizer then, and from electricallyerasable ROM (EEROM) (EEPROM), read sequence number, encryption key, synchronized counter value, the irreducible function (F of product
m) value; With random number, encryption key, irreducible function (F
m) value, sequence number send into ciphering unit together, to need information transmitted to send into shift register after finishing ciphering process, launch then, the each information that transmits of transmitting terminal is 64bit, comprise three parts, first is the 16bit plain code information that is made of 12bit before 4bit key information and the product ID, second portion by 16bit random number and sequence number after 16bit carry out XOR and generate, and third part is the 32bit frame hopping that obtains through cryptographic algorithm, after the random number combination, carry out following step:
Encrypted Data=(Serial Number^Random Number|Counter^Random Number) * CryptKey (mod Fm) is promptly: data encrypted equals, sequence number XOR random number and the synchronous data formed of counting XOR random number, with encryption key finite field multiply each other long-pending.The encrypted frame hopping information that is 32bit that obtains.
The mode of encryption key is: Cryptkey*DecryKey=1 (mod Fm) promptly: encryption key and decruption key confinement multiply each other long-pending be 1.
Control program was carried out following step after receiving terminal was received signal: after single-chip microcomputer receives command information, from electricallyerasable ROM (EEROM) (EEPROM), read in sequence number, decruption key, irreducible function, the synchronometer logarithmic data, be decrypted and verify whether instruction is effective, if effectively then with corresponding button operation order output, and with new synchronometer numerical value write-back electricallyerasable ROM (EEROM) (EEPROM), when carrying out mode of learning (Learning mode), also will be with new sequence number and decruption key write-back electricallyerasable ROM (EEROM) (EEPROM).When receiving terminal receives that continuously some these sequence numbers are effective, but when deciphering invalid information, single-chip microcomputer is scanned attack with output alarm signal (Alarm) with caution.The receiving code separated into two parts, the sequence number of the 32bit of first, the frame hopping information of second portion 32bit, wherein frame hopping is corresponding expressly is made up of two parts again, the XOR value of 16bit random number and 16bit random number and 16bit coincidence counter, when carrying out mode of learning (Learningmode) by following step: the information of receiving 64bit; From electricallyerasable ROM (EEROM) (EEPROM), read trading company of factory and irreducible function (F
m), calculate the decruption key that makes new advances by new sequence number and algorithm decruption key, and temporary this sequence number and decruption key; Obtain expressly corresponding with new decruption key deciphering frame hopping information; Carry out xor operation with correspondence plaintext first and second portion, calculate synchronized counter value, and it is temporary; Receive the code word of a 64bit once more; With its sequence number and primary comparing, identical execution next step, otherwise think study failure, do not do any operation, finish to withdraw from; Obtain expressly with decruption key deciphering frame hopping information; Plaintext first and second portion are carried out the synchronized counter value that XOR obtains this time; With itself and comparing last time, if than last time just big 1 carry out next step, otherwise think the study failure, do not do any operation, finish to withdraw from; Learning success writes new sequence number, synchronized counter value, decruption key to refresh EEPROM, finishes.
The mode of decruption key is: DecryKey=SerialNumber*ManufactureID (mod Fm) promptly: unique sign that decruption key equals sequence number and manufacturer finite field multiply each other long-pending.
Advantage of the present invention is: system adopts technology, encryption/decryption element, the design of randomizer and the design of transmitting terminal chip total system of public key algorithm frame hopping, the design of utilization coincidence counter, mode of learning (Learningmode), thereby improve the fail safe of system, because receiving terminal only need use and have the decoding program single-chip microcomputer and do not need special decoding chip, has reduced cost.
Description of drawings:
The structure chart of Fig. 1 transmitting terminal circuit of the present invention
Fig. 2 the present invention sends chip design overall plan figure
The ciphering process block diagram of Fig. 3 transmitting terminal of the present invention
The structure chart of Fig. 4 receiving terminal circuit of the present invention
The decipherment algorithm block diagram of Fig. 5 receiving terminal of the present invention
Fig. 6 decrypted program FB(flow block) of the present invention
Fig. 7 mode of learning program flow chart of the present invention
1 transmitting terminal chip, the input of B0 button, the input of B1 button, B2 button are imported, the B3 button is imported,
3 light-emitting diodes, 4 electricallyerasable ROM (EEROM)s (EEPROM), 5 randomizers, 6 ciphering units,
7 shift registers, 8 oscillators, 9 LED driving, 10 power consumption control, 11 control units,
12 reset circuits, 13 radio frequency command receiver modules, 14 electricallyerasable ROM (EEROM)s (EEPROM), 15 single-chip microcomputers
Embodiment:
System's major parameter:
Encryption key (CryptKey) 32bit is applied to ciphering process;
Decruption key (DecryKey) 32bit is applied to decrypting process;
Key information (ButtonInfo) 4bit needs information transmitted, and receiving terminal will be operated accordingly according to key information;
Whether sequence number (Serial Number) 28bit, unique sign of each electron key, door-locking system rely on this sign to distinguish is the electron key of oneself;
Count (Counter) 16bit synchronously, electron key is whenever pressed once, and this numeral adds one, is used for generating frame hopping and some security inspections through encrypting;
Vendor id (ManufactureID) 32bit, unique sign of each automobile vendor, this sign and sequence number join together to be used to generate encryption key and decruption key;
Encrypt back data (Encrypted Data) 32bit, promptly the changing unit of the each data that send of electron key by synchronous counting and serial number encryption gained, is used to realize frame hopping (hoping code);
Random number (Random Number) 16bit improves the key parameter of frame hopping rate of change and fail safe, is used for ciphering process;
Irreducible function (Fm) 32bit, the key parameter of cryptographic calculation and decrypt operation also is the key that generates encryption key and decruption key; (referring to Fig. 1), the transmitting terminal of system (promptly encrypting end) is made of transmitting terminal chip 1, button input B0, B1, B2, B3, light-emitting diode 3.The work that transmitting terminal chip 1 is mainly encrypted and sent has eight valid interfaces, comprises that keying input information, VDD, VSS, the LED of 4bit drives output and pwm signal output.Button is input as four, links 4 button inputs B0, B1 of transmitting terminal chip 1, the interface of B2, B3 respectively, and the user imports the order that controlled end need be carried out by it.Light-emitting diode 3 drives output by LED and drives, and whether display button information is effectively encrypted and exported.VDD is the input of power supply high level, and VSS is a ground connection.
At transmitting terminal, after user's action button, key information input transmitting terminal chip 1, chip is through behind the cryptographic calculation, and the information with after encrypting comprises plain code, pseudo-frame hopping and frame hopping part, sends by the PWM mouth, thereby has finished the once command transmit operation.(referring to Fig. 2) partly is made of button input, electricallyerasable ROM (EEROM) (EEPROM) 4, randomizer 5, ciphering unit 6, shift register 7, oscillator 8, LED driving 9, power consumption control 10, control unit 11 etc.The button input is the input information that receives from button; Electricallyerasable ROM (EEROM) (EEPROM) 4 is used to deposit product ID, encryption key, irreducible function Fm, synchronous counting etc.; Randomizer 5 is used to produce random number, and this random number will be used for ciphering process; Ciphering unit is mainly carried out cryptographic operation, and the 32bit frame hopping information after the output encryption; Shift register is used for temporary information to be sent, and the information of transmission sends a position; Oscillator 8 is clock sources of entire circuit, for circuit provides clock; LED drives a laser-emitting diode of 9 outsides; Reset circuit 12 is used to produce reset signal; Power consumption control 10 is used to reduce power consumption, after receiving key information, just provides clock signal to other each several parts of circuit, is executing encryption and transmit operation, promptly disconnects the clock signal of other parts; The control of whole system, working in coordination with of each module all finished by control unit.
Transmitting terminal chip 1 begins to carry out the encryption transmit operation after receiving the key information that is come out by button.At first be the power consumption control that power consumption control 10 is opened various piece, for each unit provides clock supply; Generate random numbers by randomizer 5 then, and from electricallyerasable ROM (EEROM) (EEPROM) 4 with sequence number, encryption key, synchronized counter value, the irreducible function (F of product
m) value etc. reads; With random number, encryption key, irreducible function (F
m) value, sequence number etc. send into ciphering unit 6 together, will need information transmitted to send into shift register 7 after finishing ciphering process, launch then.Thereby ciphering process and transmit operation have been finished.
The ciphering process of transmitting terminal (referring to Fig. 3): the each information that transmits of order transmitting terminal is 64bit, comprise three parts: first is the 16bit plain code information that is made of 12bit before 4bit key information and the product ID, second portion by 16bit random number and sequence number after 16bit carry out XOR and generate, and third part is the 32bit frame hopping that obtains through cryptographic algorithm, 32bit before encrypting expressly is made up of two parts again, and promptly 16bit carries out the 16bit sign indicating number that 16bit sign indicating number that XOR generates and 16bit random number and 16bit coincidence counter carry out the XOR generation behind 16bit random number and the sequence number.
The data that need in the encryption to use have: encryption key 32bit, irreducible function 32bit, the low 16bit of sequence number, random number 16bit and synchronous counting 16bit.Low 16bit and synchronous counting by sequence number are formed data to be encrypted together, after the use random number confusion, carry out following operation:
Encrypted Data=(Serial Number^Random Number|Counter^Random Number) * CryptKey (mod Fm) is promptly: data encrypted equals, sequence number XOR random number and the synchronous data formed of counting XOR random number, with encryption key finite field multiply each other long-pending.The encrypted frame hopping information that is 32bit that obtains.
Receiving terminal circuit mainly is made up of radio frequency command receiver module 13,14 and single-chip microcomputers 15 of (referring to Fig. 4) electricallyerasable ROM (EEROM) (EEPROM).Radio frequency command receiver module 13 is used for the wireless remote control instruction that the serial received transmitting terminal sends, and will instruct and be transferred to single-chip microcomputer 15 with digital signal form; Electricallyerasable ROM (EEROM) (EEPROM) 14 is deposited sequence number that deciphering will use, decruption key, irreducible function (Fm), counting etc. synchronously; After single-chip microcomputer 15 receives command information, from electricallyerasable ROM (EEROM) (EEPROM) 14, read in sequence number, decruption key, irreducible function, synchronous counting etc., be decrypted and verify whether instruction is effective, if effectively then with corresponding button operation order output, and new synchronometer numerical value is written back to electricallyerasable ROM (EEROM) (EEPROM) 14, when carrying out mode of learning (Learning mode), also will be with new sequence number and decruption key write-back electricallyerasable ROM (EEROM) 14.When receiving terminal receives that continuously some these sequence numbers are effective, but when deciphering invalid information, single-chip microcomputer 15 is scanned attack with output alarm signal (Alarm) with caution.
The receiving terminal manner of decryption is as follows:
(Serial Number^Random Number|Counter^Random Number)=Encrypted Data*DecryKey (mod Fm) is promptly: sequence number XOR random number and synchronously the data formed of counting XOR random number equal, the data that receive and decruption key are amassing that finite field multiplies each other.
Receiving terminal decrypted program operating process of the present invention is: (referring to Fig. 6)
1) will receive preceding 12bit sequence number and comparing of reading in the code word first, if identical execution 2), otherwise carry out 8); 2) utilize decipherment algorithm that frame hopping information is decrypted, and compare the corresponding first expressly of second portion, if identical execution 3 with frame hopping), otherwise carry out 8); 3) the corresponding first's (perhaps whole codeword second portion) expressly with frame hopping of back 16bit with the sequence number read carries out XOR, calculates the random number of transmitting terminal; 4) carry out xor operation by the corresponding second portion expressly of this random number, calculate synchronized counter value with frame hopping; 5) itself and readout are compared, if it carries out 7 greater than readout and difference in specified scope), otherwise carry out 6); 6) will be by 4) synchronized counter value that calculates is temporary, once receive again, promptly since 1) to 5), if new value carries out 7 than temporary value big 1), otherwise carry out 8); 7) think and receive successfully, new synchronized counter value is write to refresh EEPROM, carry out the desired operation of key information in the code word first simultaneously, finish.8) think and take defeat, judge whether to have passed through the several times sequence number relatively effectively and the deciphering failure,, otherwise directly carry out alarm signal if then judge and receive that scanning attack, output alarm signal also return.
Mode of learning: (referring to Fig. 7),
Mode of learning is primarily aimed at new electron key, and the information of automotive interior is upgraded, and comprising: product ID, decruption key and coincidence counter etc.In mode of learning, we consider its receiving code separated into two parts: the 16bit of first random number, second portion 16bit random number XOR coincidence counter.Under the mode of learning, concrete decoding step is: 1) receive, obtain the 64bit code word; 2) from EEPROM, read trading company of factory and F
m, calculate the decruption key that makes new advances by new sequence number and algorithm decruption key, and temporary this sequence number and decruption key; 3) obtain expressly corresponding with new decruption key deciphering frame hopping information; 4) carry out xor operation with corresponding expressly first and second portion, calculate synchronized counter value, and it is temporary; 5) receive the code word of a 64bit once more; 6) with its sequence number and primary comparing, identical execution 7), otherwise carry out 10); 7) obtain expressly with decruption key deciphering frame hopping information; 8) expressly first and second portion carry out the synchronized counter value that XOR obtains this time; 9) with itself and comparing last time, if than last time just big 1 carry out 10), otherwise carry out 11); 10) think learning success, new sequence number, synchronized counter value, decruption key are write to refresh EEPROM, finish.11) think study failure, do not do any operation, finish.
The generation method of key:
The generating mode of encryption key and decruption key is as follows.
Generate encryption key: Cryptkey*DecryKey=1 (mod Fm) promptly: encryption key and decruption key finite field multiply each other long-pending be 1.
Generating solution decryption key: DecryKey=SerialNumber*ManufactureID (mod Fm) is promptly: unique sign that decruption key equals sequence number and manufacturer finite field multiply each other long-pending.