CN104993932B - A kind of method for improving signature safety - Google Patents

A kind of method for improving signature safety Download PDF

Info

Publication number
CN104993932B
CN104993932B CN201510345822.8A CN201510345822A CN104993932B CN 104993932 B CN104993932 B CN 104993932B CN 201510345822 A CN201510345822 A CN 201510345822A CN 104993932 B CN104993932 B CN 104993932B
Authority
CN
China
Prior art keywords
signature
hash algorithm
signed
host computer
default
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510345822.8A
Other languages
Chinese (zh)
Other versions
CN104993932A (en
Inventor
陆舟
于华章
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Feitian Technologies Co Ltd
Original Assignee
Feitian Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Feitian Technologies Co Ltd filed Critical Feitian Technologies Co Ltd
Priority to CN201510345822.8A priority Critical patent/CN104993932B/en
Publication of CN104993932A publication Critical patent/CN104993932A/en
Application granted granted Critical
Publication of CN104993932B publication Critical patent/CN104993932B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Storage Device Security (AREA)

Abstract

The invention discloses a kind of method for improving signature safety, belong to information security field, this method includes:When equipment obtains signature algorithm and signature key from host computer, current hash algorithm is set according to the signature algorithm of acquisition, currently assigned key is set according to the signature key of acquisition;When equipment obtains summary to be signed from host computer, judge whether to meet the first preset condition and the second preset condition at the same time, it is to preserve the summary to be signed, data are carried out according to object identifier to the summary to be signed of preservation to splice to obtain data splicing result, signed using currently assigned key to the data splicing result calculate the signature as a result, returning to the signature result to host computer;Otherwise mistake is returned to host computer.Method provided by the invention improves the security of signature, can effectively prevent from deceiving label behavior.

Description

A kind of method for improving signature safety
Technical field
The present invention relates to information security field, more particularly to a kind of method for improving signature safety.
Background technology
With the fast development of information industry, internet bank trade has become a part for people's life or work, Therefore the security of network has just increasingly constituted focus of concern.In order to ensure network data will not be by transmitting procedure , there is digital signature technology in people's malicious modification.Digital signature technology is the technology for carrying out authentication.With this technology Development and application, especially during Web bank is traded, the signature process of data is had evolved to can be one Carried out in kind intelligent cipher key equipment (USBKey).
In the prior art, USBKey can perform transaction data and nontransaction data signature, and at present USBKey should Authentication scheme in not to forgery as the nontransaction data of transaction data, if gaining label by cheating using nontransaction data by hacker Name, it will cause any property loss to user.
The content of the invention
What is occurred in the prior art in order to prevent pretends to be what transaction data reached to deceive label behavior, the present invention with nontransaction data Propose a kind of method for improving signature safety.
The technical solution adopted by the present invention is as follows:A kind of method for improving signature safety, including:
When equipment obtains signature algorithm and signature key from host computer, set according to the signature algorithm of acquisition current Hash algorithm, currently assigned key is set according to the signature key of acquisition;
When equipment obtains summary to be signed from host computer, step A is performed;
Step A:Judge whether to meet the first preset condition and the second preset condition at the same time, be to preserve described to be signed pluck Will, perform step B;Otherwise mistake is returned to host computer;
First preset condition is:The length of summarization that the length of the summary to be signed is supported with current hash algorithm Match somebody with somebody, and current hash algorithm and what is stored in the first memory block first preset one of hash algorithm and match;
Second preset condition is:The length of summarization that current hash algorithm is supported is less than all summed results, or works as The length of summarization that preceding hash algorithm is supported is more than or equal at least one summed result and the summary to be signed and does not include object Identifier;The summed result is equal to the sum of the length of summarization of the second default hash algorithm support and the length of object identifier;
Step B:Data are carried out according to the object identifier to the summary to be signed of preservation to splice to obtain data spelling Binding fruit;
The method further includes, and equipment performs signature operation, and the signature operation is specially:Use currently assigned key pair The data splicing result calculate the signature obtains signature result, and the signature result is returned to host computer.
The method further includes:The equipment performs initialization operation:Open up the first default Hash of the first memory block storage Algorithm, opens up the second default hash algorithm of the second memory block storage.
The step A is further included:Judge whether current hash algorithm is consistent with the second default hash algorithm, is then to upper Machine returns to mistake, otherwise performs the step B.The judgement can in no particular order sequentially with judgement included in step A.
The method further includes:The equipment performs initialization operation, and the initialization operation is specially:First is opened up to deposit The first default hash algorithm of storage area storage, opens up the second default hash algorithm of the second memory block storage, initializes default mark and is It is invalid;The method further includes:The equipment performs generation key:Generation Key pair simultaneously preserves, and it is effective to put default mark;Also wrapped when judging that current hash algorithm is consistent with the second default hash algorithm Include, judge whether default mark is effective, is to preserve the summary to be signed, performs the step B, is otherwise returned to host computer Mistake.
The method further includes:When equipment obtains data to be signed from host computer, perform:Judging current hash algorithm is It is no consistent with the second default hash algorithm, it is that carrying out Hash calculation to the data to be signed using current hash algorithm obtains Summary to be signed simultaneously preserves, and then carrying out data to the summary to be signed of preservation according to object identifier splices to obtain data Splicing result;Otherwise mistake is returned to host computer.
When equipment obtains display data from host computer, the display data is saved in display caching;
The equipment further includes before performing signature operation:Judge whether be stored with display data in display caching, be then The display data is obtained from display caching to be shown, is performed the signature operation after user confirms, is otherwise directly held The row signature operation.
Above-mentioned object identifier is the preset data that length is 15 bytes.
Can be that the equipment obtains the signature calculation from least one instruction that host computer issues in the above method Method, the signature key, the summary to be signed.
Either, the equipment obtains the signature algorithm, the signature from least one instruction that host computer issues Key, the data to be signed.
It is above-mentioned to judge whether to meet that the first preset condition and the second preset condition be specially at the same time:
Step 1:Judge whether the length of the summary to be signed matches with the length of summarization of current hash algorithm support, be Step 2 is then performed, is otherwise judged as being unsatisfactory for the first preset condition;
Step 2:The default hash algorithm of first stored in the first memory block is traveled through, if in the presence of consistent with current hash algorithm The first default hash algorithm then perform step 3, be otherwise judged as being unsatisfactory for the first preset condition;
Step 3:The default hash algorithm of second stored in the second memory block is traveled through, if being satisfied by:Current hash algorithm branch The length of summarization held is less than the sum of the length of summarization of the second default hash algorithm support and the length of object identifier, then is judged as Meet the first preset condition and the second preset condition, otherwise perform step 4;
Step 4:Judge whether include object identifier in summary to be signed, be to be judged as being unsatisfactory for the second default bar Part, is otherwise judged as meeting the first preset condition and the second preset condition.
Further included before above-mentioned steps A and each second default hash algorithm stored in the second memory block is carried out such as respectively Lower calculating:Calculate the sum of the length of summarization of the second default hash algorithm support and the length of object identifier and obtain summed result.
What technical solution provided by the invention reached has the beneficial effect that:The security of signed data is improved, is effectively prevented Deceive label behavior.
Brief description of the drawings
Fig. 1 is a kind of method flow diagram for raising signature safety that embodiment 1 provides;
Fig. 2 is a kind of method flow diagram for raising signature safety that embodiment 3 provides;
Fig. 3 is a kind of method flow diagram for raising signature safety that embodiment 4 provides.
Embodiment
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, those of ordinary skill in the art are obtained every other without making creative work Embodiment, belongs to the scope of protection of the invention.
A kind of method for improving signature safety provided by the invention, by the improvement to USBKey internal processes, is realized USBKey does further verification processing to the received relevant operational order of signature, so as to improve signature safety, such as performs The first default Hash instruction involved by nontransaction signature, performs the second default Hash instruction involved by trading signature, and Other relevant initialization directives, set security context to instruct (i.e. MSE instructions), generation key to instruction, signature command etc..This In embodiment, the supported hash algorithm of nontransaction signature is referred to as the first default hash algorithm, the Kazakhstan that trading signature is supported Uncommon algorithm is referred to as the second default hash algorithm.
Embodiment 1
A kind of method for improving signature safety provided in this embodiment, a signature behaviour is issued by host computer to equipment Make instruction to realize, wherein, performed if include in nontransaction then signature operation instruction of signing needed for signature operation Signature algorithm, signature key and summary to be signed, label are performed if being traded signature and then including during the signature operation instructs Signature algorithm, signature key and data to be signed needed for name operation.
The method provided in this embodiment, including:
As shown in Figure 1, when equipment receives the signature operation instruction that host computer issues, parse the signature operation and refer to Order, therefrom obtains signature algorithm, signature key and summary to be signed, and does following operation:
Step S1:Current hash algorithm is set according to the signature algorithm of acquisition, according to the signature key of acquisition Currently assigned key is set;
Step S2:Judge whether to meet the length of summarization that the length of the summary to be signed is supported with current hash algorithm Match somebody with somebody, and current hash algorithm is consistent with the first default hash algorithm, is then to perform step S3, otherwise returns to mistake to host computer;
Step S3:Judge whether the length of summarization that current hash algorithm is supported is more than or equal to the second default hash algorithm support Length of summarization and object identifier the sum of length, if more than being equal to and including the object mark in the summary to be signed Know symbol, then return to mistake to host computer, otherwise preserve the summary to be signed;
Step S4:Data are carried out to the summary to be signed to splice to obtain data splicing result, make according to object identifier Signature result is obtained to the data splicing result calculate the signature with currently assigned key, returning to the signature to host computer ties Fruit.
Either, when equipment receives the signature operation instruction that host computer issues, the signature operation instruction is parsed, from Middle acquisition signature algorithm, signature key and data to be signed, and do following operation:
Step s1:Current hash algorithm is set according to the signature algorithm of acquisition, according to the signature key of acquisition Currently assigned key is set;
Step s2:Judge whether current hash algorithm is consistent with the second default hash algorithm, is calculated using current Hash Method to the data to be signed carry out Hash calculation obtain summary to be signed, according to object identifier to it is described it is to be signed make a summary into Row data are spliced to obtain data splicing result and are preserved, and perform step s3, otherwise return to mistake to host computer;
Step s3:Equipment obtains the data splicing result calculate the signature of preservation using currently assigned key signature knot Fruit, the signature result is returned to host computer.
In the present embodiment, further included before the step S1 and step s1:The equipment performs initialization operation, described first Beginningization operation is specially:The first default hash algorithm of the first memory block storage is opened up, it is default to open up the second memory block storage second Hash algorithm.
Further, at least one first default hash algorithm, the second default storage can be stored with the first memory block At least one second default hash algorithm can be stored with area.
When it is two or more that first stored in the first memory block, which presets hash algorithm, above-mentioned steps S2 can be with Specially:The length for judging whether to meet the summary to be signed is matched with the length of summarization that current hash algorithm is supported, and is worked as Preceding hash algorithm is consistent with least one first default hash algorithm in the first memory block, is then execution step S3, otherwise to Host computer returns to mistake;
When it is two or more that second stored in the second memory block, which presets hash algorithm, above-mentioned steps S3 can be with Specially:The second default hash algorithm in the second memory block is traveled through, judges whether to be satisfied by:What current hash algorithm was supported plucks Want length<The length for length of summarization+object identifier that second default hash algorithm is supported, preserves if being satisfied by and described waits to sign Name summary, otherwise determine whether include the object identifier in the summary to be signed, if comprising if to host computer Mistake is returned, the summary to be signed is preserved if not including.
Above-mentioned steps s2 can be specially:Judge current hash algorithm whether with least one second in the second memory block Default hash algorithm is consistent, is, carrying out Hash calculation to the data to be signed using current hash algorithm obtains to be signed pluck Will, data are carried out to the summary to be signed according to object identifier and splices to obtain data splicing result and preserves, perform step S3, otherwise returns to mistake to host computer.
Embodiment 2
A kind of method for improving signature safety provided in this embodiment, a plurality of signature phase is issued by host computer to equipment The operational order of pass realizes, the relevant operational order of signature includes setting security context to instruct (i.e. MSE instructions), first pre- If Hash instruction, the second default Hash instruction, signature command.
The method provided in this embodiment, including:
When equipment receives the MSE instructions that host computer issues, step S1 is performed;When equipment receives what host computer issued During the first default Hash instruction, step S2 is performed;When equipment receives the signature command that host computer issues, step S4 is performed;
Step S1:The MSE instructions are parsed, signature algorithm and signature key are therefrom obtained, according to the signature of acquisition Algorithm sets current hash algorithm, sets currently assigned key according to the signature key of acquisition, and return to MSE to host computer Instruction response;
Step S2:The described first default Hash instruction is parsed, summary to be signed is therefrom obtained, judges whether to treat described in satisfaction The length of signature digest is matched with the length of summarization that current hash algorithm is supported, and current hash algorithm and the first default Hash are calculated Method is consistent, is then to perform step S3, otherwise returns to mistake to host computer;
Step S3:Judge whether the length of summarization that the first default hash algorithm is supported is more than or equal to the second default hash algorithm The sum of the length of summarization of support and the length of object identifier, it is described right if more than being equal to and including in the summary to be signed As identifier, then mistake is returned to host computer, otherwise preserve the summary to be signed, and the first default Hash is returned to host computer Instruction response;
Step S4:Data are carried out to the summary to be signed to splice to obtain data splicing result, make according to object identifier Signature result is obtained to the data splicing result calculate the signature of preservation with currently assigned key, and returns and includes to host computer The signature command response of the signature result.
Further, when equipment receives the second default Hash instruction that host computer issues, perform:Parse described second Default Hash instruction, therefrom obtains data to be signed, judges whether current hash algorithm is consistent with the second default hash algorithm, is Then Hash calculation is carried out to the data to be signed using current hash algorithm to obtain summary to be signed and preserve, and to host computer Return to the second default Hash instruction response;Otherwise mistake is returned to host computer.
The method further includes:When equipment receives the initialization directive that host computer issues, the equipment performs initial Change operation, the initialization operation is specially:The first default hash algorithm of the first memory block storage is opened up, opens up the second memory block The default hash algorithm of storage second.It is preferable in the present embodiment, one first default hash algorithm is stored with the first memory block, One second default hash algorithm is stored with second memory block.
Embodiment 3
It is different that method provided in this embodiment, which is suitable for hash algorithm used in trading signature and nontransaction signature, The application environment of algorithm, as shown in Fig. 2, a kind of method for improving signature safety provided in this embodiment, with consolidating for USBKey It is introduced, comprises the following steps exemplified by part workflow:
Step 101:USBKey receives the instruction that host computer issues;
Step 102:The type of instruction received is judged, if initialization directive then performs step 103, if MSE refers to Order then performs step 105, if the first default Hash instruction then performs step 107, if the second default Hash instruction then performs Step 114, if signature command then performs step 118;
It is initialization directive if 84 e4 07 00 are equal to specifically, judging preceding 4 bytes of instruction received, if Then instructed equal to 00 22 41 b6 for MSE, if presetting Hash instruction equal to if 00 2a 90 81 for first, if being equal to 00 2a 90 80 are the second default Hash instruction, are signature command if 00 2a 9e 00 are equal to.First is pre- described in the present embodiment Instructed if Hash instruction can be certificate download signed Hash, the described second default Hash instruction can be that trading signature Hash refers to Order.
For example, the data format of above-mentioned each instruction is specific as follows:
Initialization directive:84 e4 07 00 Lc data
MSE is instructed:00 22 41 b6 Lc data
First default Hash instruction:00 2a 90 81 Lc data
Second default Hash instruction:00 2a 90 80 Lc data
Signature command:00 2a 9e 00 00
Wherein, Lc is data field data length, represents the length value of data numeric field data data.
Step 103:The first default hash algorithm of the first memory block storage is opened up, it is default to open up the second memory block storage second Hash algorithm;
It is preferable in the present embodiment, one first default hash algorithm is stored with the first memory block, in the second memory block One second default hash algorithm is stored with, and the first default hash algorithm is two kinds of different Kazakhstan from the second default hash algorithm Uncommon algorithm.
For example, the first default hash algorithm stored in the present embodiment in the first memory block is SSL (Secure Socket Layer) Algorithm used in login (i.e. SHA1+MD5), the second default hash algorithm stored in the second memory block is SHA1.
Step 104:Initialization directive response is returned to host computer, is then back to step 101;
Specifically, status word of the initialization directive response for two bytes, for example, initialization directive is upward after running succeeded Position machine returns to 90 00.
Step 105:Parse the MSE instructions and obtain signature algorithm and signature key, the signature algorithm obtained according to parsing Current hash algorithm is set, and the signature key obtained according to parsing sets currently assigned key;
Specifically, parsing the data numeric field data of the MSE instructions, signature algorithm and signature key are therefrom obtained, and will obtain The signature algorithm taken is arranged to current hash algorithm, and the signature key of acquisition is arranged to currently assigned key.
For example, the MSE instructions received are 00 22 41 B6 07 80 01 12 84 02 02 23;Wherein data field Data length Lc values are 07, and data numeric field data data is 80 01 12 84 02 02 23, and parsing the data numeric field data can obtain To two TLV structures 80 01 12 and 84 02 02 23, wherein the data numeric field data 12 in first TLV structure represents signature Algorithm SHA1, the data numeric field data 02 23 in second TLV structure represents key ID and Key Tpe respectively, according to described close Key ID and Key Tpe obtain signature key.
Step 106:MSE instruction responses are returned to host computer, are then back to step 101;
Specifically, status word of the MSE instructions response for two bytes, for example, MSE instructions run succeeded, backward host computer returns Return 90 00.
Step 107:Parse the described first default Hash instruction and obtain summary to be signed;
Specifically, the default Hash instruction of parsing described first, the data numeric field data parsed is summary to be signed.
For example, the first default Hash instruction received is 00 2A, 90 81 24 00 30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14 67 42 3e bf a8 45 4f 19 ac 6f 46 86 d6 c0 dc 73 1a 3d Dd 6b, wherein data field data length Lc values are 0x24, that is, numerical value 36, and data numeric field data, that is, summary to be signed is 00 30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14 67 42 3e bf a8 45 4f 19 ac 6f 46 86 d6 c0 dc 73 1a 3d dd 6b。
Step 108:Judge whether the length of the summary to be signed matches with the length of summarization of current hash algorithm support, It is then to perform step 109, otherwise returns to mistake to host computer, be then back to step 101;
Specifically, judging whether the length of the summary to be signed is equal to the length of summarization that current hash algorithm is supported, it is Step 109 is then performed, otherwise mistake is returned to host computer, is then back to step 101.
For example, the length of the summary to be signed is 20 bytes, the length of summarization that current hash algorithm SHA1 is supported is 20 Byte, then the length of the summary to be signed matched with the length of summarization that current hash algorithm is supported.
Step 109:Judge whether current hash algorithm is consistent with the first default hash algorithm, is then to perform step 110, it is no Mistake then is returned to host computer, is then back to step 101;
For example, it is specially to return to 00 00 to host computer to return to mistake to host computer.
Step 110:Judge whether the length of summarization that current hash algorithm is supported is more than or equal to the second default hash algorithm branch The sum of the length of summarization held and the length of object identifier, are then to perform step 111, otherwise perform step 112;
For example, it is 36 words that current hash algorithm, that is, SSL (Secure Socket Layer), which logs in the length of summarization for using algorithm to support, Section, specifically, OPENSSL define SSL log in used in algorithm be SHA1+MD5;Second default hash algorithm SHA1 is supported Length of summarization be 20 bytes, the length of object identifier (OID) is 15 bytes.
Step 111:Judge whether include the object identifier in the summary to be signed, be then to be returned to host computer Mistake, is then back to step 101;Otherwise step 112 is performed;
In the present embodiment, the object identifier OID is:30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14。
For example, the summary to be signed included in the first default hash algorithm is 00 30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14 67 42 3e bf a8 45 4f 19 ac 6f 46 86 d6 c0 dc 73 1a 3d dd 6b, wherein including 30 21 30 09 06 05 2b 0e, 03 02 1a 05 00 04 14 includes OID.
Step 112:The summary to be signed is preserved, treating signature digest progress data according to object identifier splices to obtain Data splicing result simultaneously preserves;
Step 113:The first default Hash instruction response is returned to host computer, is then back to step 101;
Specifically, status word of the first default Hash instruction response for two bytes, for example, the first default Hash instruction is held Successfully backward host computer of going returns to 90 00.
Step 114:Parse the described second default Hash instruction and obtain data to be signed;
For example, the second default Hash instruction is:00 2a, 90 80 Lc data, the data for parsing acquisition are number to be signed According to.
Step 115:Judge whether current hash algorithm is consistent with the second default hash algorithm, is then to perform step 116, it is no Mistake then is returned to host computer, is then back to step 101;
Step 116:Hash calculation is carried out to the data to be signed using current hash algorithm and obtains summary to be signed, root Signature digest is treated according to object identifier carry out data splice to obtain data splicing result and preserve;
For example, the summary to be signed being calculated is:1 d 11 f667 f21612416793 c77d 0b 232b 5b 3c ae 426d。
Step 117:The second default Hash instruction response is returned to host computer, is then back to step 101;
Specifically, status word of the second default Hash instruction response for two bytes, for example, the second default Hash instruction is held Successfully backward host computer of going returns to 90 00.
Step 118:Signature result is obtained to the data splicing result calculate the signature of preservation using currently assigned key;
For example, the signature obtained to the data splicing result calculate the signature preserved in the second default Hash instruction processing procedure As a result it is:
cf6ce03f72a0cd704ddcea7ac987a53882c1b9d5214adfb052174f07cdd5d0383655a8d94e412 380a5a5025dcd70ef63c58b2bb6d43166ce737aa68f4ef65c0a。
Step 119:The signature command comprising signature result is returned to host computer to respond, and is then back to step 101.
For example, it is to the signature command response that host computer returns:
900040cf6ce03f72a0cd704ddcea7ac987a53882c1b9d5214adfb052174f07cdd5d0383655a8d 94e412380a5a5025dcd70ef63c58b2bb6d43166ce737aa68f4ef65c0a。
Further, above-mentioned steps 118 may be replaced by following content:
Step 118:Judge whether there are data in display caching, be, display data is obtained from display caching and is shown Show, after user confirms, signed the data splicing result calculate the signature of preservation as a result, then using currently assigned key Step 119 is performed, is otherwise signed the data splicing result calculate the signature of preservation as a result, then using currently assigned key Perform step 119.
Corresponding, above-mentioned steps 114 need to replace with following content:
Step 114:Parse the described second default Hash instruction and obtain data to be signed, display data, and by the display Data are saved in display caching.
Embodiment 4
Method provided in this embodiment can be phase suitable for hash algorithm used in trading signature and nontransaction signature The application environment of same algorithm, as shown in figure 3, a kind of method for improving signature safety provided in this embodiment, with USBKey Firmware workflow exemplified by be introduced, comprise the following steps:
Step 201:USBKey receives the instruction that host computer issues;
Step 202:The type of instruction received is judged, if initialization directive then performs step 203, if MSE refers to Order then performs step 205, if the first default Hash instruction then performs step 207, if the second default Hash instruction then performs Step 216, if generation key then performs step 220 to instructing, if signature command then performs step 222;
It is initialization directive if 84 e4 07 00 are equal to specifically, judging preceding 4 bytes of instruction received, if Then instructed equal to 00 22 41 b6 for MSE, if presetting Hash instruction equal to if 00 2a 90 81 for first, if being equal to 00 2a 90 80 are the second default Hash instruction, are signature command if 00 2a 9e 00 are equal to, if being equal to 00 46 00 00 Key is generated to instruction.Described first default Hash instruction is that hash algorithm used in nontransaction signature instructs, under certificate Carry signature Hash instruction;Described second default Hash instruction is that hash algorithm used in trading signature instructs, such as trading signature Hash instructs.
For example, the data format of above-mentioned each instruction is specific as follows:
Initialization directive:84 e4 07 00 Lc data
MSE is instructed:00 22 41 b6 Lc data
First default Hash instruction:00 2a 90 81 Lc data
Second default Hash instruction:00 2a 90 80 Lc data
Signature command:00 2a 9e 00 00
Key is generated to instruction:00 46 00 00 02 key moulds grow (2 byte)
Step 203:The first default hash algorithm of the first memory block storage is opened up, it is default to open up the second memory block storage second Hash algorithm, it is invalid to initialize default mark;
It is preferable in the present embodiment, one first default hash algorithm is stored with the first memory block, in the second memory block One second default hash algorithm is stored with, and the first default hash algorithm and the second default hash algorithm are identical.For example, First default hash algorithm and the second default hash algorithm are SHA1 algorithms.
Step 204:Initialization directive response is returned to host computer, is then back to step 201;
For example, if initialization directive runs succeeded to host computer return 90 00, if initialization directive perform failure to Host computer returns to 00 00.
Step 205:Parse the MSE instructions and obtain signature algorithm and signature key, the signature algorithm obtained according to parsing Current hash algorithm is set, and the signature key obtained according to parsing sets currently assigned key;
Step 206:MSE instruction responses are returned to host computer, are then back to step 201;
For example, 90 00 are returned to host computer if MSE instructions run succeeded, if MSE instructions perform failure to host computer Return to 00 00.
Step 207:Parse the described first default Hash instruction and obtain summary to be signed;
Step 208:Judge whether the length of the summary to be signed matches with the length of summarization of current hash algorithm support, It is then to perform step 209, otherwise returns to mistake to host computer, be then back to step 201;
Step 209:Judge whether current hash algorithm is consistent with the first default hash algorithm, is then to perform step 210, it is no Mistake then is returned to host computer, is then back to step 201;
Step 210:Judge whether current hash algorithm is consistent with the second default hash algorithm, is then to perform step 213, it is no Then perform step 211;
Step 211:Judge whether the length of summarization that the first default hash algorithm is supported is more than or equal to the second default Hash calculation The sum of the length of summarization of method support and the length of object identifier, are then to perform step 212, otherwise perform step 214;
Step 212:Judge whether include the object identifier in the summary to be signed, be then to be returned to host computer Mistake, is then back to step 201;Otherwise step 214 is performed;
For example, object identifier OID described in the present embodiment is:30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14。
Step 213:Judge whether default mark is effective, be then to perform step 214, otherwise return to mistake to host computer, so Return to step 201 afterwards;
Step 214:The summary to be signed is preserved, treating signature digest progress data according to object identifier splices to obtain Data splicing result simultaneously preserves;
Step 215:The first default Hash instruction response is returned to host computer, is then back to step 201;
For example, 90 00 are returned to host computer if the first default Hash instruction runs succeeded, if the first default Hash instruction Perform failure and then return to 00 00 to host computer.
Step 216:Parse the described second default Hash instruction and obtain data to be signed, display data, and by the display Data are saved in display caching;
Specifically, the default Hash instruction of parsing described second obtains data to be signed, parsed from the data to be signed Obtain display data.
For example, the data to be signed that the default Hash instruction of parsing described second obtains are:3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 22 31 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 75 74 66 38 22 3f 3e 0d 0a 3c 54 72 61 64 65 3e 0d 0a 3c 42 6f 64 79 3e 3c 41 75 74 68 52 65 71 75 65 73 74 31 32 33 34 35 36 37 38 39 30 3e 3c 41 75 74 68 52 65 71 75 65 73 74 48 65 61 64 3e 3c 41 75 74 68 56 65 72 73 69 6f 6e 3e 31 30 30 32 3c 2f 41 75 74 68 56 65 72 73 69 6f 6e 3e 3c 2f 41 75 74 68 52 65 71 75 65 73 74 48 65 61 64 3e 3c 41 75 74 68 52 65 71 75 65 73 74 42 6f 64 79 3e 3c 41 75 74 68 4e 61 6d 65 3e 43 42 41 4e 4b 5f 43 52 45 44 49 54 43 41 52 44 3c 2f 41 75 74 68 4e 61 6d 65 3e 3c 44 65 66 61 75 6c 74 43 61 72 64 4e 6f 3e 3c 2f 44 65 66 61 75 6c 74 43 61 72 64 4e 6f 3e 3c 41 75 74 68 52 65 71 75 65 73 74 44 61 74 61 3e 3c 2f 41 75 74 68 52 65 71 75 65 73 74 44 61 74 61 3e 3c 2f 41 75 74 68 52 65 71 75 65 73 74 42 6f 64 79 3e 3c 2f 41 75 74 68 52 65 71 75 65 73 74 31 32 33 34 35 36 37 38 39 30 3e 3c 2f 42 6f 64 79 3e 0d 0a 3c 53 69 67 6e 54 69 6d 65 3e 31 31 31 31 31 31 31 31 3c 2f 53 69 67 6e 54 69 6d 65 3e 0d 0a 3c 50 61 64 64 69 6e 67 3e 2a 2a 2a 2a 2a 2a 2a 2a 3c 2f 50 61 64 64 69 6e 67 3e 0d 0a 3c 46 6c 61 67 3e 59 3c 2f 46 6c 61 67 3e 0d 0a 3c 53 68 6f 77 3e e5 b8 90 e5 8f b7 ef bc 9a 39 35 35 38 38 32 30 32 30 30 30 30 39 32 38 30 33 36 35 5c 72 5c 6e e9 87 91 e9 a2 9d ef bc 9a 31 2e 30 30 20 52 4d 42 5c 72 5c 6e e5 a7 93 e5 90 8d ef bc 9a e5 bc a0 e4 b8 89 3c 2f 53 68 6f 77 3e 0d 0a 3c 2f 54 72 61 64 65 3e;
The display data parsed from the data to be signed is:
Account number:9558820200009280365
The amount of money:1.00RMB
Name:Zhang San;
Step 217:Judge whether current hash algorithm is consistent with the second default hash algorithm, is then to perform step 218, it is no Mistake then is returned to host computer, is then back to step 201;
Step 218:Hash calculation is carried out to the data to be signed using current hash algorithm and obtains summary to be signed, root Signature digest is treated according to object identifier carry out data splice to obtain data splicing result and preserve;
For example, the summary to be signed obtained to data to be signed progress Hash calculation is:1d 11 f667 f21612416793 c77d 0b 232b 5b 3c ae 426d。
Step 219:The second default Hash instruction response is returned to host computer, is then back to step 101;
For example, 90 00 are returned to host computer if the second default Hash instruction runs succeeded, if the second default Hash instruction Perform failure and then return to 00 00 to host computer.
Step 220:Generation key pair simultaneously preserves, and it is effective to put default mark;
Step 221:Generation key is returned to host computer to respond instruction, return to step 201;
For example, generation key then returns to 90 00 to success to host computer, returned if generation key is to failure to host computer 00 00。
Step 222:Judge whether there are data in display caching, be then to perform step 223, otherwise perform step 224;
Step 223:Obtain display data from display caching to be shown, after user confirms, using currently assigned close Key signs the data splicing result calculate the signature of preservation as a result, then performing step 225;
For example, the signature result obtained to the data splicing result calculate the signature of preservation is:
cf6ce03f72a0cd704ddcea7ac987a53882c1b9d5214adfb052174f07cdd5d0383655a8d94e412 380a5a5025dcd70ef63c58b2bb6d43166ce737aa68f4ef65c0a。
Step 224:Signed the data splicing result calculate the signature of preservation as a result, then using currently assigned key Perform step 225;
For example, the signature result obtained to the data splicing result calculate the signature of preservation is:
70284ef196140d6eafd7ec7bba0087bc284f73c3c66a87848e9697d51954b389ce91589ec6050 e89d6de76d508eb74c248c3d3c423537202be9694e7d754dc48;
Step 225:It is invalid to put default mark;
Step 226:The signature command comprising signature result is returned to host computer to respond, return to step 201.
Preferably, the first default hash algorithm referred in the embodiment of the present invention and the second default hash algorithm can be with For other kinds of hash algorithm, such as SHA256, SHA384, SHA512 etc..
Processing mode preferable in the present embodiment, signing when doing signature and handling using review, in addition, also Can not store display data when receiving the second default Hash instruction, when receiving signature command, directly use and work as Preceding specified key signs the digest calculations to be signed of preservation to obtain signature result.
The foregoing is only a preferred embodiment of the present invention, but protection scope of the present invention be not limited thereto, Any one skilled in the art is in technical scope disclosed by the invention, the change or replacement that can readily occur in, It should be covered by the protection scope of the present invention.Therefore, protection scope of the present invention should be with scope of the claims Subject to.

Claims (10)

  1. A kind of 1. method for improving signature safety, it is characterised in that:
    When equipment obtains signature algorithm and signature key from host computer, current Hash is set according to the signature algorithm of acquisition Algorithm, currently assigned key is set according to the signature key of acquisition;
    When equipment obtains summary to be signed from host computer, step A is performed;
    Step A:Judge whether to meet the first preset condition and the second preset condition at the same time, be to preserve the summary to be signed, Perform step B;Otherwise mistake is returned to host computer;
    First preset condition is:The length of the summary to be signed is matched with the length of summarization that current hash algorithm is supported, And current hash algorithm and what is stored in the first memory block first preset one of hash algorithm and match;
    Second preset condition is:The length of summarization that current hash algorithm is supported is less than all summed results, or current Kazakhstan The length of summarization that uncommon algorithm is supported, which is more than or equal at least one summed result and the summary to be signed, does not include object identity Symbol;The summed result is equal to the sum of the length of summarization of the second default hash algorithm support and the length of object identifier;
    Described first default hash algorithm is the hash algorithm that non-trading signature is supported, the described second default hash algorithm is to hand over Easily the supported hash algorithm of signature;The object identifier is the preset data that length is 15 bytes;
    Step B:Data are carried out according to the object identifier to the summary to be signed of preservation to splice to obtain data splicing knot Fruit;
    The method further includes, and equipment performs signature operation, and the signature operation is specially:Using currently assigned key to described Data splicing result calculate the signature obtains signature result, and the signature result is returned to host computer.
  2. 2. according to the method described in claim 1, it is characterized in that, the method further includes:The equipment performs initialization behaviour Make, the initialization operation is specially:The first default hash algorithm of the first memory block storage is opened up, opens up the storage of the second memory block Second default hash algorithm.
  3. 3. according to the method described in claim 1, it is characterized in that, the step A is further included:Whether judge current hash algorithm It is consistent with the second default hash algorithm, it is then to return to mistake to host computer, otherwise performs the step B.
  4. 4. according to the method described in claim 3, it is characterized in that, the method further includes:The equipment performs initialization behaviour Make, the initialization operation is specially:The first default hash algorithm of the first memory block storage is opened up, opens up the storage of the second memory block Second default hash algorithm, it is invalid to initialize default mark;
    The method further includes:The equipment performs generation key:Generate close Key pair simultaneously preserves, and it is effective to put default mark;
    Further included when judging that current hash algorithm is consistent with the second default hash algorithm, judge whether default mark is effective, is The summary to be signed is then preserved, performs the step B, otherwise returns to mistake to host computer.
  5. 5. according to the method described in claim 1, it is characterized in that, the method further includes:When equipment is treated from host computer During signed data, perform:Judge whether current hash algorithm is consistent with the second default hash algorithm, is calculated using current Hash Method carries out the data to be signed Hash calculation and obtains summary to be signed and preserve, then according to object identifier to preservation The summary to be signed carries out data and splices to obtain data splicing result;Otherwise mistake is returned to host computer.
  6. 6. according to the method described in claim 5, it is characterized in that, the method further includes:When equipment obtain from host computer it is aobvious Registration according to when, the display data is saved in display caching;
    The equipment further includes before performing signature operation:Judge whether be stored with display data in display caching, be then from aobvious Show that obtaining the display data in caching is shown, perform the signature operation after user confirms, otherwise directly perform institute State signature operation.
  7. 7. according to the method described in claim 1, it is characterized in that, the equipment is from least one instruction that host computer issues Obtain the signature algorithm, the signature key, the summary to be signed.
  8. 8. according to the method described in claim 5, it is characterized in that, the equipment is from least one instruction that host computer issues Obtain the signature algorithm, the signature key, the data to be signed.
  9. 9. according to the method described in claim 1, it is characterized in that, described judge whether to meet the first preset condition and at the same time Two preset conditions are specially:
    Step 1:Judge whether the length of the summary to be signed matches with the length of summarization of current hash algorithm support, be to hold Row step 2, is otherwise judged as being unsatisfactory for the first preset condition;
    Step 2:The default hash algorithm of first stored in the first memory block is traveled through, if in the presence of consistent with current hash algorithm the One default hash algorithm then performs step 3, is otherwise judged as being unsatisfactory for the first preset condition;
    Step 3:The default hash algorithm of second stored in the second memory block is traveled through, if being satisfied by:What current hash algorithm was supported Length of summarization is less than the sum of the length of summarization of the second default hash algorithm support and the length of object identifier, then is judged as meeting First preset condition and the second preset condition, otherwise perform step 4;
    Step 4:Judge whether include object identifier in summary to be signed, be to be judged as being unsatisfactory for the second preset condition, it is no Then it is judged as meeting the first preset condition and the second preset condition.
  10. 10. according to the method described in claim 1, it is characterized in that, further included before the step A to being deposited in the second memory block The default hash algorithm of each the second of storage is calculated as below respectively:Calculate length of summarization that the second default hash algorithm supports with The sum of length of object identifier obtains summed result.
CN201510345822.8A 2015-06-19 2015-06-19 A kind of method for improving signature safety Active CN104993932B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510345822.8A CN104993932B (en) 2015-06-19 2015-06-19 A kind of method for improving signature safety

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510345822.8A CN104993932B (en) 2015-06-19 2015-06-19 A kind of method for improving signature safety

Publications (2)

Publication Number Publication Date
CN104993932A CN104993932A (en) 2015-10-21
CN104993932B true CN104993932B (en) 2018-04-27

Family

ID=54305689

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510345822.8A Active CN104993932B (en) 2015-06-19 2015-06-19 A kind of method for improving signature safety

Country Status (1)

Country Link
CN (1) CN104993932B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108199834B (en) * 2018-01-16 2021-07-02 飞天诚信科技股份有限公司 Method and device for working intelligent secret key equipment
CN108399329B (en) 2018-01-23 2022-01-21 晶晨半导体(上海)股份有限公司 Method for improving security of trusted application program
CN111125781B (en) * 2019-12-24 2020-12-01 腾讯科技(深圳)有限公司 File signature method and device and file signature verification method and device
CN111818106B (en) * 2020-09-14 2020-12-11 飞天诚信科技股份有限公司 Data transmission method and equipment
CN112149186B (en) * 2020-10-19 2022-09-06 福建天晴在线互动科技有限公司 Data tamper-proofing method and system based on abstract algorithm

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763477A (en) * 2009-12-30 2010-06-30 北京飞天诚信科技有限公司 Signature method of intelligent secret key device
CN102761420A (en) * 2012-08-08 2012-10-31 飞天诚信科技股份有限公司 Security certification method
CN103326863A (en) * 2013-06-24 2013-09-25 飞天诚信科技股份有限公司 Signing method of electronic signing tool

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2003246419A1 (en) * 2002-06-20 2004-01-06 Compagnie Ibm France A system and method to re-synchronize client devices while refreshing them from a server

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763477A (en) * 2009-12-30 2010-06-30 北京飞天诚信科技有限公司 Signature method of intelligent secret key device
CN102761420A (en) * 2012-08-08 2012-10-31 飞天诚信科技股份有限公司 Security certification method
CN103326863A (en) * 2013-06-24 2013-09-25 飞天诚信科技股份有限公司 Signing method of electronic signing tool

Also Published As

Publication number Publication date
CN104993932A (en) 2015-10-21

Similar Documents

Publication Publication Date Title
CN104993932B (en) A kind of method for improving signature safety
Nikitin et al. {CHAINIAC}: Proactive {Software-Update} transparency via collectively signed skipchains and verified builds
CN111914027B (en) Block chain transaction keyword searchable encryption method and system
CN104022877B (en) System and method for certification electronic transaction
CN108646983A (en) The treating method and apparatus of storage service data on block chain
CN110602125B (en) Data processing method, device, terminal and storage medium
CN108768970A (en) A kind of binding method of smart machine, identity authentication platform and storage medium
CN109902494A (en) Data encryption storage method, device and document storage system
CN108900471A (en) It is used for transmission server, client, network system and the method for data
CN110351228A (en) Remote entry method, device and system
CN109241087A (en) A kind of data processing method and terminal of alliance&#39;s chain
CN107798538A (en) One kind transaction accounting method and client
DE112007001635T5 (en) Authentication of components in computer systems
CN108876383A (en) A kind of data trade method, device and equipment based on block chain
CN107707579A (en) Data encryption and transmission method
CN108737109A (en) Data proof of possession method, apparatus and system
CN108270791A (en) A kind of method and system of safe operation executable file
CN107423626A (en) A kind of method of the BIOS renewal trust chains based on continuous hash value
CN112580062B (en) Data consistency checking method and data uploading and downloading device
CN107679149A (en) A kind of data processing method and server
CN104579677B (en) A kind of data signature method safely and fast
CN102761420A (en) Security certification method
CN109922027A (en) A kind of trusted identity authentication method, terminal and storage medium
CN107707577A (en) Multi-layer data encryption method based on encryption transmission system
CN109885790A (en) The method and apparatus for obtaining satisfaction evaluation data

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant