forked from zweib730/SM9-misc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsm9-key-ex
135 lines (117 loc) · 7.88 KB
/
sm9-key-ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
*********************** SM9 key Generation ***************************
**********************PublicKey Ppubs=[ke]P1:*************************
9174542668E8F14AB273C0945C3690C66E5DD09678B86F734C4350567ED0628354E598C6BF749A3DACC9FFFEDD9DB6866C50457CFC7AA2A4AD65C3168FF74210
**************The private key deA = (xdeA, ydeA):*********************
0FE8EAB395199B56BF1D75BD2CD610B6424F08D1092922C5882B52DCD6CA832A7DA57BC50241F9E5BFDDC075DD9D32C7777100D736916CFC165D8D36E0634CD783A457DAF52CAD464C903B26062CAF937BB40E37DADED9EDA401050E49C8AD0C6970876B9AAD1B7A50BB4863A11E574AF1FE3C5975161D73DE4C3AF621FB1EFB
**************The private key deB = (xdeB, ydeB):*********************
74CCC3AC9C383C60AF083972B96D05C75F12C8907D128A17ADAFBAB8C5A4ACF701092FF4DE89362670C21711B6DBE52DCD5F8E40C6654B3DECE573C2AB3D29B244B0294AA04290E1524FF3E3DA8CFD432BB64DE3A8040B5B88D1B5FC86A4EBC18CFC48FB4FF37F1E27727464F3C34E2153861AD08E972D1625FC1A7BD18D5539
//////////////////// SM9 Key exchange A1-A4://////////////////////////
*******************QB:=[H1(IDB||hid,N)]P1+Ppube*****************
A1C5EA63AE85302B026C2EE86DC7E8802CE3083061571FC98747011CE088BBD7
635385A8F01C8E73720CA4AD5DE8125810B6271C84B27EC6EAB182C6266E4DA2
***********************randnum rA:******************************
5879DD1D51E175946F23B1B41E93BA31C584AE59A426EC1046A4D03B06C8
////////////////////////////:RA=[r]QB //////////////////////////////
7CBA5B19069EE66AA79D490413D11846B9BA76DD22567F809CF23B6D964BB265
A9760C99CB6F706343FED05637085864958D6C90902ABA7D405FBEDF7B781599
//////////////////////// SM9 Key exchange B1-B7:///////////////////////
*******************QA:=[H1(IDA||hid,N)]P1+Ppube*****************
66C68126E6C3E19769A203C0C3275CF9121A4A116D7851DA9A702A3E14F679DD
52AF31F245EB74CDE62F99A2B557B6219C53C3F3BA7B21E1FDC62EA4BCFF9795
***********************randnum rB:********************************
18B98C44BEF9F8537FB7D071B2C928B3BC65BD3D69E1EEE213564905634FE
*************************:RB=[rB]QA*******************************
861E91485FB7623D2794F495031A35598B493BD45BE37813ABC710FCC1F34482
32D906A469EBC1216A802A7052D5617CD430FB56FBA729D41D9BD668E9EB9600
***********************g1=e(RA,deB):****************************
28542FB6954C84BE6A5F2988A31CB6817BA0781966FA83D9673A9577D3C0C134
5E27C19FC02ED9AE37F5BB7BE9C03C2B87DE027539CCF03E6B7D36DE4AB45CD1
A1ABFCD30C57DB0F1A838E3A8F2BF823479C978BD137230506EA6249C891049E
3497477913AB89F5E2960F382B1B5C8EE09DE0FA498BA95C4409D630D343DA40
4FEC93472DA33A4DB6599095C0CF895E3A7B993EE5E4EBE3B9AB7D7D5FF2A3D1
647BA154C3E8E185DFC33657C1F128D480F3F7E3F16801208029E19434C733BB
73F21693C66FC23724DB26380C526223C705DAF6BA18B763A68623C86A632B05
F63A071A6D62EA45B59A1942DFF5335D1A232C9C5664FAD5D6AF54C11418B0D
8C8E9D8D905780D50E779067F2C4B1C8F83A8B59D735BB52AF35F56730BDE5AC
861CCD9978617267CE4AD9789F77739E62F2E57B48C2FF26D2E90A79A1D86B93
9B1CA08F64712E33AEDA3F44BD6CB633E0F722211E344D73EC9BBEBC92142765
6BA584CE742A2A3AB41C15D3EF94EDEB8EF74A2BDCDAAECC09ABA567981F6437
*******************g2=(e(P2,Ppub3))^rB:*************************
1052D6E9D13E381909DFF7B2B41E13C987D0A9068423B769480DACCE6A06F492
5FFEB92AD870F97DC0893114DA22A44DBC9E7A8B6CA31A0CF0467265A1FB48C7
2C5C3B37E4F2FF83DB33D98C0317BCBBBBF4AC6DF6B89ECA58268B280045E612
6CED9E2D7C9CD3D5AD630DEFAB0B831506218037EE0F861CF9B43C78434AEC38
AE7BF3E1AEC0CB67A03440906C7DFB3BCD4B6EEEBB7E371F0094AD4A816088D
98DBC791D0671CACA12236CDF8F39E15AEB96FAEB39606D5B04AC581746A663D
DD2B7416BAA91172E89D5309D834F78C1E31B4483BB97185931BAD7BE1B9B5
7EBAC0349F8544469E60C32F6075FB0468A68147FF013537DF792FFCE024F857
10CC2B561A62B62DA36AEFD60850714F49170FD94A0010C6D4B651B64F3A3A5E
58C9687BEDDCD9E4FEDAB16B884D1FE6DFA117B2AB821F74E0BF7ACDA2269859
2A430968F16086061904CE201847934B11CA0F9E9528F5A9D0CE8F015C9AEA79
934FDDA6D3AB48C8571CE2354B79742AA498CB8CDDE6BD1FA5946345A1A652F6
***********************g3=g1^rB:********************************
A76B6777AD87C9124C7D7065F74808DB2E80371C70471580B0C7C457A79EA5E7
242FA31FF8E139FAE169A16992F5F029162664CE78B333324B3BDB4C682BF9B2
626D64DCE603F332E9593F62B67A6B002DEB6DD2E7D4FAD3F33C38F202DE204
5327490611B2AE6F849CF779B9B74AD9BA6CF397F61326120777CE4692F85DC2
ADC269D1B62332582D823132A971275477A0CF1DCCF4B2BF096D9110F74E2A01
B1ED06502333B2AB1AE697EA34F2EF8C6E47B0431831706CB5AFCD75754FA795
28F65B3651E184BCED030661EE4A8D670FBAE26796E8CDB66F388ED6644AF851
885C7F924CC7CB20968AA50E8230A3B39C2BB5DD4D753D94BE5DD9A4272CF827
DA649CB8A63172F8FB028CD951E76215824A4EE28405D3C5E5DFDA6C7CE293F
4A40AC8FC5B7168FA54AD3D0B81A0F8F50C164366CCDEC1C9A40DCE9F0A31133
35D89EAEB36F4D31BB6713064CDA8835E2AA4529F42129327C6F7E8AB760654D
58D17E448F6D5CBCA66BD7E33810D270DD3B9436B1BF46B9A17C9D11A5A6B148
***********SKB=KDF(IDA||IDB||RA||RB||g1||g2||g3,klen):***********
C5C13A8F59A97CDEAE64F16A2272A9E7
********SB=Hash(0x82||g1||Hash(g2||g3||IDA||IDB||RA||RB))********
3BB4BCEE8139C960B4D6566DB1E0D5F0B2767680E5E1BF934103E6C66E40FFEE
//////////////////////// SM9 Key exchange A5-A8:///////////////////////
***********************g1=e(Ppub,P2):****************************
28542FB6954C84BE6A5F2988A31CB6817BA0781966FA83D9673A9577D3C0C134
5E27C19FC02ED9AE37F5BB7BE9C03C2B87DE027539CCF03E6B7D36DE4AB45CD1
A1ABFCD30C57DB0F1A838E3A8F2BF823479C978BD137230506EA6249C891049E
3497477913AB89F5E2960F382B1B5C8EE09DE0FA498BA95C4409D630D343DA40
4FEC93472DA33A4DB6599095C0CF895E3A7B993EE5E4EBE3B9AB7D7D5FF2A3D1
647BA154C3E8E185DFC33657C1F128D480F3F7E3F16801208029E19434C733BB
73F21693C66FC23724DB26380C526223C705DAF6BA18B763A68623C86A632B05
F63A071A6D62EA45B59A1942DFF5335D1A232C9C5664FAD5D6AF54C11418B0D
8C8E9D8D905780D50E779067F2C4B1C8F83A8B59D735BB52AF35F56730BDE5AC
861CCD9978617267CE4AD9789F77739E62F2E57B48C2FF26D2E90A79A1D86B93
9B1CA08F64712E33AEDA3F44BD6CB633E0F722211E344D73EC9BBEBC92142765
6BA584CE742A2A3AB41C15D3EF94EDEB8EF74A2BDCDAAECC09ABA567981F6437
*******************g2=(e(RB,deA))^rB:*************************
1052D6E9D13E381909DFF7B2B41E13C987D0A9068423B769480DACCE6A06F492
5FFEB92AD870F97DC0893114DA22A44DBC9E7A8B6CA31A0CF0467265A1FB48C7
2C5C3B37E4F2FF83DB33D98C0317BCBBBBF4AC6DF6B89ECA58268B280045E612
6CED9E2D7C9CD3D5AD630DEFAB0B831506218037EE0F861CF9B43C78434AEC38
AE7BF3E1AEC0CB67A03440906C7DFB3BCD4B6EEEBB7E371F0094AD4A816088D
98DBC791D0671CACA12236CDF8F39E15AEB96FAEB39606D5B04AC581746A663D
DD2B7416BAA91172E89D5309D834F78C1E31B4483BB97185931BAD7BE1B9B5
7EBAC0349F8544469E60C32F6075FB0468A68147FF013537DF792FFCE024F857
10CC2B561A62B62DA36AEFD60850714F49170FD94A0010C6D4B651B64F3A3A5E
58C9687BEDDCD9E4FEDAB16B884D1FE6DFA117B2AB821F74E0BF7ACDA2269859
2A430968F16086061904CE201847934B11CA0F9E9528F5A9D0CE8F015C9AEA79
934FDDA6D3AB48C8571CE2354B79742AA498CB8CDDE6BD1FA5946345A1A652F6
***********************g3=g2^rB:********************************
A76B6777AD87C9124C7D7065F74808DB2E80371C70471580B0C7C457A79EA5E7
242FA31FF8E139FAE169A16992F5F029162664CE78B333324B3BDB4C682BF9B2
626D64DCE603F332E9593F62B67A6B002DEB6DD2E7D4FAD3F33C38F202DE204
5327490611B2AE6F849CF779B9B74AD9BA6CF397F61326120777CE4692F85DC2
ADC269D1B62332582D823132A971275477A0CF1DCCF4B2BF096D9110F74E2A01
B1ED06502333B2AB1AE697EA34F2EF8C6E47B0431831706CB5AFCD75754FA795
28F65B3651E184BCED030661EE4A8D670FBAE26796E8CDB66F388ED6644AF851
885C7F924CC7CB20968AA50E8230A3B39C2BB5DD4D753D94BE5DD9A4272CF827
DA649CB8A63172F8FB028CD951E76215824A4EE28405D3C5E5DFDA6C7CE293F
4A40AC8FC5B7168FA54AD3D0B81A0F8F50C164366CCDEC1C9A40DCE9F0A31133
35D89EAEB36F4D31BB6713064CDA8835E2AA4529F42129327C6F7E8AB760654D
58D17E448F6D5CBCA66BD7E33810D270DD3B9436B1BF46B9A17C9D11A5A6B148
*********S1=Hash(0x82||g1||Hash(g2||g3||IDA||IDB||RA||RB))********
3BB4BCEE8139C960B4D6566DB1E0D5F0B2767680E5E1BF934103E6C66E40FFEE
************SKA=KDF(IDA||IDB||RA||RB||g1||g2||g3,klen)************
C5C13A8F59A97CDEAE64F16A2272A9E7
*********SA=Hash(0x83||g1||Hash(g2||g3||IDA||IDB||RA||RB))********
195D1B7256BA7E0E67C71202A25F8C94FF8241702C2F55D613AE1C6B98215172
//////////////////////// SM9 Key exchange B8:///////////////////////
***************S2=Hash(0x83||g1||Hash(g2||g3||IDA||IDB||RA||RB))****************
195D1B7256BA7E0E67C71202A25F8C94FF8241702C2F55D613AE1C6B98215172