forked from zweib730/SM9-misc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsm9-enc-dec
83 lines (71 loc) · 4.71 KB
/
sm9-enc-dec
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
*********************** SM9 key Generation ***************************
**************The private key deB = (xdeB, ydeB):*********************
94736ACD2C8C8796CC4785E938301A139A059D3537B6414140B2D31EECF41683
115BAE85F5D8BC6C3DBD9E5342979ACCCF3C2F4F28420B1CB4F8C0B59A19B158
7AA5E47570DA7600CD760A0CF7BEAF71C447F3844753FE74FA7BA92CA7D3B55F
27538A62E7F7BFB51DCE08704796D94C9D56734F119EA44732B50E31CDEB75C1
**********************PublicKey Ppubs=[ke]P1:*************************
787ED7B8A51F3AB84E0A66003F32DA5C720B17ECA7137D39ABC66E3C80A892FF
769DE61791E5ADC4B9FF85A31354900B202871279A8C49DC3F220F644C57A7B1
*********************** SM9 encrypt algorithm **************************
*******************QB:=[H1(IDB||hid,N)]P1+Ppube*****************
709D165808B0A43E2574E203FA885ABCBAB16A240C4C1916552E7C43D09763B8
693269A6BE2456F43333758274786B6051FF87B7F198DA4BA1A2C6E336F51FCC
***********************randnum r:********************************
AAC0541779C8FC45E3E2CB25C12B5D2576B2129AE8BB5EE2CBE5EC9E785C
*************************:C1=[r]QB*******************************
2445471164490618E1EE20528FF1D545B0F14C8BCAA44544F03DAB5DAC07D8FF
42FFCA97D57CDDC05EA405F2E586FEB3A6930715532B8000759F13059ED59AC0
***********************g=e(P2,Ppube):****************************
9746FC5B231CEDF36F835C47893D63C6FF652BCB92375CE3C2AB256D1FD56413
232A2F80CFBAE061F196BB99213D50306648AC33CDC78E8F8A1563FFBF3BD3EB
68E8A16C0AC905F692904ABCC004B1ACF12106BD0A15B6E708D76E72B9288EF2
9436A60C403F4F8BAC4DD3E393E25419E634FC2B3DAF247F6092A802F60D5C58
A140EAEF3893D574CB83C01D951A53F51975760BE57F3BBD89817498D2158352
95A2BCCE25359D033FC654BD6A9E462E5BD0686FF6DDD7455F71FFF15AFFD3F0
B04320190B1E90CEDF6AC570147A23AE6F0EAE45034E6C62124DD6E8978F78AD
A504E3B43C1DD36794217FA1B05AC046C4131854C3D3E3A5B5967A64A861F0A2
897F7B35D1C0E21D84D75CFFAC08C73E744A16A47EE76E28A0B03849888D10FF
24443BB424B12C41EAF6D34D925205901F5CBA59CFEBA35224660DB3848B0BF5
825403FB3F681AB2B036DBBA25483D5CB98BD56F3DF95F0A7A705A2F6FD804B
9CE7BC68062182CF5D9F4A98C5A4ED1F3B4CE4EA817D19ED7EF2CE98E6F5864D
***************************w=g^r:**********************************
63253798B7535975A90F202561FC54570FEE88BF69E3B7A512697069E59E1F5D
42D54B984AF01D710BA0030C18738F6B14E4DF472ACAF89399228D85AF117904
B426DFF040C49F9A43BCD7FD7D757B7D1D8D7311C08FC3B57616C5EE137785A3
28D19396DBDFAC50EEE62B1C7F994BB6F9BD9EFB2221A1BE1B6EB3E8F71485B4
A3EEF46E1B99F614D7BD7F57574BA7EBB502AF0BDABA0787C5C4DBC56A344A25
A06790B605CEA0BBAF34776D6B1FC0198A02D05BBAAC6F64A555AB2CA576F0DA
B405CBBF22197B94FD18D27DA0B0E52C8754EE94279634691FEA6E13FFD0584E
AA2A94A7E2259B671896302B4275AE3E8CF2010098D5BEAF19D0A6E60354E1C5
5C97E64F848B06D39BA8828FF59502C081D3DAE68F35F7E6448DB96D220A0FBA
2BE03C51BF062B6F564AE0BFB42DCA36E71D387512E3BCCCA3379B73EC47176
52BE92FB9E78BA9E1D80A156065804935742DBD2B967543011AAC53333909FBF
5FADEC14A2FBD15248E77467442A69698246FB0314C7A8246D952219DD2144ED
*****************K=KDF(C1||w||IDB,klen):***********************
58373260f067ec48667c21c144f8bc33cd3049788651ffd5f738003e51df31174d0e4e402fd87f4581b612f74259db574f67ece6
************************* C2=M^K1 :***************************
1b5f5b0e951489682f3e64e1378cdd5da9513b1c
********************** C3=MAC(K2,C2):*************************
ba672387bcd6de5016a158a52bb2e7fc429197bcab70b25afee37a2b9db9f367
****************************** Cipher:************************************
2445471164490618e1ee20528ff1d545b0f14c8bcaa44544f03dab5dac07d8ff42ffca97d57cddc05ea405f2e586feb3a6930715532b8000759f13059ed59ac0ba672387bcd6de5016a158a52bb2e7fc429197bcab70b25afee37a2b9db9f3671b5f5b0e951489682f3e64e1378cdd5da9513b1c
********************** SM9 Decrypt algorithm **************************
*********************** w = e(C1, deB):****************************
63253798B7535975A90F202561FC54570FEE88BF69E3B7A512697069E59E1F5D
42D54B984AF01D710BA0030C18738F6B14E4DF472ACAF89399228D85AF117904
B426DFF040C49F9A43BCD7FD7D757B7D1D8D7311C08FC3B57616C5EE137785A3
28D19396DBDFAC50EEE62B1C7F994BB6F9BD9EFB2221A1BE1B6EB3E8F71485B4
A3EEF46E1B99F614D7BD7F57574BA7EBB502AF0BDABA0787C5C4DBC56A344A25
A06790B605CEA0BBAF34776D6B1FC0198A02D05BBAAC6F64A555AB2CA576F0DA
B405CBBF22197B94FD18D27DA0B0E52C8754EE94279634691FEA6E13FFD0584E
AA2A94A7E2259B671896302B4275AE3E8CF2010098D5BEAF19D0A6E60354E1C5
5C97E64F848B06D39BA8828FF59502C081D3DAE68F35F7E6448DB96D220A0FBA
2BE03C51BF062B6F564AE0BFB42DCA36E71D387512E3BCCCA3379B73EC47176
52BE92FB9E78BA9E1D80A156065804935742DBD2B967543011AAC53333909FBF
5FADEC14A2FBD15248E77467442A69698246FB0314C7A8246D952219DD2144ED
*****************K=KDF(C1||w||IDB,klen):***********************
58373260F067EC48667C21C144F8BC33CD3049788651FFD5F738003E51DF31174D0E4E402FD87F4581B612F74259DB57
**************************** Message:***********************************
4368696E65736520494245207374616E64617264
(Chinese IBE standard)