{"id":277,"date":"2018-08-14T23:57:04","date_gmt":"2018-08-14T15:57:04","guid":{"rendered":"https:\/\/www.tiferking.cn\/?p=277"},"modified":"2024-06-16T11:35:32","modified_gmt":"2024-06-16T03:35:32","slug":"sha-256-%e6%91%98%e8%a6%81%e7%ae%97%e6%b3%95-%e5%ae%9e%e7%8e%b0-%e5%8f%8a-%e9%80%9f%e5%ba%a6%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.tiferking.cn\/index.php\/2018\/08\/14\/277\/","title":{"rendered":"SHA-256 \u6458\u8981\u7b97\u6cd5 \u5b9e\u73b0 \u53ca \u4f18\u5316"},"content":{"rendered":"\n<p>\u5f88\u4e45\u6ca1\u6709\u53d1\u6587\u7ae0\u4e86\u554a\uff0c\u54b3\u54b3\uff0c\u6700\u8fd1\u8003\u8bd5\u8003\u7684\u4eba\u5fc3\u529b\u4ea4\u7601\u3002\u8fd9\u4e24\u5929\u7531\u4e8e\u9700\u8981(<del>\u771f\u7684\u662f\u81ea\u5df2\u7684\u9700\u8981\u4e48\uff1f<\/del>)\uff0c\u505a\u4e86\u505a\u6458\u8981\u7b97\u6cd5\u65b9\u9762\u7684\u5de5\u4f5c\uff0c\u4ee5\u524d\u90fd\u662f\u8c03\u5e93\uff0c\u4f46\u662f\u73b0\u5728\u9700\u8981\u5c06\u7b97\u6cd5\u79fb\u690d\u5230stm32\u4e0a\uff0c\u4e0d\u4ec5\u8981\u4fdd\u8bc1\u529f\u80fd\u6027\u8fd8\u8981\u4fdd\u8bc1\u6548\u7387\uff0c\u4e8e\u662f\u81ea\u5df1\u7f16\u5199\u4e86\u4e00\u4e2aSHA-256\u7684\u7a0b\u5e8f\uff0c\u73b0\u5206\u4eab\u4e00\u4e0b\u3002<\/p>\n\n\n\n<p>\u4f5c\u4e3a\u54c8\u5e0c\u7b97\u6cd5\u5728\u6211\u5370\u8c61\u4e2d\u6700\u65e9\u542c\u8bf4\u7684\u662fmd5\u7b97\u6cd5\uff0c\u4e0d\u8fc7\u540e\u6765\u53c8\u542c\u8bf4\u5b83\u88ab\u53d1\u73b0\u6709\u4e00\u4e9b\u5f31\u70b9\uff0c\u5176\u53d1\u73b0\u8005\u662f\u6211\u56fd\u7684\u5bc6\u7801\u5b66\u4e13\u5bb6\u738b\u5c0f\u4e91\u6559\u6388\uff0c\u4e0d\u8fc7\u867d\u7136\u5176\u5f31\u70b9\u88ab\u53d1\u73b0\uff0c\u4e5f\u5e76\u4e0d\u5f71\u54cd\u5176\u5728\u4e00\u4e9b\u9886\u57df\u7684\u5e94\u7528\uff0c\u81f3\u4eca\u6211\u8fd8\u7ecf\u5e38\u80fd\u770b\u5230md5\u7684\u8eab\u5f71\u3002\u5f53\u7136\u6211\u8fd9\u91cc\u9009\u7528\u4e86\u76f8\u5bf9\u5b89\u5168\u4e00\u4e9b\u7684SHA-256\u7b97\u6cd5\uff0cSHA\u5168\u79f0\u4e3aSecure Hash Algorithm\uff0c\u610f\u4e3a\u5b89\u5168\u54c8\u5e0c\u7b97\u6cd5\uff0c\u5176\u7b97\u6cd5\u5230\u76ee\u524d\u4e3a\u6b62\u5386\u7ecf\u4e86\u4e09\u4ee3\u7684\u53d8\u9769\uff0cSHA-1\uff0cSHA-2\u548cSHA-3\uff0c\u800cSHA-256\u662fSHA-2\u7cfb\u5217\u4e2d\u7684\u4e00\u4e2a\u7b97\u6cd5\uff0c\u90a3\u4e48\u5148\u4eceSHA-256\u7b97\u6cd5\u672c\u8eab\u5f00\u59cb\u8bb2\u8d77\u3002<\/p>\n\n\n\n<p>\u54c8\u5e0c\u505a\u4e3a\u4e00\u4e2a\u6458\u8981\u7b97\u6cd5\uff0c\u76f4\u89c2\u4e0a\u8bb2\uff0c\u4e0d\u7ba1\u7ed9\u5176\u8f93\u5165\u4ec0\u4e48\u5185\u5bb9\uff0c\u5176\u7ed3\u679c\u6700\u7ec8\u90fd\u4f1a\u662f\u4e00\u4e2a\u56fa\u5b9a\u957f\u5ea6\u7684\u7801\u4e32\u3002\u5bf9\u4e8eSHA-256\uff0c\u5176\u8f93\u51fa\u7684\u957f\u5ea6\u4fbf\u662f256bit\uff0c\u4e5f\u5c31\u662f\u8bf4\u6240\u6709\u7684\u6570\u636e\u90fd\u53ef\u4ee5\u6620\u5c04\u5230\u8fd9\u4e2a2^256\u4e2a\u503c\u7684\u57df\u4e2d\u3002\u4e5f\u5c31\u662f\u8bf4\u5176\u4e0e\u666e\u901a\u4e0a\u8bb2\u7684\u52a0\u5bc6\u7b97\u6cd5\u6709\u6240\u4e0d\u540c\u7684\u662f\uff0c\u54c8\u5e0c\u7b97\u6cd5\u4f1a\u5c06\u8f93\u5165\u7684\u4fe1\u606f\u635f\u5931\u4e00\u90e8\u5206\uff0c\u56e0\u4e3a\u5176\u503c\u57df\u662f\u6709\u9650\u7684\uff0c\u800c\u5b9a\u4e49\u57df\u5374\u662f\u65e0\u9650\u7684\u3002\u6240\u4ee5\u7ecf\u8fc7\u8fd9\u79cd\u7b97\u6cd5\u5904\u7406\uff0c\u5176\u7ed3\u679c\u662f\u4e0d\u80fd\u9006\u5411\u6c42\u5f97\u503c\u7684\u3002(\u5176\u5b9e\u54c8\u5e0c\u7b97\u6cd5\u5e76\u4e0d\u80fd\u7b97\u4f5c\u52a0\u5bc6\u7b97\u6cd5)<\/p>\n\n\n\n<p>\u6bd4\u65b9\u5728\u7f51\u7ad9\u5b58\u50a8\u7528\u6237\u5bc6\u7801\u7684\u65f6\u5019\uff0c\u4e3a\u4e86\u9632\u6b62\u5165\u4fb5\u8005\u5165\u4fb5\u6570\u636e\u5e93\u540e\u76f4\u63a5\u62ff\u5230\u7528\u6237\u7684\u5bc6\u7801\uff0c\u5f80\u5f80\u4f1a\u4f7f\u7528\u54c8\u5e0c\u51fd\u6570\u5bf9\u7528\u6237\u7684\u5bc6\u7801\u8fdb\u884c\u5904\u7406\uff0c\u8fd9\u6837\u6bcf\u5f53\u7528\u6237\u767b\u5f55\u7684\u65f6\u5019\u4fbf\u53ef\u4ee5\u5c06\u7528\u6237\u63d0\u4ea4\u7684\u5bc6\u7801\u8fdb\u884c\u540c\u6837\u7684\u8fd0\u7b97\u6765\u5bf9\u6bd4\u7ed3\u679c\u9a8c\u8bc1\u8eab\u4efd\uff0c\u540c\u6837\u53ef\u4ee5\u4fdd\u8bc1\u5728\u6570\u636e\u5e93\u88ab\u5165\u4fb5\u540e\u7528\u6237\u7684\u5bc6\u7801\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u4e0d\u4f1a\u5b8c\u5168\u6cc4\u9732(<del>\u7b80\u5355\u7684\u5bc6\u7801\u4e5f\u5c31\u67e5\u4e2a\u8868\u7684\u4e8b\uff0c\u548c\u88f8\u5954\u6ca1\u533a\u522b<\/del>)\u3002\u5f53\u7136\u8fd9\u53ea\u662f\u5176\u4e2d\u4e00\u4e2a\u5c0f\u5e94\u7528\uff0c\u5176\u5728\u6570\u5b57\u7b7e\u540d\uff0c\u6587\u4ef6\u9632\u4f2a\u7b49\u65b9\u9762\u4e5f\u6709\u5e7f\u6cdb\u5e94\u7528\uff0c\u751a\u81f3\u8bf4\u662f\u6bd4\u7279\u5e01\u8fd9\u6837\u7684\u533a\u5757\u94fe\u8d27\u5e01\u7684\u6838\u5fc3\u7b97\u6cd5\u4e5f\u4e0d\u4e3a\u8fc7\u3002<\/p>\n\n\n\n<p><strong>SHA-256\u7b97\u6cd5\u7684\u8fc7\u7a0b<\/strong><\/p>\n\n\n\n<p>\u9996\u5148\u6211\u60f3\u7b80\u5355\u76f4\u767d\u7684\u603b\u7ed3\u4e00\u4e0bSHA-256\u7684\u7b97\u6cd5\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p><strong>\u7b2c\u4e00\u6b65\uff1a<\/strong>\u5148\u5bf9\u8f93\u5165\u7684\u6570\u636e\u8fdb\u884c\u8865\u4f4d\u548c\u5206\u5757\uff0cSHA-256\u7b97\u6cd5\u7684\u6570\u636e\u5206\u4e3a512bit\u4e00\u4e2a\u533a\u5757\u3002\u7136\u540e\u5faa\u73af\u7684\u505a\u8fed\u4ee3\u8fd0\u7b97\uff0c\u76f4\u5230\u7b97\u51fa\u7ed3\u679c\u3002\u7531\u4e8e\u6570\u636e\u5e76\u975e\u4e00\u5b9a\u662f512bit\u7684\u6574\u6570\u500d\uff0c\u6240\u4ee5\u9700\u8981\u5148\u8fdb\u884c\u8865\u4f4d\uff0c\u4f7f\u5176\u6210\u4e3a512bit\u5757\u7684\u6574\u6570\u500d\u3002\u8865\u4f4d\u7684\u64cd\u4f5c\u4e3a\u5411\u6570\u636e\u540e\u5148\u88651\u4f4d1\u7136\u540e\u88650\u81f3\u4f4d\u957f\u5ea6\u5bf9512\u53d6\u6a21\u4e3a448\u4e3a\u6b62\uff0c\u7136\u540e\u518d\u5728\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a64\u4f4d\u957f\u7684\u6570\u636e\u957f\u5ea6\u5b57\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u9700\u8981\u8be6\u7ec6\u8bf4\u4e00\u4e0b\uff0c\u56e0\u4e3a\u4e00\u5f00\u59cb\u6211\u4e5f\u6709\u70b9\u72af\u6655\uff0c\u6bd4\u65b9\u8bf4\u4f60\u73b0\u5728\u6709\u4e00\u4e2a\u4fe1\u606f\u4e3a\u201c01010\u201d\uff0c\u90a3\u4e48\u4f60\u7684\u8865\u4f4d\u7ed3\u679c\u662f\u201c0101010000&#8230;(\u7701\u7565496\u4e2a\u201c0\u201d)&#8230;000101\u201d\uff0c\u6700\u540e\u4e00\u4f4d\u8fd9\u4e2a\u957f\u5ea6\u5b57\u7684\u6570\u503c\u4e3a\u4f60\u8f93\u5165\u7684\u6570\u636e\u7684bit\u6570\u3002\u5f53\u7136\u5728\u8ba1\u7b97\u673a\u5f53\u4e2d\u4e00\u822c\u4e5f\u4e0d\u4f1a\u78b0\u5230\u975e\u6574byte\u7684\u4fe1\u606f\uff0c\u6240\u4ee5\u8fd9\u4e2a\u957f\u5ea6\u5f80\u5f80\u662f8\u7684\u500d\u6570\uff0c\u800c\u5728\u8fdb\u884c\u88651\u64cd\u4f5c\u65f6\uff0c\u5f80\u5f80\u4e5f\u662f\u5728\u540e\u9762\u8ddf\u4e00\u4e2a0x80\u5b57\u8282\u3002\u5f53\u7136\u4e00\u65e6\u4f60\u8f93\u5165\u7684\u4fe1\u606f\u8d85\u8fc7\u4e86448bit\u90a3\u4e48\u5c31\u5fc5\u987b\u5411\u6570\u636e\u540e\u6dfb\u52a0\u65b0\u7684\u4e00\u4e2a512bit\u533a\u5757\u6765\u8865\u4f4d\uff0c\u8fd9\u4e2a\u65b0\u7684\u533a\u5757\u53ef\u80fd\u4ec5\u5305\u542b0x00\u548c\u957f\u5ea6\u5b57\u3002<\/p>\n\n\n\n<p>\u6211\u5c06\u5176\u603b\u7ed3\u4e3a\u4ee5\u4e0b\u4e09\u79cd\u60c5\u51b5\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-1.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1164\" height=\"674\" src=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-1.jpg\" alt=\"\" class=\"wp-image-279\" srcset=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-1.jpg 1164w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-1-300x174.jpg 300w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-1-768x445.jpg 768w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-1-1024x593.jpg 1024w\" sizes=\"auto, (max-width: 1164px) 100vw, 1164px\" \/><\/a><\/figure>\n\n\n\n<p>\u8fd9\u6837\u5bf9\u5176\u5206\u7c7b\u6211\u4eec\u53ef\u4ee5\u91c7\u53d6\u4e09\u79cd\u7b80\u4fbf\u7684\u65b9\u6cd5\u6765\u8865\u4f4d\u3002<\/p>\n\n\n\n<p><strong>\u7b2c\u4e8c\u6b65\uff1a<\/strong>\u5bf9\u533a\u5757\u8fdb\u884c\u6df7\u5408\u3002\u8fd9\u91cc\u4fbf\u9700\u8981\u4ecb\u7ecdSHA-256\u7684\u51e0\u79cd\u6df7\u5408\u51fd\u6570\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-2.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"690\" height=\"366\" src=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-2.jpg\" alt=\"\" class=\"wp-image-280\" srcset=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-2.jpg 690w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-2-300x159.jpg 300w\" sizes=\"auto, (max-width: 690px) 100vw, 690px\" \/><\/a><\/figure>\n\n\n\n<p>\u5176\u4e2d\u7b26\u53f7\u542b\u4e49\u4e3a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-3.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"413\" height=\"311\" src=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-3.jpg\" alt=\"\" class=\"wp-image-281\" srcset=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-3.jpg 413w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-3-300x226.jpg 300w\" sizes=\"auto, (max-width: 413px) 100vw, 413px\" \/><\/a><\/figure>\n\n\n\n<p>SHA-256\u4fbf\u662f\u5229\u7528\u8fd9\u51e0\u79cd\u6df7\u5408\u51fd\u6570\u5bf9\u6570\u636e\u8fdb\u884c\u6df7\u5408\uff0c\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u91cc\u524d\u4e24\u79cd\u51fd\u6570Ch(x)\u548cMaj(x)\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u65f6\u4fbf\u5df2\u7ecf\u4ea7\u751f\u4e86\u4fe1\u606f\u7684\u635f\u5931\uff0c\u800c\u540e\u56db\u79cd\u51fd\u6570\u5219\u662f\u4e00\u4e00\u5bf9\u5e94\u7684\uff0c\u6ca1\u6709\u635f\u5931\u4efb\u4f55\u4fe1\u606f\u3002(\u8fd9\u91cc\u5e76\u4e0d\u662f\u51ed\u7a7a\u81c6\u6d4b\u5176\u8f93\u5165bit\u4e0e\u8f93\u51fabit\u4fbf\u8349\u8349\u5f97\u51fa\u7ed3\u8bba\uff0c\u800c\u662f\u7ecf\u8fc7\u4e86\u7a0b\u5e8f\u679a\u4e3e\u9a8c\u8bc1\uff0c\u56db\u4e2a\u51fd\u6570\u7684\u5b9a\u4e49\u57df\u4e0e\u503c\u57df\u5747\u662f\u4e00\u4e00\u6620\u5c04\u7684\u3002)(<del>\u5185\u5b58\u5927\u5c31\u662f\u4e3a\u6240\u6b32\u4e3a<\/del>)<\/p>\n\n\n\n<p>\u5176\u6df7\u5408\u8fc7\u7a0b\u53ef\u4ee5\u7531\u4e0b\u56fe\u603b\u7ed3(\u56fe\u4e2d\u4ec5\u4e3a\u4e00\u8f6e\u6df7\u5408)\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-4.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1573\" height=\"729\" src=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-4.jpg\" alt=\"\" class=\"wp-image-282\" srcset=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-4.jpg 1573w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-4-300x139.jpg 300w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-4-768x356.jpg 768w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-4-1024x475.jpg 1024w\" sizes=\"auto, (max-width: 1573px) 100vw, 1573px\" \/><\/a><\/figure>\n\n\n\n<p>\u56fe\u4e2d\u6bcf\u4e00\u4e2a\u8272\u5757\u8868\u793a32bit\u7684\u6570\u636e\uff0c\u7eff\u8272\u6846\u7ebf\u4e2d\u7684\u201c+\u201d\u8868\u793a32\u4f4d\u52a0\u6cd5\uff0c\u5269\u4e0b\u7684\u4fbf\u662f\u6df7\u5408\u516c\u5f0f\uff0c\u84dd\u8272\u6846\u7ebf\u4e2d\u4e3a\u6df7\u5408\u65f6\u8f93\u5165\u7684\u6570\u636e\u3002Wt\u662f\u7531\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u7ecf\u8fc7\u53d8\u6362\u5f97\u6765\u7684\uff0c\u800cKt\u4e3a\u5df2\u77e5\u5e38\u6570\u3002\u5c06\u56fe\u4e2d\u7684\u6df7\u5408\u8fc7\u7a0b\u8fed\u4ee3\u91cd\u590d64\u6b21\uff0c\u4fbf\u53ef\u5f97\u5230\u6700\u7ec8\u7684SHA-256\u503c\u3002<\/p>\n\n\n\n<p>\u5176\u4e2d\u6700\u521d\u7684A-H\u503c\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">A = 0x6a09e667;\nB = 0xbb67ae85;\nC = 0x3c6ef372;\nD = 0xa54ff53a;\nE = 0x510e527f;\nF = 0x9b05688c;\nG = 0x1f83d9ab;\nH = 0x5be0cd19;<\/pre>\n\n\n\n<p>\u8fd98\u4e2a\u503c\u5206\u522b\u4e3a\u524d8\u4e2a\u8d28\u6570(2,3,5,7,11,13,17,19)\u7684\u5e73\u65b9\u6839\u53d6\u5c0f\u6570\u90e8\u5206\u524d32bit\u3002\u6df7\u5408\u65f6\u4f7f\u7528\u7684\u5e38\u6570Kt\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">uint32_t K[] = { \n0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};<\/pre>\n\n\n\n<p>\u8fd964\u4e2a\u503c\u5219\u662f\u524d64\u4e2a\u8d28\u6570\u7684\u7acb\u65b9\u6839\u53d6\u5c0f\u6570\u90e8\u5206\u524d32bit\u800c\u6765\u3002(<del>\u4e8b\u5b9e\u4e0a\u6211\u89c9\u5f97\u8fd9\u4e9b\u53d6\u503c\u6ca1\u4ec0\u4e48\u7406\u8bba\u4f9d\u636e\uff0c\u5c31\u8ddf\u6211\u4e00\u62cd\u5927\u817f\u60f3\u51fa\u6765\u7684\u4e00\u6837\uff0c\u770b\u8d77\u6765\u5f88\u6df7\u4e71\u5c31\u662f\u4e86<\/del>)<\/p>\n\n\n\n<p>Wt\u662f\u7528\u6237\u9700\u8981\u505aSHA-256\u53d8\u6362\u8f93\u5165\u7684\u6570\u636e\uff0c\u5176\u4e2d\u524d16\u8f6e\u53d8\u6362\u8f93\u5165\u7684\u6570\u636e\u4e3a\u4e00\u4e2a512bit\u533a\u5757\u5206\u5272\u4e3a16\u4e2a32bit\u533a\u5757\u987a\u5e8f\u586b\u5165\u7684\u503c\u3002\u800c\u7b2c17\u81f364\u8f6e\u53d8\u6362\u65f6\uff0cWt\u7684\u751f\u6210\u516c\u5f0f\u4e3a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-5.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"687\" height=\"70\" src=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-5.jpg\" alt=\"\" class=\"wp-image-285\" srcset=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-5.jpg 687w, https:\/\/www.tiferking.cn\/wp-content\/uploads\/2018\/08\/sha256-src-5-300x31.jpg 300w\" sizes=\"auto, (max-width: 687px) 100vw, 687px\" \/><\/a><\/figure>\n\n\n\n<p>\u5f5364\u8f6e\u6df7\u5408\u505a\u5b8c\u4e86\u4e4b\u540e\uff0c\u5c06\u53d8\u6362\u7ed3\u679c\u4ee5\u6bcf32\u4f4d\u4e3a\u4e00\u5757\u4e0e\u53d8\u6362\u524d\u7684\u503c\u505a\u52a0\u6cd5\uff0c\u4fbf\u5f97\u5230\u4e86\u6700\u7ec8\u7684SHA-256\u6458\u8981\u503c\u3002\u5982\u679c\u533a\u5757\u4e0d\u6b62\u4e00\u5757\u7684\u8bdd\u5219\u5c06\u524d\u4e00\u5757\u7684\u6458\u8981\u503c\u4f5c\u4e3a\u4e0b\u4e00\u5757\u7684\u521d\u59cb\u503c\uff0c\u7ee7\u7eed\u8fdb\u884c64\u8f6e\u53d8\u6362\uff0c\u76f4\u5230\u8fed\u4ee3\u5230\u6700\u540e\u4e00\u5757\u533a\u5757\u53d8\u6362\u5b8c\u6210\u4e3a\u6b62\u3002<\/p>\n\n\n\n<p><strong>\u7b2c\u4e09\u6b65<\/strong>\uff1a\u5c06\u6700\u7ec8\u7684\u7ed3\u679c\u8fd4\u56de\u4fbf\u662f\u8be5\u8f93\u5165\u4fe1\u606f\u7684SHA-256\u54c8\u5e0c\u503c\u3002<\/p>\n\n\n\n<p><strong>SHA-256\u7b97\u6cd5\u5b9e\u73b0<\/strong><\/p>\n\n\n\n<p>\u641c\u7d22GitHub\u4fbf\u53ef\u5f97\u5230\u5f88\u591aSHA-256\u7684\u5b9e\u73b0\u4ee3\u7801\uff0c\u6bd4\u5982<a href=\"https:\/\/github.com\/openssl\/openssl\">Openssl<\/a>\u4e2d\u5c31\u5305\u542bSHA-256\u7684\u5b9e\u73b0\uff0c\u8fd8\u6709<a href=\"https:\/\/github.com\/weidai11\/cryptopp\">Crypto++<\/a>\uff0c<a href=\"https:\/\/github.com\/bitcoin\/bitcoin\">BitCoin<\/a>\u7b49\uff0c\u5176\u4e2d\u7684\u4ee3\u7801\u5747\u53ef\u501f\u9274\u3002<\/p>\n\n\n\n<p>\u5176\u4e2dOpenssl\u7684SHA-256\u7b97\u6cd5\u5b9e\u73b0\u53ef\u4ee5\u8bf4\u975e\u5e38\u7684\u6e05\u6670\u6613\u61c2\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">static void sha256_block_data_order(SHA256_CTX *ctx, const void *in,\n                                    size_t num)\n{\n    unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1, T2;\n    SHA_LONG X[16], l;\n    int i;\n    const unsigned char *data = in;\n\n    while (num--) {\n\n        a = ctx->h[0];\n        b = ctx->h[1];\n        c = ctx->h[2];\n        d = ctx->h[3];\n        e = ctx->h[4];\n        f = ctx->h[5];\n        g = ctx->h[6];\n        h = ctx->h[7];\n\n        for (i = 0; i &lt; 16; i++) {\n            (void)HOST_c2l(data, l);\n            T1 = X[i] = l;\n            T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i];\n            T2 = Sigma0(a) + Maj(a, b, c);\n            h = g;\n            g = f;\n            f = e;\n            e = d + T1;\n            d = c;\n            c = b;\n            b = a;\n            a = T1 + T2;\n        }\n\n        for (; i &lt; 64; i++) {\n            s0 = X[(i + 1) &amp; 0x0f];\n            s0 = sigma0(s0);\n            s1 = X[(i + 14) &amp; 0x0f];\n            s1 = sigma1(s1);\n\n            T1 = X[i &amp; 0xf] += s0 + s1 + X[(i + 9) &amp; 0xf];\n            T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i];\n            T2 = Sigma0(a) + Maj(a, b, c);\n            h = g;\n            g = f;\n            f = e;\n            e = d + T1;\n            d = c;\n            c = b;\n            b = a;\n            a = T1 + T2;\n        }\n\n        ctx->h[0] += a;\n        ctx->h[1] += b;\n        ctx->h[2] += c;\n        ctx->h[3] += d;\n        ctx->h[4] += e;\n        ctx->h[5] += f;\n        ctx->h[6] += g;\n        ctx->h[7] += h;\n\n    }\n}<\/pre>\n\n\n\n<p>Openssl\u8fd9\u91cc\u4ee3\u7801\u5199\u7684\u975e\u5e38\u89c4\u6574\uff0c\u5f53\u7136\u8fd9\u53ea\u662f\u4f5c\u4e3a\u539f\u7406\u793a\u8303\u4ee3\u7801\uff0c\u5176\u771f\u6b63\u4f7f\u7528\u7684\u4ee3\u7801\u662f\u7528\u6c47\u7f16\u8bed\u8a00\u7f16\u5199\u7684\u3002\u518d\u5217\u4e3e\u4e00\u4e2aBitCoin\u7684\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void Transform(uint32_t* s, const unsigned char* chunk, size_t blocks)\n{\n    while (blocks--) {\n        uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s[7];\n        uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;\n\n        Round(a, b, c, d, e, f, g, h, 0x428a2f98 + (w0 = ReadBE32(chunk + 0)));\n        Round(h, a, b, c, d, e, f, g, 0x71374491 + (w1 = ReadBE32(chunk + 4)));\n        Round(g, h, a, b, c, d, e, f, 0xb5c0fbcf + (w2 = ReadBE32(chunk + 8)));\n        Round(f, g, h, a, b, c, d, e, 0xe9b5dba5 + (w3 = ReadBE32(chunk + 12)));\n        Round(e, f, g, h, a, b, c, d, 0x3956c25b + (w4 = ReadBE32(chunk + 16)));\n        Round(d, e, f, g, h, a, b, c, 0x59f111f1 + (w5 = ReadBE32(chunk + 20)));\n        Round(c, d, e, f, g, h, a, b, 0x923f82a4 + (w6 = ReadBE32(chunk + 24)));\n        Round(b, c, d, e, f, g, h, a, 0xab1c5ed5 + (w7 = ReadBE32(chunk + 28)));\n        Round(a, b, c, d, e, f, g, h, 0xd807aa98 + (w8 = ReadBE32(chunk + 32)));\n        Round(h, a, b, c, d, e, f, g, 0x12835b01 + (w9 = ReadBE32(chunk + 36)));\n        Round(g, h, a, b, c, d, e, f, 0x243185be + (w10 = ReadBE32(chunk + 40)));\n        Round(f, g, h, a, b, c, d, e, 0x550c7dc3 + (w11 = ReadBE32(chunk + 44)));\n        Round(e, f, g, h, a, b, c, d, 0x72be5d74 + (w12 = ReadBE32(chunk + 48)));\n        Round(d, e, f, g, h, a, b, c, 0x80deb1fe + (w13 = ReadBE32(chunk + 52)));\n        Round(c, d, e, f, g, h, a, b, 0x9bdc06a7 + (w14 = ReadBE32(chunk + 56)));\n        Round(b, c, d, e, f, g, h, a, 0xc19bf174 + (w15 = ReadBE32(chunk + 60)));\n\n        Round(a, b, c, d, e, f, g, h, 0xe49b69c1 + (w0 += sigma1(w14) + w9 + sigma0(w1)));\n        Round(h, a, b, c, d, e, f, g, 0xefbe4786 + (w1 += sigma1(w15) + w10 + sigma0(w2)));\n        Round(g, h, a, b, c, d, e, f, 0x0fc19dc6 + (w2 += sigma1(w0) + w11 + sigma0(w3)));\n        Round(f, g, h, a, b, c, d, e, 0x240ca1cc + (w3 += sigma1(w1) + w12 + sigma0(w4)));\n        Round(e, f, g, h, a, b, c, d, 0x2de92c6f + (w4 += sigma1(w2) + w13 + sigma0(w5)));\n        Round(d, e, f, g, h, a, b, c, 0x4a7484aa + (w5 += sigma1(w3) + w14 + sigma0(w6)));\n        Round(c, d, e, f, g, h, a, b, 0x5cb0a9dc + (w6 += sigma1(w4) + w15 + sigma0(w7)));\n        Round(b, c, d, e, f, g, h, a, 0x76f988da + (w7 += sigma1(w5) + w0 + sigma0(w8)));\n        Round(a, b, c, d, e, f, g, h, 0x983e5152 + (w8 += sigma1(w6) + w1 + sigma0(w9)));\n        Round(h, a, b, c, d, e, f, g, 0xa831c66d + (w9 += sigma1(w7) + w2 + sigma0(w10)));\n        Round(g, h, a, b, c, d, e, f, 0xb00327c8 + (w10 += sigma1(w8) + w3 + sigma0(w11)));\n        Round(f, g, h, a, b, c, d, e, 0xbf597fc7 + (w11 += sigma1(w9) + w4 + sigma0(w12)));\n        Round(e, f, g, h, a, b, c, d, 0xc6e00bf3 + (w12 += sigma1(w10) + w5 + sigma0(w13)));\n        Round(d, e, f, g, h, a, b, c, 0xd5a79147 + (w13 += sigma1(w11) + w6 + sigma0(w14)));\n        Round(c, d, e, f, g, h, a, b, 0x06ca6351 + (w14 += sigma1(w12) + w7 + sigma0(w15)));\n        Round(b, c, d, e, f, g, h, a, 0x14292967 + (w15 += sigma1(w13) + w8 + sigma0(w0)));\n\n        Round(a, b, c, d, e, f, g, h, 0x27b70a85 + (w0 += sigma1(w14) + w9 + sigma0(w1)));\n        Round(h, a, b, c, d, e, f, g, 0x2e1b2138 + (w1 += sigma1(w15) + w10 + sigma0(w2)));\n        Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc + (w2 += sigma1(w0) + w11 + sigma0(w3)));\n        Round(f, g, h, a, b, c, d, e, 0x53380d13 + (w3 += sigma1(w1) + w12 + sigma0(w4)));\n        Round(e, f, g, h, a, b, c, d, 0x650a7354 + (w4 += sigma1(w2) + w13 + sigma0(w5)));\n        Round(d, e, f, g, h, a, b, c, 0x766a0abb + (w5 += sigma1(w3) + w14 + sigma0(w6)));\n        Round(c, d, e, f, g, h, a, b, 0x81c2c92e + (w6 += sigma1(w4) + w15 + sigma0(w7)));\n        Round(b, c, d, e, f, g, h, a, 0x92722c85 + (w7 += sigma1(w5) + w0 + sigma0(w8)));\n        Round(a, b, c, d, e, f, g, h, 0xa2bfe8a1 + (w8 += sigma1(w6) + w1 + sigma0(w9)));\n        Round(h, a, b, c, d, e, f, g, 0xa81a664b + (w9 += sigma1(w7) + w2 + sigma0(w10)));\n        Round(g, h, a, b, c, d, e, f, 0xc24b8b70 + (w10 += sigma1(w8) + w3 + sigma0(w11)));\n        Round(f, g, h, a, b, c, d, e, 0xc76c51a3 + (w11 += sigma1(w9) + w4 + sigma0(w12)));\n        Round(e, f, g, h, a, b, c, d, 0xd192e819 + (w12 += sigma1(w10) + w5 + sigma0(w13)));\n        Round(d, e, f, g, h, a, b, c, 0xd6990624 + (w13 += sigma1(w11) + w6 + sigma0(w14)));\n        Round(c, d, e, f, g, h, a, b, 0xf40e3585 + (w14 += sigma1(w12) + w7 + sigma0(w15)));\n        Round(b, c, d, e, f, g, h, a, 0x106aa070 + (w15 += sigma1(w13) + w8 + sigma0(w0)));\n\n        Round(a, b, c, d, e, f, g, h, 0x19a4c116 + (w0 += sigma1(w14) + w9 + sigma0(w1)));\n        Round(h, a, b, c, d, e, f, g, 0x1e376c08 + (w1 += sigma1(w15) + w10 + sigma0(w2)));\n        Round(g, h, a, b, c, d, e, f, 0x2748774c + (w2 += sigma1(w0) + w11 + sigma0(w3)));\n        Round(f, g, h, a, b, c, d, e, 0x34b0bcb5 + (w3 += sigma1(w1) + w12 + sigma0(w4)));\n        Round(e, f, g, h, a, b, c, d, 0x391c0cb3 + (w4 += sigma1(w2) + w13 + sigma0(w5)));\n        Round(d, e, f, g, h, a, b, c, 0x4ed8aa4a + (w5 += sigma1(w3) + w14 + sigma0(w6)));\n        Round(c, d, e, f, g, h, a, b, 0x5b9cca4f + (w6 += sigma1(w4) + w15 + sigma0(w7)));\n        Round(b, c, d, e, f, g, h, a, 0x682e6ff3 + (w7 += sigma1(w5) + w0 + sigma0(w8)));\n        Round(a, b, c, d, e, f, g, h, 0x748f82ee + (w8 += sigma1(w6) + w1 + sigma0(w9)));\n        Round(h, a, b, c, d, e, f, g, 0x78a5636f + (w9 += sigma1(w7) + w2 + sigma0(w10)));\n        Round(g, h, a, b, c, d, e, f, 0x84c87814 + (w10 += sigma1(w8) + w3 + sigma0(w11)));\n        Round(f, g, h, a, b, c, d, e, 0x8cc70208 + (w11 += sigma1(w9) + w4 + sigma0(w12)));\n        Round(e, f, g, h, a, b, c, d, 0x90befffa + (w12 += sigma1(w10) + w5 + sigma0(w13)));\n        Round(d, e, f, g, h, a, b, c, 0xa4506ceb + (w13 += sigma1(w11) + w6 + sigma0(w14)));\n        Round(c, d, e, f, g, h, a, b, 0xbef9a3f7 + (w14 + sigma1(w12) + w7 + sigma0(w15)));\n        Round(b, c, d, e, f, g, h, a, 0xc67178f2 + (w15 + sigma1(w13) + w8 + sigma0(w0)));\n\n        s[0] += a;\n        s[1] += b;\n        s[2] += c;\n        s[3] += d;\n        s[4] += e;\n        s[5] += f;\n        s[6] += g;\n        s[7] += h;\n        chunk += 64;\n    }\n}<\/pre>\n\n\n\n<p>\u76f4\u63a5\u5c06\u5faa\u73af\u5c55\u5f00\uff0c\u867d\u7136\u63d0\u9ad8\u4e86\u6027\u80fd\u4f46\u5374\u52a0\u5927\u4e86\u5b58\u50a8\u5f00\u9500(\u7136\u800cPC\u673a\u4e0d\u5728\u4e4e)\u3002(<del>\u679c\u7136\u4eba\u7c7b\u7684\u672c\u8d28\u662f\u590d\u8bfb\u673a<\/del>)<\/p>\n\n\n\n<p><strong>SHA-256\u5b9e\u73b0\u4f18\u5316<\/strong><\/p>\n\n\n\n<p>\u7531\u4e8e\u6211\u9700\u8981\u5728stm32f767zit\u8fd9\u5757\u82af\u7247\u4e0a\u8fd0\u884cSHA-256\uff0c\u5355\u7247\u673a\u4e0d\u4ec5\u9700\u8981\u66f4\u9ad8\u7684\u6548\u7387\uff0c\u8fd8\u9700\u8981\u8f83\u5c0f\u7684\u5f00\u9500\uff0c\u5305\u62ecRAM\u548cFlash\u4e24\u65b9\u9762\u7684\u5f00\u9500(<del>\u800c\u4e14\u4e0d\u60f3\u4e0a\u6c47\u7f16\u4e0d\u4ec5\u4e0d\u597d\u7ef4\u62a4\u800c\u4e14\u4e07\u4e00\u540e\u9762\u5c31\u4e0d\u7528\u4e86\u5c82\u4e0d\u662f\u767d\u8d39\u597d\u5927\u529f\u592b<\/del>)\u3002\u6240\u4ee5\u4e0a\u9762\u4e24\u79cd\u4ee3\u7801\u5747\u4e0d\u80fd\u76f4\u63a5\u4f7f\u7528\u3002(\u5b9e\u9645\u4e0a\u4e0a\u9762\u4e24\u4e2a\u7a0b\u5e8f\u4e5f\u5e76\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528C\u8bed\u8a00\u7f16\u5199\u7684\u4ee3\u7801\uff0c\u800c\u662f\u90fd\u6709\u5404\u81ea\u7684\u7528\u6c47\u7f16\u7f16\u5199\u7684\u9488\u5bf9\u6027\u4f18\u5316\u7a0b\u5e8f\uff0c\u751a\u81f3\u4f7f\u7528\u4e86SIMD)\u8fd9\u8ba9\u6211\u6df1\u523b\u7684\u7406\u89e3\u4e86\u8de8\u5e73\u53f0\u7684\u4e24\u79cd\u65b9\u6cd5\uff0c\u4e00\u79cd\u662f\u4f7f\u7528\u9ad8\u7ea7\u8bed\u8a00\uff0c\u53e6\u4e00\u79cd\u662f\u5c06\u6240\u6709\u5e38\u7528\u5e73\u53f0\u7684\u6c47\u7f16\u90fd\u5199\u4e00\u904d(<del>\u7b80\u79f0\u5927\u529b\u51fa\u5947\u8ff9<\/del>)\u3002<\/p>\n\n\n\n<p>\u4ed4\u7ec6\u89c2\u5bdf\u4e0a\u8fb9\u7684\u6df7\u5408\u7b97\u6cd5\u6846\u56fe\uff0c\u4e0d\u96be\u53d1\u73b0\uff0c\u5176\u5b9e\u6bcf\u8f6e\u4fbf\u6362\u66f4\u65b0\u7684\u503c\u53ea\u6709\u4e24\u5757\uff0c\u7b2c\u4e00\u5757\u662fH\u7684\u503c\uff0c\u65b0\u7684\u503c\u662f\u539f\u6765\u503c\u52a0\u4e0a\u6240\u6709\u7684\u90e8\u5206\u7ec4\u6210\u7684\uff0c\u7b2c\u4e8c\u5757\u662fD\u7684\u503c\uff0c\u5176\u65b0\u7684\u503c\u4ec5\u4ec5\u53ea\u662f\u52a0\u4e0aH\u5757\u8fd0\u7b97\u4e2d\u7684\u4e00\u4e2a\u4e2d\u95f4\u503c\u3002\u6240\u4ee5\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u8282\u7701\u4e2d\u95f4\u53d8\u91cf\uff0c\u5148\u7b97\u4e00\u90e8\u5206H\u7684\u503c\uff0c\u7136\u540e\u5c06H\u52a0\u5728D\u4e0a\uff0c\u518d\u7ee7\u7eed\u8fd0\u7b97\u5230\u7ed3\u675f\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8eWt\u524d16\u5757\u4e0e17\u81f364\u5757\u4e0d\u76f8\u540c\u9700\u8981\u8fed\u4ee3\u7684\u95ee\u9898\uff0c\u5b8c\u5168\u4e0d\u9700\u8981\u5f00\u8f9f\u4e00\u4e2a64\u5757\u7684\u5185\u5b58\u6216\u8005\u5355\u72ec\u6765\u8fdb\u884c\u8ba1\u7b97\uff0c\u901a\u8fc7\u89c2\u5bdf\u53d1\u73b0\uff0c\u6bcf\u4e00\u8f6e\u53d8\u6362\u5b8c\u5168\u7528\u4e0d\u523016\u5757\u4e4b\u524d\u7684Wt\u503c\uff0c\u4e5f\u5c31\u662f\u8bf4\u8d85\u8fc7\u5f53\u524d\u53d8\u6362\u8f6e\u657016\u5757\u7684\u503c\u4fbf\u53ef\u4ee5\u4e22\u5f03\uff0c\u5373\u5f53\u524d\u8ba1\u7b97\u7ed3\u675f\u540e\u7684Wt\u503c\u5728\u672a\u6765\u7684\u7b2c16\u6b21\u53d8\u6362\u4fbf\u4e0d\u518d\u9700\u8981\u4e86\u3002\u6240\u4ee5\u53ef\u4ee5\u5728\u5f53\u524d\u53d8\u6362\u5b8c\u4e86\u4e4b\u540e\u76f4\u63a5\u5bf9\u4e4b\u540e\u7684\u7b2c16\u6b21\u53d8\u6362\u6240\u9700\u8981\u7684\u503c\u8fdb\u884c\u8ba1\u7b97\uff0c\u5e76\u586b\u5728\u5f53\u524d\u503c\u7684\u4f4d\u7f6e\u4e0a\uff0c\u56e0\u4e3a\u5f53\u524d\u503c\u5df2\u7ecf\u4e0d\u518d\u9700\u8981\u4e86\u3002\u8fd9\u6837\u4e0d\u4ec5\u8282\u7701\u4e86Flash\u7684\u5f00\u9500\uff0c\u540c\u65f6\u4e5f\u8282\u7701\u4e86\u5185\u5b58\u7684\u5f00\u9500\uff0c\u540c\u65f6\u4e5f\u4e0d\u727a\u7272\u6027\u80fd\uff0c\u53ef\u8c13\u4e00\u4e3e\u4e24\u5f97\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u4fbf\u662f\u6839\u636e\u8fd9\u51e0\u70b9\u6784\u5efa\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u770b\u5230\u6574\u4e2a\u51fd\u6570\u53ea\u6709133\u5b57\u8282\u7684\u5185\u5b58\u5f00\u9500(64\u5b57\u8282\u5b58\u50a8Wt,32\u5b57\u8282\u5b58\u50a8\u521d\u59cbHash\u503c,32\u5b57\u8282\u5b58\u50a8\u53d8\u6362Hash\u503c,4\u5b57\u8282\u4f5c\u4e3a\u8f6e\u6362\u4e34\u65f6\u503c,1\u5b57\u8282\u4f5c\u4e3a\u5faa\u73af\u63a7\u5236\u53d8\u91cf)\uff0c\u5e76\u4e14\u77ed\u5c0f\u7cbe\u608d(<del>\u75af\u72c2\u81ea\u5439<\/del>)\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CRYPTO_STATUS sha_256_update(uint32_t* data)\n{\n\tuint8_t i;\n\tuint32_t tmp;\n\n\tmemcpy(SHA256_Data2, SHA256_Data1, 32);\n\tfor (i = 0; i &lt; 64; ++i)\n\t{\n\t\tSHA256_Data2[7] += sha256_ch(SHA256_Data2[4], SHA256_Data2[5], SHA256_Data2[6])\n\t\t\t+ sigma_h1(SHA256_Data2[4]) + SHA256_CalcTab[i] + data[i &amp; 0x0F];\n\t\tSHA256_Data2[3] += SHA256_Data2[7];\n\t\tSHA256_Data2[7] += sha256_maj(SHA256_Data2[0], SHA256_Data2[1], SHA256_Data2[2])\n\t\t\t+ sigma_h0(SHA256_Data2[0]);\n\n\t\ttmp = SHA256_Data2[7];\n\t\tSHA256_Data2[7] = SHA256_Data2[6];\n\t\tSHA256_Data2[6] = SHA256_Data2[5];\n\t\tSHA256_Data2[5] = SHA256_Data2[4];\n\t\tSHA256_Data2[4] = SHA256_Data2[3];\n\t\tSHA256_Data2[3] = SHA256_Data2[2];\n\t\tSHA256_Data2[2] = SHA256_Data2[1];\n\t\tSHA256_Data2[1] = SHA256_Data2[0];\n\t\tSHA256_Data2[0] = tmp;\n\n\t\tdata[i &amp; 0x0F] += sigma_l1(data[(i + 14) &amp; 0x0F]) + data[(i + 9) &amp; 0x0F] + sigma_l0(data[(i + 1) &amp; 0x0F]);\n\t}\n\tfor (i = 0; i &lt; 8; ++i)\n\t{\n\t\tSHA256_Data1[i] += SHA256_Data2[i];\n\t}\n\treturn CRYPTO_SUCCESS;\n}<\/pre>\n\n\n\n<p>\u5bf9\u4ee3\u7801\u8fdb\u884c\u6027\u80fd\u6d4b\u8bd5\u7ed3\u679c\u4e3a\uff1a<\/p>\n\n\n\n<p>===================<\/p>\n\n\n\n<p>\u5e73\u53f0\uff1aIntel Xeon E5-2699 v4 @ 2.2GHz<\/p>\n\n\n\n<p>\u7f16\u8bd1\u5668\uff1aMS VC++ v14.0 (\u4f18\u5316\u7b49\u7ea7:O2)<\/p>\n\n\n\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a129.6MByte\/s<\/p>\n\n\n\n<p>===================<\/p>\n\n\n\n<p>\u5e73\u53f0\uff1aSTM32F767ZIT @ 216MHz (\u5f00\u542f\u6307\u4ee4\u548c\u6570\u636e\u7f13\u5b58\uff0c\u6307\u4ee4\u9884\u53d6\u548cFlash\u9884\u53d6)<\/p>\n\n\n\n<p>\u7f16\u8bd1\u5668\uff1aArmcc v5.06 (\u4f18\u5316\u7b49\u7ea7:O3)<\/p>\n\n\n\n<p>\u6d4b\u8bd5\u7ed3\u679c\uff1a3.21MByte\/s<\/p>\n\n\n\n<p>===================<\/p>\n\n\n\n<p>\u603b\u7684\u6765\u8bf4\uff0c\u901f\u5ea6\u8fd8\u662f\u80fd\u8fbe\u5230\u4f7f\u7528\u8981\u6c42\u7684\u3002<\/p>\n\n\n\n<p><s>PS:\u6574\u4e2a\u5de5\u7a0b\u548c\u6e90\u6587\u4ef6\u5728\u540e\u7eed\u6574\u7406\u6ce8\u91ca\u540e\u4f1a\u4e0a\u4f20\u5230\u8fd9\u91cc\u3002(<del>\u5148\u5077\u4e2a\u61d2<\/del>)<\/s><\/p>\n\n\n\n<p>\u6e90\u6587\u4ef6\uff1a<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-b4dd4ddb-17e3-4ab7-918e-431b09685ae6\" href=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2024\/06\/sha256.zip\">sha256<\/a><a href=\"https:\/\/www.tiferking.cn\/wp-content\/uploads\/2024\/06\/sha256.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-b4dd4ddb-17e3-4ab7-918e-431b09685ae6\">\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<p>(\u5b8c)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u4e45\u6ca1\u6709\u53d1\u6587\u7ae0\u4e86\u554a\uff0c\u54b3\u54b3\uff0c\u6700\u8fd1\u8003\u8bd5\u8003\u7684\u4eba\u5fc3\u529b\u4ea4\u7601\u3002\u8fd9\u4e24\u5929\u7531\u4e8e\u9700\u8981(\u771f\u7684\u662f\u81ea\u5df2\u7684\u9700\u8981\u4e48\uff1f)\uff0c\u505a\u4e86\u505a\u6458\u8981\u7b97\u6cd5\u65b9\u9762\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":282,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-277","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-the-mystery"],"_links":{"self":[{"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/posts\/277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":7,"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":647,"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/posts\/277\/revisions\/647"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/media\/282"}],"wp:attachment":[{"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tiferking.cn\/index.php\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}