Summary of the invention
Hach coprocessor of the present invention designs for realizing data encrypting and deciphering computing and signature verification, it supports block cipher system and HASH computing, support high low speed data-interface and pipeline organization, can realize function combinations such as single grouping, single Hash, elder generation's grouping back Hash and while Hach, have very strong practicality.
The hardware component of realizing this function comprises: grouping arithmetic element, Hash operation unit, low speed data interface read-write control unit, high speed interface processing unit (being made up of input FIFO1 and output FIFO2), coprocessor key control unit and dual port RAM, inner FIFO3, command register, piece number register, parameter register, grouping input buffer register Inda and a grouping output buffer Outda etc.
This coprocessor is supported high speed interface and low speed data interface simultaneously, and the high-speed data mouth is supported the input of 32 bit data, and the low speed data mouth is supported the input of 8,16,32 bit data.
Wherein dual port RAM, command register, piece number register and parameter register all carry out unified addressing respectively to low speed data mouth ppu and innernal CPU, so that by address wire control it is conducted interviews.
Order, piece number and parameter are only by the input of low speed data interface, and required plaintext or the ciphertext of encryption and decryption both can also can be imported by the high-speed data mouth by the input of low speed data mouth.
Encryption and decryption data is followed the principle of where going back and forth from which, if promptly expressly advance from the low speed data mouth, then ciphertext also goes out from the low speed data mouth, advances from the high-speed data mouth, then goes out from the high-speed data mouth.
When encryption and decryption data was imported by the low speed data mouth, the outside will be sent out piece number, parameter and encryption and decryption data earlier, and then says the word; When encryption and decryption data was imported by high speed interface, the low speed data interface was still followed the sequencing of piece number → parameter → order, but carried encryption and decryption data not have sequencing with the high-speed data mouth, and both can independently carry out.
This coprocessor is supported to divide into groups simultaneously and fill and outside the filling inside of Hash.
The piece number that the piece number register is deposited is to be got divided by 32 by the plaintext that participates in encryption and decryption or the bit number of ciphertext, doing grouping separately, Hach is done and earlier under the situation of grouping back Hash simultaneously, piece numerical table during outside the filling shows the later length of grouping filling, and the piece numerical table during inner the filling shows the true length of grouped data; When doing Hash separately, the piece numerical table during outside the filling shows the later length of Hash filling, and the piece numerical table during inner the filling shows the true length of Hash data.
Order is to give the coprocessor key control unit after being resolved by innernal CPU, carries out the control of corresponding computing, can support the user defined command agreement by revising software like this.
When same group of data being divided into groups simultaneously,,, introduce an inner FIFO3 and come data are carried out buffer memory to prevent loss of data in the porch of hash units for solving grouping and the unmatched problem of Hash operation speed with Hash operation.
When dividing into groups computing, be raising speed, the coprocessor key control unit is introduced pipeline organization, promptly sends out data → send out and enables → give one group of data → detections done → read data → enable, and utilizes to be ready to next operation time and to organize pending data.
When data are imported by the low speed data interface, data are moved from RAM in the coprocessor key control unit by innernal CPU, in like manner operation result is also moved among the RAM by innernal CPU, the convenient so spontaneous situation of carrying out computing of innernal CPU of supporting, only need write-in block number → parameter → order successively, send pending data to the coprocessor key control unit again and get final product.
In this coprocessor, owing to support the computing of multitude of different ways and speed, need shake hands in a large number, introduce handshake register, as to write fashionable flag be 1, flag is 0 when reading.Outside from low speed data interface write command register, flag is 1, it is 1 that innernal CPU detects flag, the indication outside has write new order, then take out and resolve, flag becomes 0 simultaneously, and external detection becomes 0 to flag, represent that then command analysis finishes, next new order can be continued to send in the outside.
This coprocessor is supported following all kinds of instructions: the selection of data inlet, mode of operation selection, algorithm selection, encryption and decryption selection, encryption and decryption model selection, key length selection and Hash length are selected.
The workflow of this coprocessor may further comprise the steps:
(1) outsidely sends out piece number, parameter, pending data and order.Wherein pending data can go into also to go into from high speed interface from the low speed data interface, and inlet selection information is included in the order.
(2) innernal CPU resolve command, and analysis result sent into key control unit.
(3) the key control unit judgment data is advanced from the low speed data interface, then forwards (4) to, and data are advanced from high speed interface, then forwards (16) to, and to be that innernal CPU is spontaneous send data, then forwards (4) to.
(4) as singly doing grouping, forward (5) to, singly do Hash, forward (7) to, Hach is done simultaneously, forwards (10) to, and grouping back Hash forwards (13) to earlier.
(5) receive data that innernal CPU sends here in Inda, send enable signal, change (6) to grouped element.
(6) wait for when grouping done signal is effective, the output result, reading for innernal CPU (is the situations of being gone into by the low speed data interface as data, the result also will be sent to dual port RAM by innernal CPU, read for the outside), count judgment data according to piece simultaneously and whether all handle, as do not have, then change (5), finish as handling then.
(7) receive the data that innernal CPU is sent here, send among the inside FIFO3 of Hash porch, and send enable signal to hash units.Change (8).
(8) hash units is received enable signal, according to piece numerical control system internally among the FIFO3 peek carry out computing, all handle up to data, change (9).
When (9) the done signal of coprocessor wait Hash was effective, the output result read (as data are the situations of being gone into by the low speed data interface, and the result also will be sent to dual port RAM by innernal CPU, reads for the outside) for innernal CPU.
(10) receive the data that innernal CPU is sent here,, data are delivered among Inda and the inner FIFO3 simultaneously, and sent enable signal to grouped element and hash units when FIFO3 is non-when full.Change (11).
When (11) detection grouping done signal is effective, the output result, reading for innernal CPU (is the situations of being gone into by the low speed data interface as data, the result also will be sent to dual port RAM by innernal CPU, reads for the outside), count judgment data according to piece simultaneously and whether all handle, as do not have, then change (10),, then change (12) as handling.
When (12) detection Hash done signal was effective, the output result read (as data are the situations of being gone into by the low speed data interface, and the result also will be sent to dual port RAM by innernal CPU, reads for the outside) for innernal CPU.
(13) receive data that innernal CPU sends here in Inda, send enable signal, also send enable signal simultaneously to hash units to grouped element.Change (14).
(14) wait for when grouping done signal is effective, group result is moved among the inside FIFO3 of Hash porch, handle for hash units, it (is the situations of being gone into by the low speed data interface as data that the while result is read away by innernal CPU, the result also will be sent to dual port RAM by innernal CPU, reads for the outside).Count judgment data according to piece and whether all handle, then change in this way (15), otherwise change (13).
(15) wait for that when Hash done signal was effective, the output result read (as data are the situations of being gone into by the low speed data interface, and the result also will be sent to dual port RAM by innernal CPU, reads for the outside) for innernal CPU.
(16) as singly doing grouping, forward (17) to, singly do Hash, forward (21) to, Hach is done simultaneously, forwards (24) to, and grouping back Hash forwards (29) to earlier.
(17) from high speed interface input FIFO1, receive data in Inda, change (18).
(18) send enable signal to grouped element.Change (19).
(19) receive next group data from high speed interface input FIFO1 in Inda, the computing of dividing into groups simultaneously realizes water operation, changes (20).
(20) wait for when grouping done signal is effective, output results among the output FIFO2, read, count judgment data according to piece simultaneously and whether all handle, as do not have, then change (18), finish as handling then for the high speed interface outside.
(21) from high speed interface input FIFO1, receive data, send among the inside FIFO3 of Hash porch, and send enable signal to hash units.Change (22).
(22) hash units is received enable signal, according to piece numerical control system internally among the FIFO3 peek carry out computing, all handle up to data, change (23).
When (23) the done signal of coprocessor wait Hash is effective, output results among the output FIFO2, read for the high speed interface outside.
(24) from high speed interface input FIFO1, receive data,, data are delivered among Inda and the inner FIFO3 simultaneously, change (25) when FIFO3 is non-when full.
(25) send enable signal to grouped element and hash units, change (26).
(26) from high speed interface input FIFO1, receive next group data,, data are delivered among Inda and the inner FIFO3 simultaneously, divide into groups simultaneously and Hash operation, realize water operation, change (27) when FIFO3 is non-when full.
Whether when (27) detection grouping done signal is effective, output results to output FIFO2, read for the high speed interface outside, count judgment data according to piece simultaneously and all handle, as do not have, then commentaries on classics (25) as handling, is then changeed (28).
When (28) detection Hash done signal is effective, output results to output FIFO2, read for the high speed interface outside.
(29) receive data to Inda from high speed interface input FIFO1, change (30).
(30) send enable signal to grouped element, also send enable signal simultaneously to hash units.Turn to (31).
(31) receive next group data to Inda from high speed interface input FIFO1, the computing of dividing into groups simultaneously realizes water operation, turns to (32)
(32) wait for when grouping done signal is effective, group result is outputed to FIFO2, read for the high speed interface outside, the result also is shifted among the inside FIFO3 of Hash porch simultaneously, handles for hash units.
Count judgment data according to piece then and whether all handle, then change in this way (33), otherwise change (30).
(33) wait for when Hash done signal is effective, output results to output FIFO2, read for the high speed interface outside.As seen from the above description, the present invention has the following advantages:
(1) supports high speed and low-speed interface simultaneously, satisfy the needs under user's different condition;
(2) support multiple block cipher;
(3) support multiple hash algorithm;
(4) be speed up processing, adopt pipeline organization;
(5) support the inside of grouping and Hash to fill and outside the filling simultaneously, use more flexible;
(6) support the user to come the custom command agreement by revising software;
(7) support to carry out simultaneously block cipher and Hash operation;
When (8) being supported in the outside and obtaining encrypted result, also obtain corresponding Hash operation result.
Embodiment
The structure of being set forth in the concrete enforcement fundamental sum of the present invention specification of the present invention is consistent with principle.Below in conjunction with accompanying drawing, specify the present invention.
The invention discloses a kind of implementation of Hach coprocessor, its hardware component comprises: grouping arithmetic element, Hash operation unit, low speed data interface read-write control unit, high speed interface processing unit (being made up of input FIFO1 and output FIFO2), coprocessor key control unit and dual port RAM, inner FIFO3, command register, piece number register, parameter register, grouping input buffer register Inda and a grouping output buffer Outda etc.
See also the solid line boxes part of accompanying drawing 1, the hardware component structural representation that it utilizes said structure to realize for the present invention.According to this schematic diagram, this hardware component is made of above-mentioned several sections.
The wherein low speed data interface read-write control unit read-write that comes control data according to the bit wide (8bits, 16bits, 32bits) and the address of low speed data interface.
Dual port RAM carries out the buffer unit of transfer of data as low speed data interface and inner cpu processor, respectively low speed data interface ppu and inner cpu processor are carried out unified addressing with command register, piece number register, parameter register, so that inside and outside to its visit.
Input FIFO1 and output FIFO2 form high speed interface, buffer unit as high speed interface transmission data, Inda and Outda carry out the buffer unit of transfer of data as coprocessor key control unit and grouping arithmetic element, and inner FIFO3 carries out the buffer unit of transfer of data as coprocessor key control unit and Hash operation unit.
The coprocessor key control unit is the maincenter of whole coprocessor, and he is responsible for control and finishes all kinds of computings, as: Hash, Hach are done etc. simultaneously after single grouping, single Hash, the grouping earlier.
Following conjunction with figs. is further set forth the specific embodiment of the present invention.
This coprocessor externally divides low speed data interface and high speed interface, support the situation of the spontaneous computing of inner cpu simultaneously, because data are fashionable by the low speed data interface, all do transfer and enter core processing unit through inner cpu, so the situation of the spontaneous computing of inner cpu is included in the middle of the situation that data are gone into by the low speed data interface, so we introduce data and are gone into the low speed data interface to go into two kinds of situations by high speed interface at this.
(1) situation of being gone into by high speed interface for data referring to accompanying drawing 2, may further comprise the steps:
(1) send out piece number, parameter and order successively by the low speed data interface, pending data are entered by the high speed FIFO mouth simultaneously.
(2) innernal CPU resolve command, and analysis result sent into key control unit.
(3) key control unit is judged as is singly done grouping, forwards (4) to, singly does Hash, forwards (8) to, and Hach is done simultaneously, forwards (11) to, and grouping back Hash forwards (16) to earlier.
(4) from high speed interface input FIFO1, receive data in Inda.
(5) send enable signal to grouped element.
(6) receive next group data from high speed interface input FIFO1 in Inda, the computing of dividing into groups simultaneously realizes water operation.
(7) wait for when grouping done signal is effective, output results among the output FIFO2, read, count judgment data according to piece simultaneously and whether all handle, as do not have, then change (5),, then finish as handling for the high speed interface outside.
(8) from high speed interface input FIFO1, receive data, send among the inside FIFO3 of Hash porch, and send enable signal to hash units.
(9) hash units is received enable signal, according to piece numerical control system internally among the FIFO3 peek carry out computing, all handle up to data.
When (10) the done signal of coprocessor wait Hash is effective, output results among the output FIFO2, read for the high speed interface outside.
(11) from high speed interface input FIFO1, receive data,, data are delivered among Inda and the inner FIFO3 simultaneously when FIFO3 is non-when full.
(12) send enable signal to grouped element and hash units.
(13) from high speed interface input FIFO1, receive next group data,, data are delivered among Inda and the inner FIFO3 simultaneously, divide into groups simultaneously and Hash operation, realize water operation when FIFO3 is non-when full.
Whether when (14) detection grouping done signal is effective, output results to output FIFO2, read for the high speed interface outside, count judgment data according to piece simultaneously and all handle, as do not have, then commentaries on classics (12) as handling, is then changeed (15).
When (15) detection Hash done signal is effective, output results to output FIFO2, read for the high speed interface outside.
(16) receive data to Inda from high speed interface input FIFO1.
(17) send enable signal to grouped element, also send enable signal simultaneously to hash units.
(18) receive next group data to Inda from high speed interface input FIFO1, the computing of dividing into groups simultaneously realizes water operation.
(19) wait for when grouping done signal is effective, group result is outputed to FIFO2, read for the high speed interface outside, the result also is shifted among the inside FIFO3 of Hash porch simultaneously, handles for hash units.
Count judgment data according to piece then and whether all handle, then change in this way (20), otherwise change (17).
(20) wait for when Hash done signal is effective, output results to output FIFO2, read for the high speed interface outside.
(2) situation of being gone into by the low speed data interface for data referring to accompanying drawing 3, may further comprise the steps:
(1) outside distribute piece number, parameter, pending data by the low speed data interface after, say the word again.
(2) innernal CPU resolve command, and analysis result sent into key control unit.
(3) key control unit is judged as is singly done grouping, forwards (4) to, singly does Hash, forwards (6) to, and Hach is done simultaneously, forwards (9) to, and grouping back Hash forwards (12) to earlier.
(4) receive data that innernal CPU sends here in Inda, send enable signal to grouped element.
(5) wait for that the output result was sent to dual port RAM by innernal CPU, reads for the outside when grouping done signal was effective, count judgment data according to piece simultaneously and whether all handle, as do not have, then change (4),, then finish as handling.
(6) receive the data that innernal CPU is sent here, send among the inside FIFO3 of Hash porch, and send enable signal to hash units.
(7) hash units is received enable signal, according to piece numerical control system internally among the FIFO3 peek carry out computing, all handle up to data.
When (8) the done signal of coprocessor wait Hash was effective, the output result was sent to dual port RAM by innernal CPU, reads for the outside.
(9) receive the data that innernal CPU is sent here,, data are delivered among Inda and the inner FIFO3 simultaneously, and sent enable signal to grouped element and hash units when FIFO3 is non-when full.。
Whether when (10) detection grouping done signal was effective, the output result was sent to dual port RAM by innernal CPU, reads for the outside, count judgment data according to piece simultaneously and all handle, as do not have, and then changeed (9), as handling, and then commentaries on classics (11).
When (11) detection Hash done signal was effective, the output result was sent to dual port RAM by innernal CPU, reads for the outside.
(12) receive data that innernal CPU sends here in Inda, send enable signal, also send enable signal simultaneously to hash units to grouped element.
Wait for when grouping done signal is effective (13), group result moved among the inside FIFO3 of Hash porch that handle for hash units, the result is sent to dual port RAM by innernal CPU simultaneously, reads for the outside.Count judgment data according to piece and whether all handle, then change in this way (14), otherwise change (12).
(14) wait for that when Hash done signal was effective, the output result was sent to dual port RAM by innernal CPU, reads for the outside.