CN104579677B - A kind of data signature method safely and fast - Google Patents

A kind of data signature method safely and fast Download PDF

Info

Publication number
CN104579677B
CN104579677B CN201410657600.5A CN201410657600A CN104579677B CN 104579677 B CN104579677 B CN 104579677B CN 201410657600 A CN201410657600 A CN 201410657600A CN 104579677 B CN104579677 B CN 104579677B
Authority
CN
China
Prior art keywords
card
data
instruction
private key
result
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
CN201410657600.5A
Other languages
Chinese (zh)
Other versions
CN104579677A (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 CN201410657600.5A priority Critical patent/CN104579677B/en
Publication of CN104579677A publication Critical patent/CN104579677A/en
Application granted granted Critical
Publication of CN104579677B publication Critical patent/CN104579677B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Storage Device Security (AREA)

Abstract

The present invention relates to information security field, more particularly to a kind of data signature method safely and fast, including:It is electric on card, the instruction for waiting host computer to be received to issue, and the type of decision instruction, if being introduced into private key instruction, ciphertext is obtained from importing in private key instruction, ciphertext is decrypted using default decipherment algorithm and preset-key to obtain private key, preserves private key;If data signature instructs, then judge whether median, if median be present, then obtain the median that therein preserves, obtained from data signature instruction and block outer random number, according to the outer random number tissue data to be signed of card, private key, median and data to be signed are signed using preset algorithm, result of signing is obtained, the signature response for including signature result is sent to host computer;Using method provided by the invention, the time signed to data to be signed can be saved on the premise of guaranteeing data security.

Description

A kind of data signature method safely and fast
Technical field
The invention belongs to information security field, more particularly to a kind of data signature method safely and fast.
Background technology
In the prior art, when card is to authenticating user identification, it is necessary first to card tissue data to be signed, according to card The private key that inside preserves calculates public key, and data to be signed then are carried out with signature operation, completion pair with the public key being calculated again Authenticating user identification;Invention technician find, using prior art to authenticating user identification during, card needs to consume The expense plenty of time is calculated, and extends the signature time.
The content of the invention
In order to solve the defects of prior art, the present invention provides a kind of data signature method safely and fast, and its feature exists In, including:
Step S1:It is electric on card;
Step S2:The instruction that the host computer to be received such as the card issues, and judge the type of the instruction, if leading Enter private key instruction, then perform step S3;If data signature instructs, then step S4 is performed;
Step S3:The card obtains ciphertext from the importing private key instruction, using default decipherment algorithm and presets close Key is decrypted to obtain private key to the ciphertext, preserves the private key, return to step S2;
Step S4:The card judges that therein whether there is median, is then to perform step S9;Otherwise step is performed S5;
Step S5:The card judges whether private key, is, obtains the private key, and the private key calculate To public key, the public key is preserved, performs step S6;Otherwise report an error, return to step S2;
Step S6:The card obtains the subscriber identity information of itself preservation, calculates the length of the subscriber identity information;
Step S7:The card obtains the data message of itself preservation, to the subscriber identity information, the user identity The length of information, the data message carry out that the first result is calculated;
Step S8:Median is calculated to first result and the public key in the card, preserves the median;
Step S9:The card obtains from data signature instruction blocks outer random number, according to random number outside the card Data to be signed are organized, the private key, the median and the data to be signed are signed using preset algorithm, obtained Signature result, the signature response for including the signature result, return to step S2 are sent to the host computer.
Using method provided by the invention, card can handle the data signature instruction that host computer issues, and carry out identity and recognize Demonstrate,prove, random number tissue data to be signed outside the card in being instructed according to data signature, signed.Data to be signed are entered for the first time During row signature, median, public key are preserved, when non-first time is signed, saved median is directly obtained or public key is carried out Signature, reach the speed for improving signature, save the signature time, strengthen the effect of Consumer's Experience.
Brief description of the drawings
Embodiment
The technical scheme in the embodiment of the present invention will be clearly and completely described below, it is clear that described implementation Example only part of the embodiment of the present invention, rather than whole embodiments.It is common based on the embodiment in the present invention, this area The every other embodiment that technical staff is obtained under the premise of creative work is not made, belong to the model that the present invention protects Enclose.
To make the object, technical solutions and advantages of the present invention clearer, embodiment of the present invention will be done into one below The detailed description of step.
Embodiment 1
The present embodiment provides a kind of data signature method safely and fast, including:
Step Q1:It is electric on card;
Step Q2:The instruction that the host computer to be received such as card issues, and the type of decision instruction, refer to if being introduced into private key Order, then perform step Q3;If data signature instructs, then step Q4 is performed;
Step Q3:Card obtains ciphertext from importing private key instruction, using default decipherment algorithm and preset-key to ciphertext It is decrypted to obtain private key, preserves private key, return to step Q2;
Specifically, card judges that therein whether there is median, is to remove median, from importing private key instruction Ciphertext is obtained, ciphertext is decrypted using default decipherment algorithm and preset-key to obtain private key, preserves private key, return to step Q2;Otherwise ciphertext is obtained from importing private key instruction, ciphertext is decrypted to obtain using default decipherment algorithm and preset-key Private key, preserve private key, return to step Q2.
In the present embodiment, after preserving private key, in addition to:Public key is calculated according to private key, preserves public key, itself is obtained and preserves Subscriber identity information, calculate the length of subscriber identity information, obtain the data message of itself preservation, to subscriber identity information, The length of subscriber identity information, data message carry out that the first result is calculated, and centre is calculated to the first result and public key Value, preserve median;
Step Q4:Card judges that therein whether there is median, is then to perform step Q9;Otherwise step Q5 is performed;
This step can also be:Card judges whether median, is then to perform step Q9;Otherwise report an error, return to step Rapid Q2.
Step Q5:Card judges whether private key, is, obtains private key, private key is carried out public key is calculated, and preserves Public key, perform step Q6;Otherwise report an error, return to step Q2;
Step Q6:Card obtains the subscriber identity information of itself preservation, calculates the length of subscriber identity information;
Also include before this step:Card judges whether the first result, is, obtains the first result, performs step Q8;Otherwise step Q6 is performed;
Step Q7:Card obtain itself preservation data message, to subscriber identity information, subscriber identity information length, Data message carries out that the first result is calculated;
In the present embodiment, data message includes:First element, second element, third element, fourth element;Specifically, block Piece obtain the first element, second element, third element, fourth element, by the length of subscriber identity information, subscriber identity information, First element, second element, third element and fourth element sequential concatenation, obtained result is as the first result.
This step also includes, and preserves the first result;
Step Q8:Card the first result and public key is calculated median, preserves median;
Specifically, the first result and public key sequential concatenation are done Hash calculation to obtained splicing result, obtained by card Hash result is as median.
Step Q9:Card obtains from data signature instruction blocks outer random number, according to the outer random number tissue of card number to be signed According to, private key, median and data to be signed are signed using preset algorithm, obtain sign result, to host computer send wrap The signature response of the result containing signature, return to step Q2.
Specifically,
Step X0:Card obtains from data signature instruction blocks outer random number, according to the outer random number tissue of card number to be signed According to;
Step X1:Card carries out Hash calculation by median and data to be signed sequential concatenation, to obtained splicing result, Obtain the first result of calculation;
Step X2:Card generate card random number, obtain itself preservation third element and fourth element, according to card with Machine number, third element and fourth element calculate, and obtain the first numerical value;
Step X3:Card obtains the The Fifth Element of itself preservation, according to the first result of calculation, the first numerical value and The Fifth Element Calculate, obtain the Part I data of signature result;
Step X4:Whether card judge the to sign Part I data of result meet preparatory condition, are then return to step X2; Otherwise step X5 is performed;
Step X5:Card calculates according to private key, card random number, the Part I data for result of signing and The Fifth Element, The Part II data of signature result are obtained, perform step X6;
Step X6:Whether card judge the to sign Part II data of result are equal to 0, are then return to step X2;Otherwise hold Row step X7;
Step X7:Card splices the Part II data order of the Part I data for result of signing and signature result, Using obtained splicing result as signature result;
Step X8:Card sends the signature response for including signature result, return to step Q2 to host computer.
In the present embodiment, after step Q9, in addition to:Card judges whether successfully to carry out signature operation, is then to upper Machine sends the signature response for including signature result, return to step Q2;Otherwise signature failure information, return to step are sent to host computer Q2。
It should be noted that data signature instruction is Dynamic Data Authentication instruction;
When the instruction that host computer issues is Dynamic Data Authentication instruction, in addition to:Card judges that Dynamic Data Authentication instructs It is whether legal, it is then to perform step Q4;Otherwise Dynamic Data Authentication instruction information unauthorized, return to step are sent to host computer Q2;Wherein, card judges whether Dynamic Data Authentication instruction is legal, is specially:
Step a1:Card judges whether the value of the first byte of Dynamic Data Authentication instruction is 0X00, is then to perform step Rapid a2;Otherwise Dynamic Data Authentication instruction information unauthorized, return to step Q2 are sent to host computer;
Step a2:Card judges whether the 3rd of Dynamic Data Authentication instruction the, value of nybble is 0X00,0X00, It is then to perform step a3;Otherwise Dynamic Data Authentication instruction information unauthorized, return to step Q2 are sent to host computer;
Step a3:Card is obtained to the number in last byte since the 6th byte that Dynamic Data Authentication instructs According to calculating the length of the data got, judge the value of the 5th byte of Dynamic Data Authentication instruction whether with getting The length of data is identical, is then to perform step a4;Otherwise Dynamic Data Authentication instruction information unauthorized is sent to host computer, returned Step Q2;
Step a4:What card acquisition pre-saved applies interaction feature, judges whether to support to move according to using interaction feature State data authentication operations, it is then to perform step Q4;Otherwise Dynamic Data Authentication instruction information unauthorized is sent to host computer, returned Step Q2.
According to the outer random number tissue data to be signed of card, it is specially:Card generates card dynamic random number, and itself is preserved The first data, the length of card dynamic random number, card dynamic random number and the outer random number sequential concatenation of card, the spelling that will be obtained Binding fruit is as data to be signed.
Data signature instruction is rapid authentication instruction;When the instruction that host computer issues is rapid authentication instruction, in addition to:Card Piece judges whether rapid authentication instruction is legal, is then to perform step Q4;Otherwise it is illegal to send rapid authentication instruction to host computer Information, return to step Q2;
Wherein, card judges whether rapid authentication instruction is legal, is specially:
Step b1:Card judges whether the value of the first byte of rapid authentication instruction is 0X80, is then to perform step b2; Otherwise rapid authentication instruction information unauthorized, return to step Q2 are sent to host computer;
Step b2:Card judges whether the 3rd of rapid authentication instruction the, value of nybble is 0X00,0X00, is then Perform step b3;Otherwise rapid authentication instruction information unauthorized, return to step Q2 are sent to host computer;
Step b3:Card is obtained since the 6th byte that rapid authentication instructs to the data in last byte, meter The length of the data got, judge rapid authentication instruction the 5th byte value whether with the length of the data got It is identical, it is then to perform step b4;Otherwise rapid authentication instruction information unauthorized, return to step Q2 are sent to host computer;
Step b4:What card acquisition pre-saved applies interaction feature, judges whether to support soon according to using interaction feature Fast authentication operation, it is then to perform step Q4;Otherwise rapid authentication instruction information unauthorized, return to step Q2 are sent to host computer.
Correspondingly, according to the outer random number tissue data to be signed of card, it is specially:Card obtains the crucial letter of itself preservation Breath, by the outer random number of card and key message sequential concatenation, using splicing result as data to be signed.
When the instruction that host computer issues is rapid authentication instruction, in addition to:Empty buffer area;Judging rapid authentication instruction When legal, in addition to:
Rapid authentication instruction is preserved into buffer area, the first count value is set to initial value, performs step Q4;
Data signature instruction is compound Dynamic Data Authentication instruction, and the instruction that host computer issues is compound Dynamic Data Authentication During instruction, card obtains from data signature instruction blocks outer random number, according to the outer random number tissue data to be signed of card, specific bag Include:
Step K1:Card judges to whether there is data in buffer area, is then to perform step K2;Otherwise report an error, return to step Q2;
Step K2:Card obtains the data in buffer area, and the data got and the instruction of compound Dynamic Data Authentication are suitable Sequence is spliced, and using obtained splicing result as hash is treated, is obtained the first count value, is judged whether the first count value is initial Value, it is then to perform step K4;Otherwise step K3 is performed;
Step K3:Card empties buffer area, and the first count value is set into initial value, performs step K5;
Step K4:Card will be treated in hash deposit buffer area, update the first count value, perform step K5;
Step K5:Card treats hash and carries out Hash calculation, obtains Hash result, refers to from compound Dynamic Data Authentication Obtained in order and block outer random number, according to Hash result and block outer random number tissue data to be signed.
According to Hash result and block outer random number tissue data to be signed, be specially:
Card obtains the second data of itself preservation, obtains the 3rd data of itself preservation, obtains the 4th of itself preservation Data, obtain itself preservation card in ciphertext, by the second data, the 3rd data, the 4th data, card in ciphertext, Hash result and The outer random number sequential concatenation of card, using obtained splicing result as data to be signed.
Data signature instruction is compound Dynamic Data Authentication instruction;
When the instruction that host computer issues is compound Dynamic Data Authentication instruction, in addition to:Card judges compound dynamic data Whether certification instruction is legal, is then to perform step Q4;Otherwise send compound Dynamic Data Authentication to host computer and instruct illegal letter Breath, return to step Q2.Wherein, card judges whether compound Dynamic Data Authentication instruction is legal, is specially:
Step c1:Card judges whether the value of the first byte of compound Dynamic Data Authentication instruction is 0X80, is to hold Row step c2;Otherwise send compound Dynamic Data Authentication to host computer and instruct information unauthorized, return to step Q2;
Step c2:Card judge the 3rd of the instruction of compound Dynamic Data Authentication the, nybble value whether be 0X00, 0X00, it is then to perform step c3;Otherwise send compound Dynamic Data Authentication to host computer and instruct information unauthorized, return to step Q2;
Step c3:Card is obtained to last byte since the 6th byte that compound Dynamic Data Authentication instructs Data, the length of the data got is calculated, judge the value of the 5th byte of compound Dynamic Data Authentication instruction whether with obtaining The length for the data got is identical, is then to perform step c4;Otherwise compound Dynamic Data Authentication instruction is sent to host computer not conforming to Method information, return to step Q2;
Step c4:What card acquisition pre-saved applies interaction feature, judges whether to support again according to using interaction feature Dynamic Data Authentication operation is closed, is then to perform step Q4;Otherwise it is illegal to send compound Dynamic Data Authentication instruction to host computer Information, return to step Q2.
In the present embodiment, in addition to generation key is to instruction, is that generation is close when card receives the instruction that host computer issues When key is to instruction, card generation private key, and private key is preserved, return to step Q2.
In the present embodiment, step Q3 to step Q9 could alternatively be:
Step Q3 ':Card obtains ciphertext from importing private key instruction, and ciphertext is decrypted using default decipherment algorithm Identified to private key and private key, preserve private key and private key mark;
Step Q4 ':Card obtains private key mark from data signature instruction, judges that therein identifies with the presence or absence of private key Corresponding median, it is then to perform step Q9 ';Otherwise step Q5 ' is performed;
Step Q5 ':Card judge whether private key mark corresponding to private key, be to obtain private key, private key counted Calculation obtains public key, preserves public key, performs step Q6;Otherwise report an error, return to step Q2;
Step Q9 ':Card obtains from data signature instruction blocks outer random number, according to the outer random number tissue of card number to be signed According to, median and data to be signed corresponding to private key corresponding to private key mark, private key mark are signed using preset algorithm, Result of signing is obtained, the signature response for including signature result, return to step Q2 are sent to host computer.
Embodiment 2
The present embodiment provides a kind of data signature method safely and fast, including:
Step 101:It is electric on card;
Step 102:The instruction that the host computer to be received such as card issues, decision instruction type, if being introduced into private key instruction, Then perform step 103;If Dynamic Data Authentication instructs, then step 105 is performed;If rapid authentication instructs, then perform Step 116;If compound Dynamic Data Authentication instruction, then perform step 127;
In the present embodiment, card according to the type of the value decision instruction of first, second byte of instruction, if first, The value of second byte is 0X0088, then is Dynamic Data Authentication instruction;If the value of first, second byte is 0X80A8, It is then rapid authentication instruction;The value of first, second byte is 0X80AE, then is compound Dynamic Data Authentication instruction.
Wherein, Dynamic Data Authentication instruction instructs for INTERNAL AUTHENTICATE;Rapid authentication instruction is GET PROCESSING OPTIONS are instructed;Compound Dynamic Data Authentication instruction instructs for GENERATE AC;
In the present embodiment, Dynamic Data Authentication instruction, rapid authentication instruction, the instruction of compound Dynamic Data Authentication are data Signature command;
In the present embodiment, the instruction that host computer issues also includes:Key is generated to instruction;If generation key is to referring to Order, then card generation private key, and preserve private key, return to step 102.
In the present embodiment, private key is that length is to be less than the random number of 256 bits more than 0 bit.
Step 103:Card obtains ciphertext from importing private key instruction, using default decipherment algorithm and preset-key to ciphertext It is decrypted, obtains private key;
Such as:The private key obtained after decryption is:
FB0EEB34DD4BD85C645F2CD2DD343ECD0ED03349282C3E1BF6DB51F1384FBC76;
Step 104:Card preserves private key, return to step 102;
Step 105:Card judges whether Dynamic Data Authentication instruction is legal, is then to perform step 106;Otherwise to host computer Send Dynamic Data Authentication instruction information unauthorized, return to step 102;
In the present embodiment, judge Dynamic Data Authentication instruction whether legal method, specifically include,
Step a1:Card judges whether the value of the first byte of Dynamic Data Authentication instruction is 0X00, is then to perform step Rapid a2;Otherwise host computer, return to step 102 are sent to using 0X6E00 as Dynamic Data Authentication instruction information unauthorized;
Step a2:Card judges whether the 3rd of Dynamic Data Authentication instruction the, value of nybble is 0X000X00, is Then perform step a3;Otherwise host computer, return to step are sent to using 0X6A86 as Dynamic Data Authentication instruction information unauthorized 102;
Step a3:Card is obtained to the number in last byte since the 6th byte that Dynamic Data Authentication instructs According to calculating the length of the data got, judge the value of the 5th byte of Dynamic Data Authentication instruction whether with getting The length of data is identical, is then to perform step a4;Otherwise sent 0X6700 as Dynamic Data Authentication instruction information unauthorized To host computer, return to step 102;
Step a4:What card acquisition pre-saved applies interaction feature, judges whether to support to move according to using interaction feature State data authentication operations, it is that then Dynamic Data Authentication instruction is legal, performs step 106;Otherwise, Dynamic Data Authentication instruction does not conform to Method, host computer, return to step 102 are sent to using 0X6985 as Dynamic Data Authentication instruction information unauthorized;
Preferably, the first word applied interaction feature, judge using interaction feature being pre-stored in inside card is obtained Whether the value of the 6th of section is 1, is then to support Dynamic Data Authentication operation;Otherwise Dynamic Data Authentication is not supported to operate;
Such as:The Dynamic Data Authentication instruction received is 008800000411223344;Wherein, the value of the first byte For 0X00;3rd, the value of nybble is 0X00,0X00;Since Dynamic Data Authentication instruction the 6th byte obtain to Data in last byte, the data got are 11223344, and the length of the data got is 4 bytes, that is, is obtained The length of the data arrived is 0X04, and the value of the 5th byte of Dynamic Data Authentication instruction is 0X04, with the data that get Length is identical;Exemplified by the value of the 6th of the first byte using interaction feature to be pre-stored in inside card is 1, then Dynamic Data Authentication instruction is legal.
Step 106:Card judges that therein whether there is median, is then to perform step 112;Otherwise step is performed 107;
In this step, when judging that median is not present in card therein, in addition to:Public key is judged whether, is Then perform step 109;Otherwise step 107 is performed;
Step 107:Card judges whether private key, is then to perform step 108;Otherwise report an error, return to step 102;
Step 108:Card obtains private key, private key is calculated public key, preserves public key, performs step 109;
For example, card is to the public key that private key is calculated:
A876F78AABB8C8C0BBC0D03CD76D2AE8AD19FCF176F6B0E7D0C803783B0CBC91
2E00F90B473D38D95A03C1C1B3629D0DA1BD07FC796D7CC6E365C8296245E305;
Step 109:Card judges whether the first result, is then to perform step 111;Otherwise step 110 is performed;
The present embodiment performs step 110 exemplified by the absence of the first result;
Step 110:Card obtains the subscriber identity information of itself preservation, calculates the length of subscriber identity information, is obtained from First element of body preservation, second element, third element, fourth element, to the length of subscriber identity information, subscriber identity information Degree, the first element, second element, third element, fourth element carry out that the first result is calculated, and preserve the first result, perform Step 111;
Specifically, card obtains the subscriber identity information of itself preservation, calculates the length of subscriber identity information, obtains itself Preserve the first element, second element, third element, fourth element, by the length of subscriber identity information, subscriber identity information, First element, second element, third element and fourth element sequential concatenation, obtained result is as the first result.Wherein, first Element, second element, third element and fourth element are fixed value, and the first element is:
FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC;
Second element is:
28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93;
Third element is:
32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7;
Fourth element is:
BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0;
Such as:Subscriber identity information is:31323334353637383132333435363738;User is understood by calculating The length of identity information is 0X0080;
First result is:0X0080
31323334353637383132333435363738
FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC
28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93
32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7
BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0。
Step 111:Card the first result and public key is calculated median, preserves median;
Specifically, the first result and public key sequential concatenation are done Hash calculation to obtained splicing result, obtained by card Hash result is as median.
For example, obtained median is:
6F73DC832ABB274E6B4A7305BE2A4C0F3B78C77F585B3680FF31814E9FE4AA3B。
Step 112:Obtained from Dynamic Data Authentication instruction and block outer random number, tissue, which includes, blocks the to be signed of outer random number Data, perform step 113;
In the present embodiment, card obtains the value of the 5th byte of Dynamic Data Authentication instruction, by the value of the 5th byte As the length of the outer random number of card, since the 6th byte of Dynamic Data Authentication instruction, length is obtained with blocking outer random number Length identical data, using the data got as the outer random number of card;Card generates card dynamic random number, and itself is preserved The first data, the length of card dynamic random number, card dynamic random number and the outer random number sequential concatenation of card, the spelling that will be obtained Binding fruit is as data to be signed.Wherein, the first data are the data preserved inside card, and value 0X1503, card is dynamically Random number length is 2 bytes;
In this step, tissue comprising after the data to be signed for blocking outer random number, in addition to, card according to default step-length more New card dynamic random number;
Specifically, card dynamic random number and default step-length are done into add operation, obtained operation result renewal card moves State random number;Or card dynamic random number and default step-length are done into subtraction, obtained operation result renewal card dynamic Random number.
Such as:The value that card obtains the 5th byte of Dynamic Data Authentication instruction is 0X04, outer random as card Several length, i.e. 4 bytes, the data of 4 byte lengths are obtained since the 6th byte of Dynamic Data Authentication instruction, that is, are got Data be 11223344, as card outside random number;It is 4A5B that card, which obtains the internal card dynamic random number preserved,;Group Into data to be signed be:0X1503024A5B11223344;
Step 113:Card is signed using preset algorithm to private key, median and data to be signed, obtains signature knot Fruit;
Preferably, preset algorithm is SM2 algorithms.The length for result of signing is 0X40 bytes;
Wherein, card uses the method that SM2 algorithms are signed to private key, median and data to be signed, including:
Step A1:Card carries out Hash calculation by median and data to be signed sequential concatenation, to obtained splicing result, Obtain the first result of calculation;
Step A2:Card generate card random number, obtain itself preservation third element and fourth element, according to card with Machine number, third element and fourth element calculate, and obtain the first numerical value;
Wherein, card random number is greater than being equal to 1, less than or equal to the random number of The Fifth Element, and card random number Length is more than 0 bit, less than 256 bits;The Fifth Element is greater than 0 prime number.Preferably, The Fifth Element is:
FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123;
In the present embodiment, card random number and third element are done multiplying by card, and obtained result of calculation is used as the One numerical value;
Such as:Card random number is:
64D9F366298D40C2B38005B746962ADD1345AC5621D29BD8E673D26033AD96;
First numerical value is:
34793E74567FC6C51100653D96F1FDF6EDDAA7FC160BAB67C7AFA89E 1DD704EC,
Step A3:Card obtains the The Fifth Element of itself preservation, according to the first result of calculation, the first numerical value and The Fifth Element Calculate, obtain the Part I data of signature result;
In the present embodiment, the first result of calculation and the first numerical value are done add operation by card, obtained result of calculation and the Five elements do complementation computing, Part I data of the obtained result as signature result;
Such as:The Fifth Element is:
FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123;
Signature result Part I data be:
0X6B8AECEE54C2C65D174C9311334B76C097B09211E61DD59BC8F7FA9F85A68F1C;
Step A4:Whether card judge the to sign Part I data of result meet preparatory condition, are then return to step A2; Otherwise step A5 is performed;
In the present embodiment, preparatory condition is specially:The Part I data for result of signing are equal to 0;Or result of signing Part I data do add operation with card random number, and obtained result of calculation is equal to The Fifth Element;
With the data instance in step A3, the Part I data for result of signing are not equal to 0, and the first of result of signing Partial data does add operation with card random number, and obtained result of calculation is not equal to The Fifth Element, performs step A5.
Step A5:Card calculates according to private key, card random number, the Part I data for result of signing and The Fifth Element, The Part II data of signature result are obtained, perform step A6;
In the present embodiment, card is according to private key, card random number, the Part I data and The Fifth Element meter of result of signing Calculate, the method for obtaining the Part II data of signature result is specially:
Private key and 1 are carried out add operation by card, obtain operation result, take the inverse of operation result to calculate knot as second Fruit;The Part I data for result of signing are done into multiplying with private key, obtained operation result does subtraction with card random number Computing, obtain the 3rd result of calculation;Second result of calculation and the 3rd result of calculation are done into multiplying, obtained dynamic operation knot Fruit is cooked complementation computing with The Fifth Element, Part II data of the obtained operation result as signature result.
Such as:The Part II data for the signature result that card is calculated are:
0XD5D1022F1346B745203E007ACF7930C1CB72823944FC14FF88DB8FBEDF1DEFD4;
Step A6:Whether card judge the to sign Part II data of result are equal to 0, are then return to step A2;Otherwise hold Row step A7;
With the data instance in step A5, the Part II data for result of signing are not equal to 0, perform step A7;
Step A7:Card ties the Part II data of the Part I data for result of signing and signature result as signature Fruit.
In the present embodiment, the Part II data splicing of the Part I data and signature result of result of signing, it will splice As a result as signature result.
Such as:Obtained signature result is:
0X6B8AECEE54C2C65D174C9311334B76C097B09211E61DD59BC8F7FA9F85A68F1CD5D1022F134 6B745203E007ACF7930C1CB72823944FC14FF88DB8FBEDF1DEFD4;
Step 114:Card judges whether signature operation succeeds, and is then to perform step 115;Otherwise dynamic is sent to host computer Data authentication signature failure information, return to step 102;
In the present embodiment, Dynamic Data Authentication signature failure information is specially 0X6F81.
Step 115:Card returns to the Dynamic Data Authentication comprising signature result to host computer and responded, return to step 102;
In the present embodiment, data head that card responds 0X80 as Dynamic Data Authentication, using 0X45 as dynamic data The length of the data field of authentication response, 0X15,0X03,0X02, card dynamic random number, signature result sequential concatenation obtain The data field that is responded as Dynamic Data Authentication of splicing result, be sent to splicing result as Dynamic Data Authentication response Position machine.
Also include after the success of card signature operation, obtain the card the result preserved inside card, card is verified As a result the value of the 3rd byte carries out step-by-step or computing with 0X02, and obtained operation result replaces the 3rd of card the result Byte, using the data obtained after replacement as the card the result after renewal.
Such as:Dynamic Data Authentication responds:
0X80451503024A5B6B8AECEE54C2C65D174C9311334B76C097B09211E61DD59BC8F7FA9F85A68 F1CD5D1022F1346B745203E007ACF7930C1CB72823944FC14FF88DB8FBEDF1DEFD49000;
Step 116:Card judges whether rapid authentication instruction is legal, is then to perform step 117;Otherwise sent to host computer Rapid authentication instructs information unauthorized, return to step 102;
In the present embodiment, judge rapid authentication instruction whether legal method, specifically include,
Step b1:Card judges whether the value of the first byte of rapid authentication instruction is 0X80, is then to perform step b2; Otherwise host computer, return to step 102 are sent to using 0X6E00 as rapid authentication instruction information unauthorized;
Step b2:Card judges whether the 3rd of rapid authentication instruction the, value of nybble is 0X00,0X00, is then Perform step b3;Otherwise host computer, return to step 102 are sent to using 0X6A86 as rapid authentication instruction information unauthorized;
Step b3:Card is obtained since the 6th byte that rapid authentication instructs to the data in last byte, meter The length of the data got, judge rapid authentication instruction the 5th byte value whether with the length of the data got It is identical, it is then to perform step b4;Otherwise host computer is sent to using 0X6700 as rapid authentication instruction information unauthorized, returns to step Rapid 102;
Step b4:What card acquisition pre-saved applies interaction feature, judges whether to support soon according to using interaction feature Fast authentication operation, it is that then rapid authentication instruction is legal;Otherwise rapid authentication instruction is illegal, refers to 0X6985 as rapid authentication Information unauthorized is made to be sent to host computer, return to step 102;
Preferably, the first word applied interaction feature, judge using interaction feature being pre-stored in inside card is obtained Whether the value of the 6th of section is 1, is then to determine to support rapid authentication operation;Otherwise determine not support rapid authentication to operate;
Step 117:Card judges that therein whether there is median, is then to perform step 123;Otherwise step is performed 118;
In this step, when judging that median is not present in card therein, in addition to:Public key is judged whether, is then Perform step 120;Otherwise step 118 is performed;
Step 118:Card judges whether private key, is then to perform step 119;Otherwise report an error, return to step 102;
Step 119:Card obtains private key, private key is calculated public key, preserves public key, performs step 120;
Step 120:Card judges whether the first result, is then to perform step 122;Otherwise step 121 is performed;
Step 121:Card obtains the subscriber identity information of itself preservation, calculates the length of subscriber identity information, is obtained from First element of body preservation, second element, third element, fourth element, to the length of subscriber identity information, subscriber identity information Degree, the first element, second element, third element, fourth element carry out that the first result is calculated, and preserve the first result, perform Step 122;
This step concrete operation method is identical with step 110.
Step 122:Card the first result and public key is calculated median, preserves median;
This step concrete operation method is identical with step 111.
Step 123:Card obtains from rapid authentication instruction blocks outer random number, obtains the crucial letter preserved inside card Breath, according to the outer random number of card and key message tissue data to be signed;
Preferably, 4 byte datas are obtained forward since the byte second from the bottom of rapid authentication instruction, the number that will be got According to as the outer random number of card;
In the present embodiment, key message includes the dealing money of 6 byte lengths, the transaction currency code of 2 byte lengths, 8 The close dynamic random number of state of byte length;Outer random number and key message sequential concatenation will be blocked, using splicing result as to be signed Data;Preferably, the length for blocking outer random number is 4 bytes.
Step 124:Card is signed using preset algorithm to private key, median and data to be signed, obtains signature knot Fruit;
In the present embodiment, preset algorithm is SM2 algorithms;Private key, median and data to be signed are carried out using SM2 algorithms The method of signature is identical with step 113.
Step 125:Card judges whether signature operation succeeds, and is then to perform step 126;Otherwise sent to host computer quick Authentication signature failure information, return to step 102;
Step 126:Card empties buffer area, and the first count value is set into initial value, and rapid authentication is instructed into deposit caching Qu Zhong, return to the rapid authentication comprising signature result to host computer and respond, return to step 102;
In the present embodiment, card using 0X77,0X81 as data head, using the data that are responded as rapid authentication of result of signing The part in domain, tissue rapid authentication response.
Rapid authentication is instructed into deposit buffer area, is specially:The value for the 5th byte that card instructs according to rapid authentication, Data are obtained since the 6th byte of rapid authentication instruction, the data got are stored in buffer area;Or card is from quick 6th byte of certification instruction starts to obtain to the data in last byte, and the data got are stored in into buffer area;It is excellent Selection of land, the initial value of the first count value is 0.
Step 127:Card judges whether compound Dynamic Data Authentication instruction is legal, is then to perform step 128;Otherwise it is upward Position machine sends compound Dynamic Data Authentication instruction information unauthorized, return to step 102;
In the present embodiment, judge the instruction of compound Dynamic Data Authentication whether legal method, specifically include,
Step c1:Card judges whether the value of the first byte of compound Dynamic Data Authentication instruction is 0X80, is to hold Row step c2;Otherwise host computer, return to step are sent to using 0X6E00 as compound Dynamic Data Authentication instruction information unauthorized 102;
Step c2:Card judges whether the value of the 5th of the 3rd byte of compound Dynamic Data Authentication instruction is 1, is Then perform step c3;Otherwise host computer is sent to using 0X6A86 as compound Dynamic Data Authentication instruction information unauthorized, returned Step 102;
Step c3:Card is obtained to last byte since the 6th byte that compound Dynamic Data Authentication instructs Data, the length of the data got is calculated, judge the value of the 5th byte of compound Dynamic Data Authentication instruction whether with obtaining The length for the data got is identical, is then to perform step c4;Otherwise do not conform to 0X6700 as the instruction of compound Dynamic Data Authentication Method information is sent to host computer, return to step 102;
Step c4:What card acquisition pre-saved applies interaction feature, judges whether to support again according to using interaction feature Dynamic Data Authentication operation is closed, is that then compound Dynamic Data Authentication instruction is legal;Otherwise compound Dynamic Data Authentication instruction does not conform to Method, host computer, return to step 102 are sent to using 0X6985 as compound Dynamic Data Authentication instruction information unauthorized;
Preferably, the first word applied interaction feature, judge using interaction feature being pre-stored in inside card is obtained Whether the primary value of section is 1, is to support compound dynamic data authentication operations;Otherwise compound dynamic data is not supported to recognize Card operation;
Step 128:Card judges that therein whether there is median, is then to perform step 134;Otherwise step is performed 129;
In this step, when judging that median is not present in card therein, in addition to:Public key is judged whether, is then Perform step 130;Otherwise step 129 is performed;
Step 129:Card judges whether private key, is then to perform step 130;Otherwise report an error, return to step 102;
Step 130:Card obtains private key, private key is calculated public key, preserves public key, performs step 131;
Step 131:Card judges whether the first result, is then to perform step 133;Otherwise step 132 is performed;
Step 132:Card obtains the subscriber identity information of itself preservation, calculates the length of subscriber identity information, is obtained from First element of body preservation, second element, third element, fourth element, to the length of subscriber identity information, subscriber identity information Degree, the first element, second element, third element, fourth element carry out that the first result is calculated, and preserve the first result, perform Step 133;
This step concrete operation method is identical with step 110.
Step 133:Card the first result and public key is calculated median, preserves median;
This step concrete operation method is identical with step 111.
Step 134:Card judges to whether there is data in buffer area, is then to perform step 135;Otherwise report an error, return to step Rapid 102;
Step 135:Card obtains the data in buffer area, and the data got and the instruction of compound Dynamic Data Authentication are suitable Sequence is spliced, and using spliced result as hash is treated, performs step 136;
In the present embodiment, card obtains the data field of compound Dynamic Data Authentication instruction, by its sequential concatenation in buffer area In data behind, using spliced data as treating hash;
Card obtains the data field of compound Dynamic Data Authentication instruction, is specially:Card is according to compound Dynamic Data Authentication The value of 5th byte of instruction, data are obtained since the 6th byte of compound Dynamic Data Authentication instruction, by what is got The data field that data instruct as compound Dynamic Data Authentication;Or the 6th word that card instructs from compound Dynamic Data Authentication Section starts to obtain to the data in last byte, the data that the data got are instructed as compound Dynamic Data Authentication Domain;
Step 136:Card obtains the first count value, judges whether the first count value is initial value, is to perform step 137;Otherwise step 138 is performed;
Preferably, the initial value of the first count value is 0.
Step 137:Card will be treated in hash deposit buffer area, update the first count value, perform step 139;
Step 138:Card empties buffer area, and the first count value is set into initial value, performs step 139;
Step 139:Card treats hash and carries out Hash calculation, Hash result is obtained, from compound Dynamic Data Authentication Obtained in instruction and block outer random number, according to Hash result and blocked outer random number tissue data to be signed, perform step 140;
Preferably, 4 byte datas are obtained forward since the byte second from the bottom of compound Dynamic Data Authentication instruction, will obtain The data got are as the outer random number of card;
In the present embodiment, according to Hash result and block outer random number tissue data to be signed, be specially:
Card obtains the second data of itself preservation, obtains the 3rd data of itself preservation, obtains the 4th of itself preservation Data, ciphertext in the card of itself preservation is obtained, by ciphertext, Hash result, card in the second data, the 3rd data, the 4th data, card Outer random number sequential concatenation, using obtained splicing result as data to be signed.Wherein, the second data be 0X15,0X2C, 0X02, the 3rd data are the ATC of 2 byte lengths, and the 4th data are the CID of 1 byte length, data to be signed ciphertext in card Length is 8 bytes.
Step 140:Card is signed using preset algorithm to private key, median and data to be signed, obtains signature knot Fruit;
In the present embodiment, preset algorithm is SM2 algorithms;Private key, median and data to be signed are carried out using SM2 algorithms The method of signature is identical with step 113.
Step 141:Card judges whether signature operation succeeds, and is then to perform step 142;Otherwise sent to host computer compound Dynamic Data Authentication signature failure information, return to step 102;
Step 142:Card returns to the compound Dynamic Data Authentication comprising signature result to host computer and responded, return to step 102;
It should be noted that step 103 can also be to 104:Card obtains ciphertext from importing private key instruction, using pre- If ciphertext is decrypted to obtain private key decipherment algorithm and private key identifies, private key and private key mark are preserved;
Accordingly, step 106 replaces with:Card obtains private key mark from Dynamic Data Authentication instruction, judges that inside is No presence and the corresponding median of private key mark, it is then to perform step 112;Otherwise step 107 is performed ';
Wherein, when card judges that inside is not present with private key mark corresponding median, in addition to:Card judges whether to deposit Corresponding public key is being identified with private key, is being then to perform step 108;Otherwise step 107 is performed ';
Step 107 ':Card judge whether with the corresponding private key of private key mark, be to obtain private key, to private key calculate Public key is calculated, preserves public key, performs step 109;Otherwise report an error end, return to step 102;
Step 113 replaces with:Card obtains from Dynamic Data Authentication instruction blocks outer random number, according to the outer random array of card Knit data to be signed, using preset algorithm to private key mark corresponding to private key, private key mark corresponding to median and number to be signed According to being signed, result of signing is obtained.
Step 117 replaces with:Card obtains private key mark from rapid authentication instruction, judges that inside whether there is and private key Median corresponding to mark, it is then to perform step 123;Otherwise step 118 is performed ';
Wherein, when card judges that inside is not present with private key mark corresponding median, in addition to:Card judges whether to deposit Corresponding public key is being identified with private key, is being then to perform step 120;Otherwise step 118 is performed ';
Step 118 ':Card judge whether with the corresponding private key of private key mark, be to obtain private key, to private key calculate Public key is calculated, preserves public key, performs step 119;Otherwise report an error end, return to step 102;
Step 124 replaces with:Card obtains from rapid authentication instruction blocks outer random number, is treated according to the outer random number tissue of card Signed data, median and data to be signed corresponding to private key corresponding to private key mark, private key mark are entered using preset algorithm Row signature, obtains result of signing.
Step 128 replaces with:Card obtains private key mark from the instruction of compound Dynamic Data Authentication, judges internal whether deposit Corresponding median is being identified with private key, is being then to perform step 134;Otherwise step 129 is performed ';
Wherein, when card judges that inside is not present with private key mark corresponding median, in addition to:Card judges whether to deposit Corresponding public key is being identified with private key, is being then to perform step 130;Otherwise step 129 is performed ';
Step 129 ':Card judge whether with the corresponding private key of private key mark, be to obtain private key, to private key calculate Public key is calculated, preserves public key, performs step 130;Otherwise report an error end, return to step 102;
Step 140 replaces with:Card obtains from the instruction of compound Dynamic Data Authentication blocks outer random number, outer random according to card Array knits data to be signed, using preset algorithm to median and waiting to sign corresponding to private key corresponding to private key mark, private key mark Name data are signed, and obtain result of signing.
The method provided using the present embodiment, card can handle the Dynamic Data Authentication instruction that host computer issues, tissue Data to be signed, data to be signed and median are signed;Card can handle the rapid authentication instruction that host computer issues, Data to be signed are organized, data to be signed and median are signed;Card can handle the compound dynamic that host computer issues Data authentication instructs, and organizes data to be signed, data to be signed and median are signed;And can be by handling private key Instruction, private key is updated, and calculate median;In this way can be in the case where private key change, in directly using Between be worth, save the time of signature.
More than, it is only embodiment of the invention, but protection scope of the present invention is not limited thereto, and it is any to be familiar with Those skilled in the art the invention discloses technical scope in, change or replacement can be readily occurred in, should all be covered Within protection scope of the present invention.Therefore, protection scope of the present invention should be defined by scope of the claims.

Claims (18)

  1. A kind of 1. data signature method safely and fast, it is characterised in that including:
    Step S1:It is electric on card;
    Step S2:The instruction that the host computer to be received such as the card issues, and judge the type of the instruction, if being introduced into private Key instructs, then performs step S3;If data signature instructs, then step S4 is performed;
    Step S3:The card obtains ciphertext from the importing private key instruction, using default decipherment algorithm and preset-key pair The ciphertext is decrypted to obtain private key, preserves the private key, return to step S2;
    Step S4:The card judges that therein whether there is median, is then to perform step S9;Otherwise step S5 is performed;
    Step S5:The card judges whether private key, is, obtains the private key, the private key is carried out public affairs are calculated Key, the public key is preserved, perform step S6;Otherwise report an error, return to step S2;
    Step S6:The card obtains the subscriber identity information of itself preservation, calculates the length of the subscriber identity information;
    Step S7:The card obtains the data message of itself preservation, to the subscriber identity information, the subscriber identity information Length, the data message carries out that the first result is calculated;
    Step S8:Median is calculated to first result and the public key in the card, preserves the median;
    Step S9:The card obtains from data signature instruction blocks outer random number, according to random number tissue outside the card Data to be signed, the private key, the median and the data to be signed are signed using preset algorithm, signed As a result, the signature response for including the signature result, return to step S2 are sent to the host computer.
  2. 2. the method as described in claim 1, it is characterised in that the data message includes:First element, second element, Three elements, fourth element;The card is believed the subscriber identity information, the length of the subscriber identity information, the data Breath carries out that the first result is calculated, and is specially:
    The card is by the length of the subscriber identity information, subscriber identity information, first element, described second yuan Plain, described third element and the fourth element sequential concatenation, obtained result is as the first result.
  3. 3. the method as described in claim 1, it is characterised in that the step S8 is specially:
    First result and the public key sequential concatenation are done Hash calculation to obtained splicing result, obtained by the card Hash result as median and preserve.
  4. 4. the method as described in claim 1, it is characterised in that before the step S6, in addition to:
    The card judges whether the first result, is, obtains first result, performs step S8;Otherwise step is performed S6;
    The step S7, in addition to:Preserve first result.
  5. 5. method as claimed in claim 2, it is characterised in that described to use preset algorithm to the private key, the median Signed with the data to be signed, obtain result of signing, be specially:
    Step X1:The card is by the median and the data to be signed sequential concatenation, the splicing result progress to obtaining Hash calculation, obtain the first result of calculation;
    Step X2:The card generates card random number, the third element and fourth element of itself preservation is obtained, according to the card Piece random number, the third element and the fourth element calculate, and obtain the first numerical value;
    Step X3:The card obtain itself preservation The Fifth Element, according to first result of calculation, first numerical value and The The Fifth Element calculates, and obtains the Part I data of signature result;
    Step X4:The card judges whether the Part I data of the signature result meet preparatory condition, is then to return to step Rapid X2;Otherwise step X5 is performed;
    Step X5:The card is according to the private key, the card random number, the Part I data of the signature result and institute The Fifth Element calculating is stated, obtains the Part II data of signature result, performs step X6;
    Step X6:The card judges whether the Part II data of the signature result are equal to 0, is then return to step X2;It is no Then perform step X7;
    Step X7:The card is suitable by the Part II data of the Part I data of the signature result and the signature result Sequence is spliced, using obtained splicing result as signature result.
  6. 6. the method as described in claim 1, it is characterised in that it is described obtain sign result after, in addition to:
    The card judges whether successfully to carry out signature operation, is that the label for including the signature result are then sent to the host computer Name response, return to step S2;Otherwise signature failure information, return to step S2 are sent to the host computer.
  7. 7. the method as described in claim 1, it is characterised in that the data signature instruction is Dynamic Data Authentication instruction;
    When the instruction that host computer issues is Dynamic Data Authentication instruction, in addition to:The card judges the Dynamic Data Authentication Whether instruction is legal, is then to perform step S4;Otherwise Dynamic Data Authentication instruction information unauthorized is sent to the host computer, returned Return step S2;
    It is described according to random number tissue data to be signed outside the card, be specially:The card generates card dynamic random number, will It is random outside the first data, the length of the card dynamic random number, the card dynamic random number and the card itself preserved Number sequential concatenation, using obtained splicing result as data to be signed.
  8. 8. method as claimed in claim 7, it is characterised in that the card judges whether the Dynamic Data Authentication instruction closes Method, it is specially:
    Step a1:The card judges whether the value of the first byte of the Dynamic Data Authentication instruction is 0X00, is to hold Row step a2;Otherwise Dynamic Data Authentication instruction information unauthorized, return to step S2 are sent to the host computer;
    Step a2:The card judge the 3rd of Dynamic Data Authentication instruction the, nybble value whether be 0X00, 0X00, it is then to perform step a3;Otherwise Dynamic Data Authentication instruction information unauthorized, return to step are sent to the host computer S2;
    Step a3:The card is obtained to last byte since the 6th byte that the Dynamic Data Authentication instructs Data, calculate the length of the data got, judge Dynamic Data Authentication instruction the 5th byte value whether with institute It is identical to state the length of the data got, is then to perform step a4;Otherwise Dynamic Data Authentication instruction is sent to the host computer Information unauthorized, return to step S2;
    Step a4:What the card acquisition pre-saved applies interaction feature, judges whether to prop up according to the application interaction feature Dynamic Data Authentication operation is held, is then to perform step S4;Otherwise it is illegal to send Dynamic Data Authentication instruction to the host computer Information, return to step S2.
  9. 9. the method as described in claim 1, it is characterised in that the data signature instruction is rapid authentication instruction;
    When the instruction that host computer issues is rapid authentication instruction, in addition to:Whether the card judges the rapid authentication instruction It is legal, it is then to perform step S4;Otherwise rapid authentication instruction information unauthorized, return to step S2 are sent to the host computer;
    It is described according to random number tissue data to be signed outside the card, be specially:The card obtains the crucial letter of itself preservation Breath, by random number outside the card and the key message sequential concatenation, using splicing result as data to be signed.
  10. 10. method as claimed in claim 9, it is characterised in that the card judges whether the rapid authentication instruction is legal, Specially:
    Step b1:The card judges whether the value of the first byte of the rapid authentication instruction is 0X80, is then to perform step Rapid b2;Otherwise rapid authentication instruction information unauthorized, return to step S2 are sent to the host computer;
    Step b2:The card judges whether the value of the 3rd of rapid authentication instruction the, nybble is 0X00,0X00, It is then to perform step b3;Otherwise rapid authentication instruction information unauthorized, return to step S2 are sent to the host computer;
    Step b3:The card is obtained to the number in last byte since the 6th byte that the rapid authentication instructs According to, calculate the length of the data got, judge the rapid authentication instruction the 5th byte value whether with the acquisition The length of the data arrived is identical, is then to perform step b4;Otherwise rapid authentication instruction information unauthorized is sent to the host computer, Return to step S2;
    Step b4:What the card acquisition pre-saved applies interaction feature, judges whether to prop up according to the application interaction feature Rapid authentication operation is held, is then to perform step S4;Otherwise rapid authentication instruction information unauthorized is sent to the host computer, returned Step S2.
  11. 11. the method as described in claim 1, it is characterised in that the data signature instruction is that compound Dynamic Data Authentication refers to Order;
    When the instruction that host computer issues is compound Dynamic Data Authentication instruction, in addition to:The card judges the compound dynamic Whether data authentication instruction is legal, is then to perform step S4;Otherwise compound Dynamic Data Authentication is sent to the host computer to instruct Information unauthorized, return to step S2.
  12. 12. method as claimed in claim 11, it is characterised in that the card judges the compound Dynamic Data Authentication instruction It is whether legal, be specially:
    Step c1:The card judges whether the value of the first byte of the compound Dynamic Data Authentication instruction is 0X80, is Then perform step c2;Otherwise send compound Dynamic Data Authentication to the host computer and instruct information unauthorized, return to step S2;
    Step c2:The card judge the 3rd of the compound Dynamic Data Authentication instruction the, nybble value whether be 0X00,0X00, it is then to perform step c3;Otherwise send compound Dynamic Data Authentication to the host computer and instruct information unauthorized, Return to step S2;
    Step c3:The card is obtained to last byte since the 6th byte of the compound Dynamic Data Authentication instruction On data, the length of the data got described in calculating, judge the 5th byte of the compound Dynamic Data Authentication instruction Whether value is identical with the length of the data got, is then to perform step c4;Otherwise sent to the host computer compound Dynamic Data Authentication instructs information unauthorized, return to step S2;
    Step c4:What the card acquisition pre-saved applies interaction feature, judges whether to prop up according to the application interaction feature Compound dynamic data authentication operations are held, are then to perform step S4;Otherwise compound Dynamic Data Authentication is sent to the host computer to refer to Make information unauthorized, return to step S2.
  13. 13. method as claimed in claim 9, it is characterised in that
    When the instruction that the host computer issues is rapid authentication instruction, in addition to:Empty buffer area;Judging the rapid authentication When instructing legal, in addition to:
    Rapid authentication instruction is preserved into the buffer area, the first count value is set to initial value, performs step S4;
    The data signature instruction is compound Dynamic Data Authentication instruction, and the instruction that host computer issues is compound Dynamic Data Authentication During instruction, the card obtains from data signature instruction blocks outer random number, waits to sign according to random number tissue outside the card Name data, are specifically included:
    Step K1:The card judges to whether there is data in buffer area, is then to perform step K2;Otherwise report an error, return to step S2;
    Step K2:The card obtains the data in the buffer area, and the data got and the compound dynamic data are recognized Instruction sequences splicing is demonstrate,proved, using obtained splicing result as hash is treated, first count value is obtained, judges described first Whether count value is initial value, is then to perform step K4;Otherwise step K3 is performed;
    Step K3:The card empties the buffer area, and first count value is set into initial value, performs step K5;
    Step K4:The card treats that hash is stored in the buffer area by described, updates first count value, performs step Rapid K5;
    Step K5:The card treats that hash carries out Hash calculation to described, Hash result is obtained, from the compound dynamic number Obtained in being instructed according to certification and block outer random number, according to random number tissue data to be signed outside the Hash result and the card.
  14. 14. method as claimed in claim 13, it is characterised in that described according to random number outside the Hash result and the card Data to be signed are organized, are specially:
    The card obtains the second data of itself preservation, obtains the 3rd data of itself preservation, obtains the 4th of itself preservation Data, ciphertext in the card of itself preservation is obtained, by second data, the 3rd data, the 4th data, the card The outer random number sequential concatenation of ciphertext, the Hash result and the card, using obtained splicing result as data to be signed.
  15. 15. the method as described in claim 1, it is characterised in that also include:Key is generated to instruction;
    When card receive the instruction that host computer issues be generation key to instruction when, the card generates private key, and preserves institute State private key, return to step S2.
  16. 16. the method as described in claim 1, it is characterised in that the step S3, be specially:
    The card obtains ciphertext from the importing private key instruction, and the ciphertext is decrypted using default decipherment algorithm Identified to private key and private key, preserve the private key and private key mark, return to step S2;
    The step S4, it is specially:The card obtains private key mark from data signature instruction, judges that therein is It is no private key mark be present corresponding to median, be then to perform step S9;Otherwise step S5 is performed;
    Step S5, it is specially:The card judge whether private key mark corresponding to private key, be to obtain the private Key, the private key is carried out public key is calculated, preserve the public key, perform step S6;Otherwise report an error, return to step S2;
    Step S9, it is specially:The card obtains from data signature instruction blocks outer random number, according to random outside the card Array knits data to be signed, using preset algorithm to the private key mark corresponding to private key, the private key mark corresponding among Value and the data to be signed are signed, and obtain result of signing, and the label for including the signature result are sent to the host computer Name response, return to step S2.
  17. 17. the method as described in claim 1 or 15, it is characterised in that after the preservation private key, in addition to:
    Public key is calculated according to the private key, preserves the public key, the subscriber identity information of itself preservation is obtained, calculates the user The length of identity information, the data message of itself preservation is obtained, to the length of the subscriber identity information, the subscriber identity information Degree, the data message carry out that the first result is calculated, and median is calculated to first result and the public key, protect Deposit the median;
    The step S4, it is specially:The card judges whether median, is then to perform step S9;Otherwise report an error, return Step S5.
  18. 18. the method as described in claim 1, it is characterised in that the step S3 is specifically included:The card is judged in itself Portion whether there is median, be to remove the median, ciphertext be obtained from the importing private key instruction, using default decryption Algorithm and preset-key are decrypted to obtain private key to the ciphertext, preserve the private key, return to step S2;Otherwise led from described Enter in private key instruction and obtain ciphertext, the ciphertext is decrypted using default decipherment algorithm and preset-key to obtain private key, protect Deposit the private key, return to step S2.
CN201410657600.5A 2014-11-18 2014-11-18 A kind of data signature method safely and fast Active CN104579677B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410657600.5A CN104579677B (en) 2014-11-18 2014-11-18 A kind of data signature method safely and fast

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410657600.5A CN104579677B (en) 2014-11-18 2014-11-18 A kind of data signature method safely and fast

Publications (2)

Publication Number Publication Date
CN104579677A CN104579677A (en) 2015-04-29
CN104579677B true CN104579677B (en) 2017-12-19

Family

ID=53094957

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410657600.5A Active CN104579677B (en) 2014-11-18 2014-11-18 A kind of data signature method safely and fast

Country Status (1)

Country Link
CN (1) CN104579677B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104852806B (en) * 2015-05-15 2018-01-05 飞天诚信科技股份有限公司 A kind of implementation method signed according to Key Tpe
CN105188018B (en) * 2015-08-17 2018-08-28 飞天诚信科技股份有限公司 A kind of safety device and its working method
CN106603238B (en) * 2015-10-20 2019-06-18 飞天诚信科技股份有限公司 A kind of multi-digital certificate signs and issues system, certificate management end, issue apparatus and its working method
CN108055133B (en) * 2017-12-12 2020-02-14 江苏安凰领御科技有限公司 Key security signature method based on block chain technology
CN109446786B (en) * 2018-12-25 2021-01-01 飞天诚信科技股份有限公司 Working method of intelligent secret key device and intelligent secret key device
CN109981284B (en) * 2019-03-11 2022-04-29 三未信安科技股份有限公司 Method and device for realizing elliptic curve digital signature

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2000028493A1 (en) * 1998-11-10 2000-05-18 Kent Ridge Digital Labs A method of encryption and apparatus therefor
EP1030282A1 (en) * 1997-09-02 2000-08-23 Cadix Inc. Digital signature generating server and digital signature generating method
CN102651743A (en) * 2012-05-02 2012-08-29 飞天诚信科技股份有限公司 Method for generating token seeds
CN103095460A (en) * 2013-01-22 2013-05-08 飞天诚信科技股份有限公司 Intelligent card safety communication method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1030282A1 (en) * 1997-09-02 2000-08-23 Cadix Inc. Digital signature generating server and digital signature generating method
WO2000028493A1 (en) * 1998-11-10 2000-05-18 Kent Ridge Digital Labs A method of encryption and apparatus therefor
CN102651743A (en) * 2012-05-02 2012-08-29 飞天诚信科技股份有限公司 Method for generating token seeds
CN103095460A (en) * 2013-01-22 2013-05-08 飞天诚信科技股份有限公司 Intelligent card safety communication method

Also Published As

Publication number Publication date
CN104579677A (en) 2015-04-29

Similar Documents

Publication Publication Date Title
CN104579677B (en) A kind of data signature method safely and fast
CN107453862A (en) Private key generation storage and the scheme used
CN109872155A (en) Data processing method and device
CN106797317A (en) Secure shared key shared system and method
CN103914913B (en) A kind of application of IC cards scene recognition method and system
CN104506321B (en) A kind of method of seed data in renewal dynamic token
CN105656669B (en) The remote repairing method of electronic equipment, is repaired equipment and system at equipment
CN104753684B (en) A kind of method for realizing digital signature and sign test
CN106790156A (en) A kind of smart machine binding method and device
CN108111524A (en) Terminal data protection method and system based on private key dynamic generation mechanism
CN103888938A (en) PKI private key protection method of dynamically generated key based on parameters
CN106919811A (en) File test method and device
CN104796534A (en) Method and device for processing information contents
CN102456116A (en) File encryption method, file decryption method and devices
CN108270791A (en) A kind of method and system of safe operation executable file
CN107135077A (en) Software protecting method and device
CN102883323B (en) A kind of method and apparatus of protection mobile terminal user's private data
CN104993932B (en) A kind of method for improving signature safety
CN110166489A (en) Data transmission method, system, equipment and computer media in a kind of Internet of Things
CN101175267A (en) Communication terminal and software detecting method and device
CN106357608A (en) Method for encrypting and decrypting private data for personal healthcare data
CN107391974A (en) A kind of backup method and device of software protecting equipment data
CN104978542A (en) Secure data storage and data access method and system
CN104636662B (en) A kind of data processing method and terminal device
CN108549551A (en) A kind of the startup method, apparatus and equipment of server network interface card

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