1.简要介绍
2024年5月28日,国家密码管理局官方网站发布《关于对通过商用密码检测机构(商用密码应用安全性评估业务)资质申请材料审查的机构名单进行公示的通知》,按照《商用密码管理条例》、《商用密码检测机构管理办法》有关规定,国家密码管理局组织对新一批商用密码检测机构(商用密码应用安全性评估业务)资质申请材料进行了审查,现将通过材料审查的19家机构名单予以公示。公示期间,任何机构及个人均可通过申请机构所在地省、自治区、直辖市密码管理部门向我局实名提出书面意见。至此,共有174家密评机构通过商用密码检测机构资质申请材料审查,覆盖32个省、直辖市、自治区、新疆生产建设兵团。如下图:
2.能力验证
2.1TLCP协议
在描述这个协议之前我们事先得熟悉GB/T 38636-2020《信息安全技术 传输层密码协议(TLCP)》,和握手协议,在这里我先将握手协议的过程放上去,以便后续的有关讲解,如下图所示:
然后在分析这块内容的时候我们结合着习题来看。
3.习题练习
3.1根据2020年机构能力验证题N1数据包,提交服务端Server Key Exchange中签名值r||s,去掉格式
e4795b5a947526f8e7cbd0edd571ea8749e0efd24323799346ea2c740c006c5a026189e51c19d20d40a82606d0ed72cb9530a189bbb94c09e4559d7d8ff3f598
3045022100
e4795b5a947526f8e7cbd0edd571ea8749e0efd24323799346ea2c740c006c5a
0220
026189e51c19d20d40a82606d0ed72cb9530a189bbb94c09e4559d7d8ff3f598
3.2根据2020年机构能力验证题N1数据包,提交服务端Server Key Exchange中上述签名值r||s所用的签名公钥,去掉格式04
04
49a0975fa53295d2455bdd5ef25d5bd730ba76343b5c2c7e7feb7ee0bebfad0f0f1f76a63b915a0086fc60cc6b8440d3f5041b54422bebd3d4664ef31daaef5e
3.3根据2020年机构能力验证题N1数据包,提交服务端Server Key Exchange中签名源数据
交服务端Server Key Exchange中签名源数据=客户端随机数+服务器端随机数+加密证书的长度+加密证书
客户端随机数
f81ce4d345466f00852fd30dc0555086544391bd2bd0ca13b8b66776a0bbc2ab
服务器端随机数
5ed8968e7d19162fdc1aca131ddf438b55275de556c9994a8ff3bb871393d4cd
加密证书的长度
000225
加密证书
30820221308201c6a003020102020108300a06082a811ccf55018375308187310b300906035504061302434e3110300e06035504080c074265696a696e673110300e06035504070c074265696a696e67310d300b060355040a0c04424a4341310d300b060355040b0c04424a43413116301406035504030c0d424a4341534d32544553544341311e301c06092a864886f70d010901160f737570706f727440626a63612e636e301e170d3230303531323035313231345a170d3330303332313035313231345a30818e310b300906035504061302434e3110300e06035504080c074265696a696e673110300e06035504070c074265696a696e67310d300b060355040a0c04424a4341310d300b060355040b0c04424a4341311d301b06035504030c14626a6361736d3273657276657273727031656e63311e301c06092a864886f70d010901160f737570706f727440626a63612e636e3059301306072a8648ce3d020106082a811ccf5501822d03420004a0e54d33742636210e37a36c6e0102c296813a1812d112e44864337d7a248a6865afe51abf3830971465bdcbc9b003c72e62e0c7ca6ce53cf56f265ae877c442a31a301830090603551d1304023000300b0603551d0f040403020430300a06082a811ccf5501837503490030460221009dd093c169af50fbca6061ed1b10d4394b2768d115027f64533f24080d94f20d022100cc96806594a6ad537b78991c6e673384ef415da8c0d226103dcee21327341032
拼接:
f81ce4d345466f00852fd30dc0555086544391bd2bd0ca13b8b66776a0bbc2ab5ed8968e7d19162fdc1aca131ddf438b55275de556c9994a8ff3bb871393d4cd00022530820221308201c6a003020102020108300a06082a811ccf55018375308187310b300906035504061302434e3110300e06035504080c074265696a696e673110300e06035504070c074265696a696e67310d300b060355040a0c04424a4341310d300b060355040b0c04424a43413116301406035504030c0d424a4341534d32544553544341311e301c06092a864886f70d010901160f737570706f727440626a63612e636e301e170d3230303531323035313231345a170d3330303332313035313231345a30818e310b300906035504061302434e3110300e06035504080c074265696a696e673110300e06035504070c074265696a696e67310d300b060355040a0c04424a4341310d300b060355040b0c04424a4341311d301b06035504030c14626a6361736d3273657276657273727031656e63311e301c06092a864886f70d010901160f737570706f727440626a63612e636e3059301306072a8648ce3d020106082a811ccf5501822d03420004a0e54d33742636210e37a36c6e0102c296813a1812d112e44864337d7a248a6865afe51abf3830971465bdcbc9b003c72e62e0c7ca6ce53cf56f265ae877c442a31a301830090603551d1304023000300b0603551d0f040403020430300a06082a811ccf5501837503490030460221009dd093c169af50fbca6061ed1b10d4394b2768d115027f64533f24080d94f20d022100cc96806594a6ad537b78991c6e673384ef415da8c0d226103dcee21327341032
3.4根据下载的模拟题SSL流量包.pcapng,提交客户端Server Key Exchange中C1||C3||C2,去掉格式
308198
0220
2f1233582f931890b0d6472d39c1729cc20e00d9b26a0ad119c468b8bbbb3e1a
0220
171274bf57ef071e4d76ee3441f39b31996b2438e5f3334f91533e93aa1c3db9
0420
a1e8b8721d5f922c6e33fb7052a2afb0038d05017e2c0ab5035bf772da2cc2f3
0430
c2ce0c6634f3d7626db03963d8c19d8a98c1c4756659b707547fdf0439505e4c1bca72406c22d6ee62e1811d016b402e
2f1233582f931890b0d6472d39c1729cc20e00d9b26a0ad119c468b8bbbb3e1a171274bf57ef071e4d76ee3441f39b31996b2438e5f3334f91533e93aa1c3db9a1e8b8721d5f922c6e33fb7052a2afb0038d05017e2c0ab5035bf772da2cc2f3c2ce0c6634f3d7626db03963d8c19d8a98c1c4756659b707547fdf0439505e4c1bca72406c22d6ee62e1811d016b402e
3.5根据下载的模拟题流量包服务端加密私钥.pem解析出公私钥(公钥不带格式04)。
-----BEGIN PRIVATE KEY-----
MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgb8tUl8wJ17FqiOSp
pHwKa1pOgxQhAP0VoPe/EU0cGAqgCgYIKoEcz1UBgi2hRANCAARipb11eBDLluL8
OMWZOfdyOXKsvWMu40pEW2nFdUPxWpRw+akHNz8Aat6Mbr5k9fUiG3gbC/SYG44t
d40YCWFb
-----END PRIVATE KEY-----
私钥:
6FCB5497CC09D7B16A88E4A9A47C0A6B5A4E83142100FD15A0F7BF114D1C180A
公钥(加密证书公钥)
04
62a5bd757810cb96e2fc38c59939f7723972acbd632ee34a445b69c57543f15a9470f9a907373f006ade8c6ebe64f5f5221b781b0bf4981b8e2d778d1809615b
3.6根据下载的模拟题流量包服务端加密私钥.pem,解密Server Key Exchange中C1||C3||C2,还原预主密钥
私钥:
6FCB5497CC09D7B16A88E4A9A47C0A6B5A4E83142100FD15A0F7BF114D1C180A
数据:
2f1233582f931890b0d6472d39c1729cc20e00d9b26a0ad119c468b8bbbb3e1a171274bf57ef071e4d76ee3441f39b31996b2438e5f3334f91533e93aa1c3db9a1e8b8721d5f922c6e33fb7052a2afb0038d05017e2c0ab5035bf772da2cc2f3c2ce0c6634f3d7626db03963d8c19d8a98c1c4756659b707547fdf0439505e4c1bca72406c22d6ee62e1811d016b402e
使用SM2解密,还原预主密钥:
0101AC14A3D2DA7DCCFCAA9FEE0882F41B9974AA17B8A3070C042DF50A275CAAEC6ED730DFD132EA871BDD19574DC83F
3.7根据模拟题SSL流量包.pcapng,计算主密钥
master secret 转换为16进制(字符串转换工具)
6D617374657220736563726574
PHASH
seed(A0)master secret+客户端随机数+服务端随机数
客户端随机数:
0a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d8
服务端随机数:
5423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac268
拼接:
6D6173746572207365637265740a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d85423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac268
然后将拼接完的数据做原始数据输入,用还原的预主密钥作密钥进行HMAC-SM3得到A1
密钥:0101AC14A3D2DA7DCCFCAA9FEE0882F41B9974AA17B8A3070C042DF50A275CAAEC6ED730DFD132EA871BDD19574DC83F
A1:75466BA297BAA6ABF75FA19698B5DEBDF815D632B98FDAF7C1BF60D8A7724F9E
A2:C7642FABAE939CAD31063AF385648BB48B8FB31E4C94ED97E1CC271208C0E477
A3:33830B6FE2EEFC391AD497F09E942835FF31E9508B75F9FB5C01730CAA3BB53E
然后拼接A1+seed、A2+seed、A3+seed
A1+seed:75466BA297BAA6ABF75FA19698B5DEBDF815D632B98FDAF7C1BF60D8A7724F9E6D6173746572207365637265740a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d85423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac268
A2+seed:C7642FABAE939CAD31063AF385648BB48B8FB31E4C94ED97E1CC271208C0E4776D6173746572207365637265740a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d85423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac268
A3+seed:33830B6FE2EEFC391AD497F09E942835FF31E9508B75F9FB5C01730CAA3BB53E6D6173746572207365637265740a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d85423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac268
然后再将拼接完的A1+seed、A2+seed、A3+seed做hash,密钥还是预主密钥。
hash(A1+seed):
640DA76978A5EFD6E0953088F015FA20EE810E48E24AA6F19A8900BCFF05A3A7
hash(A2+seed):
722DE36C807E5C7CA912E7E6FFA4965E7DB07BEF99DF8C0F27F29C21237F94C7
hash(A3+seed):
36D7EDAE5238BFA4E790B0022BF6A8A631CE7C88F4A061848175999624347A95
然后拼接完hash的数据:
640DA76978A5EFD6E0953088F015FA20EE810E48E24AA6F19A8900BCFF05A3A7722DE36C807E5C7CA912E7E6FFA4965E7DB07BEF99DF8C0F27F29C21237F94C736D7EDAE5238BFA4E790B0022BF6A8A631CE7C88F4A061848175999624347A95
主密钥:
640DA76978A5EFD6E0953088F015FA20EE810E48E24AA6F19A8900BCFF05A3A7722DE36C807E5C7CA912E7E6FFA4965E (96字节)
3.8根据模拟题SSL流量包.pcapng,计算工作密钥
key expansion转换成16进制
6B657920657870616E73696F6E
seed(A0):服务端随机数+客户端随机数
服务端随机数:
5423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac268
客户端随机数:
0a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d8
拼接:
6B657920657870616E73696F6E5423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac2680a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d8
注:密钥:(此过程支不过是是将服务端随机数放到了客户端随机数前面,这里不再进行过程演示)640DA76978A5EFD6E0953088F015FA20EE810E48E24AA6F19A8900BCFF05A3A7722DE36C807E5C7CA912E7E6FFA4965E
A1:6003A5937FAA6C9276656BD9CF11E5FC44D1DA8CF8916CC3F1A1D9C9C5B2C364
A2:0A45328C9D23A88AD0B0DFE3656996B979BD4A2730A3F8EDE29BC392153B6A6B
A3:FEE4DB5E22A5E48C3C0E0B88509763940A8E65C4AAF850C00AE7EB72282089CF
A4:8807466C968862F58C17B171B3520AB2A519D5DF00C8FC991E9D696244C95437
A1+seed:
6003A5937FAA6C9276656BD9CF11E5FC44D1DA8CF8916CC3F1A1D9C9C5B2C3646B657920657870616E73696F6E5423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac2680a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d8
A2+seed:
0A45328C9D23A88AD0B0DFE3656996B979BD4A2730A3F8EDE29BC392153B6A6B6B657920657870616E73696F6E5423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac2680a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d8
A3+seed:
FEE4DB5E22A5E48C3C0E0B88509763940A8E65C4AAF850C00AE7EB72282089CF6B657920657870616E73696F6E5423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac2680a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d8
A4+seed:
8807466C968862F58C17B171B3520AB2A519D5DF00C8FC991E9D696244C954376B657920657870616E73696F6E5423003bf0b79c2a134837d6c560dfb6d11cebdb2ab84e701fafe387b31ac2680a359775d8a2c2fd2756261b8ae86767db7b3cd3be532c9665ea432dc260b6d8
然后做hash(Ax+seed)
client mac key(用来做HMAC)
87E00935DC21B9D87E3E5616179307D817966079A0DEA9B9D09A4883CBF0E13D
serer mac key
B4B53C3B2ACAFE5781712816C1A3A2CECE09D5837EB3389BDF1E471B06BC8157
client enc(用来加解密)
022A23065301DE9E49AAA0879E4ECBF2
servce enc key
622CDA5B8994A0BB4496F03B8C13A4CD
client IV(IV值)
145BA093616E5939AAE6B59E4BED7701
server IV
45482C297F4C7CC76B497FCB1B2F4A84
3.9根据模拟题SSL流量包.pcapng工作密钥,解密第8行端口52117到50052的encrypted handshake massage,以及第12行、14行application data数据
第8行解密的handshake massage
encrypted handshake massage:
01cb7997f77ee792a871e70ece4c148eba47b751a1032ec619bea239e1954b8e106e3d7c37491dc809be6c1979d11647ff20e9cae997d9dde43619ca2ae773df9fc8b6304ced8c594ad7d0ff9eeb0067
sm4-cbc解密
密钥:022A23065301DE9E49AAA0879E4ECBF2
IV:145BA093616E5939AAE6B59E4BED7701
798C9C0B7015B173E832F41CEDCD0F821400000C778001771615C2D5B9E553CB6DD2068DC92F27D8CDA2C44584815660A0BED385C0C569A2ED6B294DFA4B3EC90F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
然后第十二行和第十四行的handshake massage同样是以
sm4-cbc解密
密钥:022A23065301DE9E49AAA0879E4ECBF2
IV:145BA093616E5939AAE6B59E4BED7701
这里不再进行相关截图描述,直接放结果了
第12行解密的handshake massage
175D3C90378D99285BB69756C0EB139A47FBA05E1B8988C9AE7B934460DDFF88600C5FF0980242EC9677D2F557C746FB020E0E0E0E0E0E0E0E0E0E0E0E0E0E0E
第14行解密的handshake massage
980B3648B73D349D1A85EF65B8BE0C794554202F20485454502F312E310D0A486F73743A206C6F63616C686F73740D0A436F6E6E656374696F6E3A20636C6F73650D0A0D0ACBA63F629594DA48A591A34B0EDE377F23378B3C672D578847085FF2171278EF0A0A0A0A0A0A0A0A0A0A0A
3.10根据模拟题SSL流量包.pcapng工作密钥,解密第10行端口50052到52117的encrypted handshake massage
和上面的过程一样 只不过这时的
sm4-cbc解密
密钥:622CDA5B8994A0BB4496F03B8C13A4CD
IV:45482C297F4C7CC76B497FCB1B2F4A84
D6770A0BD9253B6F4DE7A42779D7605E1400000CE7CDA178C6D6D8B6A45FBB02CE9CC490CF0D61DFAEA90AEE4CC5DEB1378639DE36153C357B429DA0A0B19F660F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F
0f74bb8cbfa527b2d9b75c4674e45f94a862b218e70bc311cc4745e10398ff3703ddbcc6853d918e1df031517caa78b0a3ab3dac70dddf09eee9266fb685151335bb8a3e7b8ea2bf6d71d45455e51b23
3.11请伪造新的消息,消息分组长度可变,并伪造出新的mac
消息1:9e07a1cdcd795bc9cf5ae8984eeed7de
mac1:6e3ede668142ead5ceb7e0ea2223d4bb
解题思路:首先了解对称加密模式,CBC模式可以产生MAC,且初始向量为全零时,可构造MAC值
当IV全0时,IV和密文1异或=M1,M1加密得到MAC1
当M1异或(MAC1异或M1)=MAC1,所以M2=M1拼接(MAC1异或M1)
CBC模式的加密和解密流程如图所示。在CBC模式下,每个明文分组在加密之前,先与反馈至输入端的前一组密文分组按位异或后,再送至加密模块进行加密。其中,IV是一个初始向量,无须保密,但须随着消息的更换而更换,且收发双方必须选用同一个IV。显然,计算的密文分组不仅与当前明文分组有关,而且通过反馈作用还与以前的明文分组有关。在解密过程中,初始值IV用于产生第一个明文输出;之后,前一个密文分组与当前密文分组解密运算后的结果进行异或,得到对应的明文分组。
新消息:
9e07a1cdcd795bc9cf5ae8984eeed7def0397fab4c3bb11c01ed08726ccd0365
新消息MAC:
6e3ede668142ead5ceb7e0ea2223d4bb
f0397fab4c3bb11c01ed08726ccd0365
3.12后台对于用户身份鉴别的验证逻辑如下所述:用用户提交的数字证书(hex格式,以3082打头)验证用户提交的签名值(sm2withsm3算法)以及签名原数据,如果验证成功,则提示用户鉴别成功。 证书(请提交hex格式证书)
解题思路 这个时候我们可以生成一个SM2的公私钥对,
私钥:
7455A2FF5B02D79DA427E30658C2641925ED77AE11B2CACD5BD1E5C36798FA53
公钥:
353A365B7BCC06152D06D22E6AFF0AE2E6569692D07E40EDC35CC80F24132ECC
3AAA769C143B8C558CB6879AB2BEE2BE3D460391A065E9D790F7909F70D623E5
然后对12345678数据进行签名
得到签名值:
50F9C05D233DB820DB566B137FD1D33D6732C16FADABB43C10AF670AB6A1C96AE8E16DFA23F81D3B148367C4FCF6305AF43986034B16072A19EA686229218947
然后我们将原来的证书导出来:
-------------------------------------------------------------------------------------------------------------------------------
30820203308201a9a003020102020802ce05b3832c3387300a06082a811ccf550183753042310b300906035504061302434e310f300d06035504080c06e6b599e6b19f310f300d06035504070c06e69dade5b79e3111300f060355040a0c08e6b58be8af954341301e170d3231303533303130333632345a170d3331303533303036353530325a305a310b300906035504061302434e310f300d06035504080c06e6b599e6b19f310f300d06035504070c06e69dade5b79e31153013060355040a0c0ce6b58be8af95e585ace58fb831123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a811ccf5501822d034200
040634504b9925f0832a72005967eaa960695f9ae87d5169306ba45d76722b98f9b9daf5ec015db01d336c183c1c6af227d97e5fd39e0bd7f1302aacdc31f29aef (原始公钥)
a371306f300e0603551d0f0101ff0404030206c0301d0603551d250416301406082b0601050507030106082b06010505070302301d0603551d0e041604149a39eb4f5aa952500f24238512c66ed0f00b8545301f0603551d2304183016801491d3d7a6f97b77fc795dcbd232acbb4004b0f8ff300a06082a811ccf55018375034800304502201613cda55da36d2e534e2c096ece5254a549e87690d0d76d6d817e5f667295c1022100aa4877ee80ba6a2ba96d1041c81a3ebc0fdcec8979dd573cbc6f39890c992753
---------------------------------------------------------------------------------------------------------------------------------
然后我们将公钥进行替换之后进行验证:
30820203308201a9a003020102020802ce05b3832c3387300a06082a811ccf550183753042310b300906035504061302434e310f300d06035504080c06e6b599e6b19f310f300d06035504070c06e69dade5b79e3111300f060355040a0c08e6b58be8af954341301e170d3231303533303130333632345a170d3331303533303036353530325a305a310b300906035504061302434e310f300d06035504080c06e6b599e6b19f310f300d06035504070c06e69dade5b79e31153013060355040a0c0ce6b58be8af95e585ace58fb831123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a811ccf5501822d034200353A365B7BCC06152D06D22E6AFF0AE2E6569692D07E40EDC35CC80F24132ECC3AAA769C143B8C558CB6879AB2BEE2BE3D460391A065E9D790F7909F70D623E5a371306f300e0603551d0f0101ff0404030206c0301d0603551d250416301406082b0601050507030106082b06010505070302301d0603551d0e041604149a39eb4f5aa952500f24238512c66ed0f00b8545301f0603551d2304183016801491d3d7a6f97b77fc795dcbd232acbb4004b0f8ff300a06082a811ccf55018375034800304502201613cda55da36d2e534e2c096ece5254a549e87690d0d76d6d817e5f667295c1022100aa4877ee80ba6a2ba96d1041c81a3ebc0fdcec8979dd573cbc6f39890c992753
伪造成功!