{"id":371892,"date":"2024-05-21T04:59:06","date_gmt":"2024-05-21T04:59:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=371892"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=371892","title":{"rendered":"<span>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 cryptopals. \u0427\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u0438\u044f <a href=\"https:\/\/cryptopals.com\/\" rel=\"noopener noreferrer nofollow\">cryptopals<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u043b\u043e\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 3 \u0438 4.<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/801805\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><br \/> \u0412\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c<br \/> <a href=\"https:\/\/habr.com\/ru\/articles\/804905\/\" rel=\"noopener noreferrer nofollow\">\u0422\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/p>\n<h2>\u0411\u043b\u043e\u043a 3: Block &amp; stream crypto<\/h2>\n<p><strong>\u0422\u0435\u043c\u044b:<\/strong>  \u0411\u043b\u043e\u0447\u043d\u044b\u0435 \u0448\u0438\u0444\u0440\u044b, \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b<br \/> <strong>\u0421\u0441\u044b\u043b\u043a\u0430:<\/strong>  <a href=\"https:\/\/cryptopals.com\/sets\/3\" rel=\"noopener noreferrer nofollow\">https:\/\/cryptopals.com\/sets\/3<\/a><\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 17: The CBC padding oracle<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 (\u043d\u043e \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439) \u0430\u0442\u0430\u043a\u043e\u0439 \u00abOracle Padding Attack\u00bb \u043d\u0430 \u0440\u0435\u0436\u0438\u043c CBC \u0431\u043b\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0438\u043c\u0435\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0440\u0430\u043a\u0443\u043b\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043f\u0438\u0448\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"python\">text = CBC.decrypt(ciphertext);  # \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 if (!is_padding_correct(text)) {  # \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f         Error('incorrect padding');     } return unpad(text);  # \u0441\u043d\u044f\u0442\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <\/code><\/pre>\n<p>\u041d\u043e \u0442\u0430\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u0430 \u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p><strong>\u0418\u0434\u0435\u044f \u0430\u0442\u0430\u043a\u0438<\/strong><br \/> \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CBC \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443:<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"P_i = C_{i - 1} \\oplus D_k(C_i)\" alt=\"P_i = C_{i - 1} \\oplus D_k(C_i)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/78\/788\/78858fe1bd44ca1f761341d1b4236c41.svg\" width=\"auto\" height=\"auto\"\/><\/p>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c <img decoding=\"async\" class=\"formula inline\" source=\"I_i = D_k(C_i)\" alt=\"I_i = D_k(C_i)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5\/5d\/5db\/5db7caf4c36231306d57988a6daf4019.svg\" width=\"auto\" height=\"auto\"\/>, \u0442\u043e\u0433\u0434\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"P_i = C_{i - 1} \\oplus I_i\" alt=\"P_i = C_{i - 1} \\oplus I_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/de\/de9\/de9b008a7f5305fdd402a975c0dd2e94.svg\" width=\"auto\" height=\"auto\"\/><br \/> \u0415\u0441\u043b\u0438  <img decoding=\"async\" class=\"formula inline\" source=\"I_i\" alt=\"I_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/ff\/ff3\/ff3e5d497ea81bedd8ea917f06223313.svg\" width=\"auto\" height=\"auto\"\/> \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <img decoding=\"async\" class=\"formula inline\" source=\"C_{i - 1}\" alt=\"C_{i - 1}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/f6\/f6b\/f6bf5d5d5a9df86bfea93580099dd3d6.svg\" width=\"auto\" height=\"auto\"\/> \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e). \u0410 \u0443\u0437\u043d\u0430\u0442\u044c <img decoding=\"async\" class=\"formula inline\" source=\"I_i\" alt=\"I_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/ff\/ff3\/ff3e5d497ea81bedd8ea917f06223313.svg\" width=\"auto\" height=\"auto\"\/> \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0440\u0430\u043a\u0443\u043b\u0430.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a <img decoding=\"async\" class=\"formula inline\" source=\"C\" alt=\"C\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/0d\/0d6\/0d61f8370cad1d412f80b84d143e1257.svg\" width=\"auto\" height=\"auto\"\/>  \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0430. \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430.<br \/> \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0431\u043b\u043e\u043a <img decoding=\"async\" class=\"formula inline\" source=\"B\" alt=\"B\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/9d\/9d5\/9d5ed678fe57bcca610140957afab571.svg\" width=\"auto\" height=\"auto\"\/> \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u044b <img decoding=\"async\" class=\"formula inline\" source=\"B[0],...,B[14]\" alt=\"B[0],...,B[14]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/fd\/fdd\/fdd531bb4bc563bb8b51b919ec9f12f3.svg\" width=\"auto\" height=\"auto\"\/> \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u0430\u0439\u0442 \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"B || C\" alt=\"B || C\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/1\/15\/15a\/15a8f40ffedacdd0e012f7b51db5058b.svg\" width=\"auto\" height=\"auto\"\/>  \u043e\u0440\u0430\u043a\u0443\u043b\u0443.<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0440\u0430\u043a\u0443\u043b \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u00ab\u041d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u00bb, \u0442\u043e \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0431\u0430\u0439\u0442<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0440\u0430\u043a\u0443\u043b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0442\u0432\u0435\u0442, \u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 (\u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e)  <img decoding=\"async\" class=\"formula inline\" source=\"P[15] = 0x01\" alt=\"P[15] = 0x01\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6\/69\/69c\/69c6b6ccc1c76837cb337ec2a9b61bef.svg\" width=\"auto\" height=\"auto\"\/><\/p>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"formula inline\" source=\"P[15] = B[15] \\oplus I[15]\" alt=\"P[15] = B[15] \\oplus I[15]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/26\/263\/263ebb5b75a8e9462aac40577e2edc92.svg\" width=\"auto\" height=\"auto\"\/>,\u0442\u043e\u0433\u0434\u0430<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"I[15] = B[15] \\oplus P[15] = B[15] \\oplus 0x01\" alt=\"I[15] = B[15] \\oplus P[15] = B[15] \\oplus 0x01\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/91\/914\/914055d27393ff1a67b4890b6c7f7c61.svg\" width=\"auto\" height=\"auto\"\/><br \/> \u0442. \u0435. \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <img decoding=\"async\" class=\"formula inline\" source=\"I[15]\" alt=\"I[15]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d6\/d67\/d671367b7c1947d614b2703cdc802feb.svg\" width=\"auto\" height=\"auto\"\/>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0439\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0432\u0443\u0445 \u0431\u0430\u0439\u0442\u043e\u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 <img decoding=\"async\" class=\"formula inline\" source=\"0x02, 0x02\" alt=\"0x02, 0x02\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/98\/98c\/98c23c50aeded903410ed80e6cbe79a8.svg\" width=\"auto\" height=\"auto\"\/>.<br \/> \u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <img decoding=\"async\" class=\"formula inline\" source=\"I[14]\" alt=\"I[14]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/30\/306\/306a47dd0d7769bab191d5741df5eca3.svg\" width=\"auto\" height=\"auto\"\/> \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0431\u043b\u043e\u043a <img decoding=\"async\" class=\"formula inline\" source=\"B\" alt=\"B\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/9d\/9d5\/9d5ed678fe57bcca610140957afab571.svg\" width=\"auto\" height=\"auto\"\/>:<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"B[0],...,B[13]\" alt=\"B[0],...,B[13]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a5\/a52\/a5244d90ab3e43401f858a8e80fa0ca7.svg\" width=\"auto\" height=\"auto\"\/> \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"B[15] = I[15] \\oplus 0x02\" alt=\"B[15] = I[15] \\oplus 0x02\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/2e\/2ee\/2ee476d984f36075393c2c3c9e70ac54.svg\" width=\"auto\" height=\"auto\"\/><br \/> \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c <img decoding=\"async\" class=\"formula inline\" source=\"B[14]\" alt=\"B[14]\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/9c\/9c6\/9c69a8b5735086d961bf634fdf127950.svg\" width=\"auto\" height=\"auto\"\/> \u0438 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 \u043e\u0440\u0430\u043a\u0443\u043b\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"B||C\" alt=\"B||C\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/22\/22a\/22a50479b5adeaf25def9c6af73c5bf9.svg\" width=\"auto\" height=\"auto\"\/>. \u041a\u043e\u0433\u0434\u0430 \u043e\u0440\u0430\u043a\u0443\u043b \u043d\u0435 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c <img decoding=\"async\" class=\"formula inline\" source=\"I[14] = B[14] \\oplus 0x02\" alt=\"I[14] = B[14] \\oplus 0x02\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ec\/ec3\/ec3c4e4cf889cec84b09e179facd569b.svg\" width=\"auto\" height=\"auto\"\/><\/p>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 18: Implement CTR, the stream cipher mode<\/h3>\n<p>\u0412 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f CTR. \u042d\u0442\u043e\u0442 \u0440\u0435\u0436\u0438\u043c \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u043b\u043e\u0447\u043d\u044b\u0439 \u0448\u0438\u0444\u0440 \u0432 \u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439.<\/p>\n<p>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CTR \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0443:<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"C_i = P_i \\oplus E_k(counter_i)\" alt=\"C_i = P_i \\oplus E_k(counter_i)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/39\/39c\/39c005fd100071fade844ea4a68f7417.svg\" width=\"auto\" height=\"auto\"\/>, \u0433\u0434\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"counter_i\" alt=\"counter_i\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/4\/41\/410\/41041826f83461455e1e7a330005ad58.svg\" width=\"auto\" height=\"auto\"\/> \u2014 \u0441\u0447\u0451\u0442\u0447\u0438\u043a<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 19-20: Break fixed-nonce CTR<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u043a\u043b\u044e\u0447\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CTR. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0417\u0430\u0434\u0430\u043d\u0438\u044e 6.<br \/> \u0412 \u0417\u0430\u0434\u0430\u043d\u0438\u0438 19 \u043d\u0443\u0436\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0440\u0443\u0447\u043d\u044b\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u0441\u043a\u0443\u0447\u043d\u043e, \u0438 \u043d\u0435 \u0432 \u0434\u0443\u0445\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u043d\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443 19 \u0438 20 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 21: Implement the MT19937 Mersenne Twister RNG<\/h3>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c  \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%92%D0%B8%D1%85%D1%80%D1%8C_%D0%9C%D0%B5%D1%80%D1%81%D0%B5%D0%BD%D0%BD%D0%B0\" rel=\"noopener noreferrer nofollow\">\u0412\u0438\u0445\u0440\u044c \u041c\u0435\u0440\u0441\u0435\u043d\u043d\u0430<\/a>.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 22: Crack an MT19937 seed<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0413\u041f\u0421\u0427 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0440\u0443\u0434\u043d\u043e\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u2014 \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u044b\u0431\u043e\u0440. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 23: Clone an MT19937 RNG from its output<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0413\u041f\u0421\u0427 \u0412\u0438\u0445\u0440\u044c \u041c\u0435\u0440\u0441\u0435\u043d\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0435\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u043e\u0432.<br \/> \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432 \u0417\u0430\u0434\u0430\u043d\u0438\u0438 21. \u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0412\u0438\u0445\u0440\u044c \u041c\u0435\u0440\u0441\u0435\u043d\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u043e\u0439\u043a\u0438\u043c: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 624 \u0447\u0438\u0441\u0435\u043b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 24: Create the MT19937 stream cipher and break it<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0448\u0438\u0444\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0412\u0438\u0445\u0440\u044f \u041c\u0435\u0440\u0441\u0435\u043d\u0430 \u0438 \u0432\u0437\u043b\u043e\u043c\u0430\u0442\u044c \u0435\u0433\u043e.<br \/> \u041a\u043b\u044e\u0447\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0413\u041f\u0421\u0427. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435, \u0432\u0441\u0435\u0433\u043e 16 \u0431\u0438\u0442, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u043e\u043c.<\/p>\n<h2>\u0411\u043b\u043e\u043a 4: Stream crypto and randomness<\/h2>\n<p><strong>\u0422\u0435\u043c\u044b:<\/strong>  MAC, \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438<br \/> <strong>\u0421\u0441\u044b\u043b\u043a\u0430:<\/strong>  <a href=\"https:\/\/cryptopals.com\/sets\/4\" rel=\"noopener noreferrer nofollow\">https:\/\/cryptopals.com\/sets\/4<\/a><\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 25: Break &#171;random access read\/write&#187; AES CTR<\/h3>\n<p>\u041f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0434\u0430\u043d \u043e\u0440\u0430\u043a\u0443\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0435\u043a\u0441\u0442, \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CTR:<\/p>\n<pre><code class=\"python\">edit(ciphertext, key, offset, newtext) <\/code><\/pre>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>edit<\/code> \u0442\u0435\u043a\u0441\u0442 <code>newtext<\/code>, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438 \u0440\u0430\u0432\u043d\u044b\u0439 \u043f\u043e \u0434\u043b\u0438\u043d\u0435 \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0443. \u0422\u0430\u043a \u043a\u0430\u043a \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0434\u0451\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CTR, \u0432 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0433\u0430\u043c\u043c\u0443 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 26: CTR bitflipping<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u0440\u0435\u0436\u0438\u043c\u043e\u043c CRT \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0431\u0438\u0442\u0430 \u0432 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 CBC (\u0417\u0430\u0434\u0430\u043d\u0438\u0435 16). \u0412 \u0440\u0435\u0436\u0438\u043c\u0435 CTR \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0438\u0442 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"P = C \\oplus K\" alt=\"P = C \\oplus K\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/f7\/f7d\/f7d4dec8b78b20c2e05afd1b858bce80.svg\" width=\"auto\" height=\"auto\"\/><br \/> \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0442 \u0432 \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0435, \u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 27: Recover the key from CBC with IV=Key<\/h3>\n<p>\u0412 \u0440\u0435\u0436\u0438\u043c\u0435 CBC \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f: \u043a\u043b\u044e\u0447 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 <img decoding=\"async\" class=\"formula inline\" source=\"IV\" alt=\"IV\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c\/cf\/cf4\/cf482c5807b62034beeabdb795c5a689.svg\" width=\"auto\" height=\"auto\"\/>. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"IV\" alt=\"IV\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c\/cf\/cf4\/cf482c5807b62034beeabdb795c5a689.svg\" width=\"auto\" height=\"auto\"\/> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u0438\u043c \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0433\u0430\u044e\u0442 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u043b\u044e\u0447 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"IV\" alt=\"IV\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c\/cf\/cf4\/cf482c5807b62034beeabdb795c5a689.svg\" width=\"auto\" height=\"auto\"\/>. \u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c <img decoding=\"async\" class=\"formula inline\" source=\"IV=K\" alt=\"IV=K\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8\/89\/891\/8913933d96c28f819fbf0d0242a2989f.svg\" width=\"auto\" height=\"auto\"\/>. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442 \u0438\u0437 \u0442\u0440\u0451\u0445 \u0431\u043b\u043e\u043a\u043e\u0432: \u043f\u0435\u0440\u0432\u044b\u0439 \u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u043d\u0443\u043b\u0435\u0439. <img decoding=\"async\" class=\"formula inline\" source=\"C || 0 || C\" alt=\"C || 0 || C\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/0a\/0ac\/0ac4fc00c6922f89d41f24375be6024c.svg\" width=\"auto\" height=\"auto\"\/>. \u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CBC \u0438\u043c\u0435\u0435\u043c:<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"P_1 = IV \\oplus D_k(C) = K \\oplus D_k(C)\" alt=\"P_1 = IV \\oplus D_k(C) = K \\oplus D_k(C)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8\/8f\/8f4\/8f4d04d6594166a80a4d2ccc82c260a1.svg\" width=\"auto\" height=\"auto\"\/><br \/> <img decoding=\"async\" class=\"formula inline\" source=\"P_2 =  C \\oplus D_k(0)\" alt=\"P_2 =  C \\oplus D_k(0)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/fe\/fe5\/fe5eb72375bd98c54a090de875f5a1a8.svg\" width=\"auto\" height=\"auto\"\/><br \/> <img decoding=\"async\" class=\"formula inline\" source=\"P_3 = D_k(C)\" alt=\"P_3 = D_k(C)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/90\/906\/9067936a8bd7f548108e096ce0f4ac01.svg\" width=\"auto\" height=\"auto\"\/><br \/> \u0422\u043e\u0433\u0434\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"P_1 \\oplus  P_3 = K\" alt=\"P_1 \\oplus  P_3 = K\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d0\/d09\/d090059fa03f3e48c538a49012f1943b.svg\" width=\"auto\" height=\"auto\"\/> \u2014 \u043a\u043b\u044e\u0447 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0439\u0434\u0435\u043d.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 28: Implement a SHA-1 keyed MAC<\/h3>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435. \u041d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 MAC:<\/p>\n<pre><code class=\"python\">MAC = SHA1(key || message) <\/code><\/pre>\n<p>\u0425\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>SHA-1<\/code> \u0441\u0442\u043e\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f, \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u0434\u0430\u043d\u0438\u044f\u0445.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 29-30: Break a SHA-1 keyed MAC using length extension<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0445\u0435\u043c\u044b MAC:<\/p>\n<pre><code class=\"python\">MAC = SHA1(key || message) <\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 SHA-1:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u043e\u043a\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0441\u0436\u0430\u0442\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"h_i = H(m_i, h_{i-1}), h_0 = const\" alt=\"h_i = H(m_i, h_{i-1}), h_0 = const\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a4\/a40\/a406d28c98a32f4d9dae5a7a7bd3226c.svg\" width=\"auto\" height=\"auto\"\/><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"h\" alt=\"h\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/25\/251\/2510c39011c5be704182423e3a695e91.svg\" width=\"auto\" height=\"auto\"\/> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u0435\u0448\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c <img decoding=\"async\" class=\"formula inline\" source=\"h\" alt=\"h\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/25\/251\/2510c39011c5be704182423e3a695e91.svg\" width=\"auto\" height=\"auto\"\/> \u2014 \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0436\u0430\u0442\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0445\u0435\u0448 <img decoding=\"async\" class=\"formula inline\" source=\"h\" alt=\"h\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/25\/251\/2510c39011c5be704182423e3a695e91.svg\" width=\"auto\" height=\"auto\"\/> \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0445\u0435\u0448 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0436\u0430\u0442\u0438\u044f \u043d\u0435 \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"h_0\" alt=\"h_0\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/91\/919\/91923b083a33516b2ae173d6a93c2573.svg\" width=\"auto\" height=\"auto\"\/>, \u0430 \u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"h\" alt=\"h\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/25\/251\/2510c39011c5be704182423e3a695e91.svg\" width=\"auto\" height=\"auto\"\/>.<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u0430\u0451\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 \u043e\u0440\u0430\u043a\u0443\u043b\u0443 <code>original-message<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u043e\u0442\u0432\u0435\u0442 <code>h = SHA1(key || original-message || padding)<\/code><\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e SHA1 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <code>key || original-message || padding || new-message || padding<\/code> \u043d\u043e \u043d\u0435 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"h_0\" alt=\"h_0\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9\/91\/919\/91923b083a33516b2ae173d6a93c2573.svg\" width=\"auto\" height=\"auto\"\/>, \u0430 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"h\" alt=\"h\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/25\/251\/2510c39011c5be704182423e3a695e91.svg\" width=\"auto\" height=\"auto\"\/><\/p>\n<\/li>\n<li>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0435\u0440\u043d\u043e\u0435 \u0445\u0435\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <code>key || original-message || padding || new-message<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 30 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e SHA1 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f MD4.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 31-32: Implement and break HMAC-SHA1 with an artificial timing leak<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442 \u0441 \u043f\u043e\u043d\u044f\u0442\u0438\u0435\u043c timing-\u0430\u0442\u0430\u043a \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/HMAC\" rel=\"noopener noreferrer nofollow\">HMAC<\/a>.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u043f\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u043e, \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u0442\u0435\u043c \u0434\u043e\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 HMAC.<\/p>\n<p><strong>\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0430 python:<\/strong> <a href=\"https:\/\/github.com\/seregablog\/cryptopals\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/seregablog\/cryptopals<\/a><\/p>\n<hr\/>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u0443 \u043c\u0435\u043d\u044f \u0432 <a href=\"https:\/\/t.me\/+LQI0gTuGj5M0YTky\" rel=\"noopener noreferrer nofollow\">\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0435<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/803077\/\"> https:\/\/habr.com\/ru\/articles\/803077\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u0438\u044f <a href=\"https:\/\/cryptopals.com\/\" rel=\"noopener noreferrer nofollow\">cryptopals<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u043b\u043e\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0439 3 \u0438 4.<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/801805\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a><br \/> \u0412\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c<br \/> <a href=\"https:\/\/habr.com\/ru\/articles\/804905\/\" rel=\"noopener noreferrer nofollow\">\u0422\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c<\/a><\/p>\n<h2>\u0411\u043b\u043e\u043a 3: Block &amp; stream crypto<\/h2>\n<p><strong>\u0422\u0435\u043c\u044b:<\/strong>  \u0411\u043b\u043e\u0447\u043d\u044b\u0435 \u0448\u0438\u0444\u0440\u044b, \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b<br \/> <strong>\u0421\u0441\u044b\u043b\u043a\u0430:<\/strong>  <a href=\"https:\/\/cryptopals.com\/sets\/3\" rel=\"noopener noreferrer nofollow\">https:\/\/cryptopals.com\/sets\/3<\/a><\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 17: The CBC padding oracle<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 (\u043d\u043e \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439) \u0430\u0442\u0430\u043a\u043e\u0439 \u00abOracle Padding Attack\u00bb \u043d\u0430 \u0440\u0435\u0436\u0438\u043c CBC \u0431\u043b\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430. \u041e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0438\u043c\u0435\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0440\u0430\u043a\u0443\u043b\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043f\u0438\u0448\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442, \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"python\">text = CBC.decrypt(ciphertext);  # \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 if (!is_padding_correct(text)) {  # \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f         Error('incorrect padding');     } return unpad(text);  # \u0441\u043d\u044f\u0442\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <\/code><\/pre>\n<p>\u041d\u043e \u0442\u0430\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u0430 \u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p><strong>\u0418\u0434\u0435\u044f \u0430\u0442\u0430\u043a\u0438<\/strong><br \/> \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CBC \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443: <\/p>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c , \u0442\u043e\u0433\u0434\u0430 <br \/> \u0415\u0441\u043b\u0438   \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0442\u043e \u043b\u0435\u0433\u043a\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443  \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e). \u0410 \u0443\u0437\u043d\u0430\u0442\u044c  \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0440\u0430\u043a\u0443\u043b\u0430.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a   \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0430. \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u043e, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430.<br \/> \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0431\u043b\u043e\u043a  \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0430\u0439\u0442\u044b  \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u0430\u0439\u0442 \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435   \u043e\u0440\u0430\u043a\u0443\u043b\u0443.<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0440\u0430\u043a\u0443\u043b \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u00ab\u041d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u00bb, \u0442\u043e \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0431\u0430\u0439\u0442<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0440\u0430\u043a\u0443\u043b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0442\u0432\u0435\u0442, \u0442\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 (\u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e)  <\/p>\n<\/li>\n<\/ul>\n<p>,\u0442\u043e\u0433\u0434\u0430<\/p>\n<p> \u0442. \u0435. \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c , \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0439\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0432\u0443\u0445 \u0431\u0430\u0439\u0442\u043e\u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 .<br \/> \u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c  \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0431\u043b\u043e\u043a :<br \/>  \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/p>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c  \u0438 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 \u043e\u0440\u0430\u043a\u0443\u043b\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0430 . \u041a\u043e\u0433\u0434\u0430 \u043e\u0440\u0430\u043a\u0443\u043b \u043d\u0435 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c <\/p>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 18: Implement CTR, the stream cipher mode<\/h3>\n<p>\u0412 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0436\u0438\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f CTR. \u042d\u0442\u043e\u0442 \u0440\u0435\u0436\u0438\u043c \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u043b\u043e\u0447\u043d\u044b\u0439 \u0448\u0438\u0444\u0440 \u0432 \u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439.<\/p>\n<p>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CTR \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0443:<br \/> , \u0433\u0434\u0435  \u2014 \u0441\u0447\u0451\u0442\u0447\u0438\u043a<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 19-20: Break fixed-nonce CTR<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u043a\u043b\u044e\u0447\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CTR. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0417\u0430\u0434\u0430\u043d\u0438\u044e 6.<br \/> \u0412 \u0417\u0430\u0434\u0430\u043d\u0438\u0438 19 \u043d\u0443\u0436\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0440\u0443\u0447\u043d\u044b\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u0441\u043a\u0443\u0447\u043d\u043e, \u0438 \u043d\u0435 \u0432 \u0434\u0443\u0445\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u043d\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443 19 \u0438 20 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 21: Implement the MT19937 Mersenne Twister RNG<\/h3>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c  \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%92%D0%B8%D1%85%D1%80%D1%8C_%D0%9C%D0%B5%D1%80%D1%81%D0%B5%D0%BD%D0%BD%D0%B0\" rel=\"noopener noreferrer nofollow\">\u0412\u0438\u0445\u0440\u044c \u041c\u0435\u0440\u0441\u0435\u043d\u043d\u0430<\/a>.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 22: Crack an MT19937 seed<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0413\u041f\u0421\u0427 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0442\u0440\u0443\u0434\u043d\u043e\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u2014 \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u044b\u0431\u043e\u0440. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 23: Clone an MT19937 RNG from its output<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0413\u041f\u0421\u0427 \u0412\u0438\u0445\u0440\u044c \u041c\u0435\u0440\u0441\u0435\u043d\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0435\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u043e\u0432.<br \/> \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432 \u0417\u0430\u0434\u0430\u043d\u0438\u0438 21. \u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0412\u0438\u0445\u0440\u044c \u041c\u0435\u0440\u0441\u0435\u043d\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0442\u043e\u0439\u043a\u0438\u043c: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u0437 624 \u0447\u0438\u0441\u0435\u043b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 24: Create the MT19937 stream cipher and break it<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0448\u0438\u0444\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0412\u0438\u0445\u0440\u044f \u041c\u0435\u0440\u0441\u0435\u043d\u0430 \u0438 \u0432\u0437\u043b\u043e\u043c\u0430\u0442\u044c \u0435\u0433\u043e.<br \/> \u041a\u043b\u044e\u0447\u043e\u043c \u0442\u0430\u043a\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0413\u041f\u0421\u0427. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435, \u0432\u0441\u0435\u0433\u043e 16 \u0431\u0438\u0442, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u043e\u043c.<\/p>\n<h2>\u0411\u043b\u043e\u043a 4: Stream crypto and randomness<\/h2>\n<p><strong>\u0422\u0435\u043c\u044b:<\/strong>  MAC, \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438<br \/> <strong>\u0421\u0441\u044b\u043b\u043a\u0430:<\/strong>  <a href=\"https:\/\/cryptopals.com\/sets\/4\" rel=\"noopener noreferrer nofollow\">https:\/\/cryptopals.com\/sets\/4<\/a><\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 25: Break &#171;random access read\/write&#187; AES CTR<\/h3>\n<p>\u041f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0434\u0430\u043d \u043e\u0440\u0430\u043a\u0443\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0435\u043a\u0441\u0442, \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CTR:<\/p>\n<pre><code class=\"python\">edit(ciphertext, key, offset, newtext) <\/code><\/pre>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>edit<\/code> \u0442\u0435\u043a\u0441\u0442 <code>newtext<\/code>, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438 \u0440\u0430\u0432\u043d\u044b\u0439 \u043f\u043e \u0434\u043b\u0438\u043d\u0435 \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0443. \u0422\u0430\u043a \u043a\u0430\u043a \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0434\u0451\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CTR, \u0432 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0433\u0430\u043c\u043c\u0443 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 26: CTR bitflipping<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u0440\u0435\u0436\u0438\u043c\u043e\u043c CRT \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0431\u0438\u0442\u0430 \u0432 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 CBC (\u0417\u0430\u0434\u0430\u043d\u0438\u0435 16). \u0412 \u0440\u0435\u0436\u0438\u043c\u0435 CTR \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0438\u0442 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435<\/p>\n<p> \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0442 \u0432 \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0435, \u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0432 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 27: Recover the key from CBC with IV=Key<\/h3>\n<p>\u0412 \u0440\u0435\u0436\u0438\u043c\u0435 CBC \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f: \u043a\u043b\u044e\u0447 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 . \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435  \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u0438\u043c \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0433\u0430\u044e\u0442 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043a\u043b\u044e\u0447 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 . \u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f.<\/p>\n<p>\u041f\u0443\u0441\u0442\u044c . \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442 \u0438\u0437 \u0442\u0440\u0451\u0445 \u0431\u043b\u043e\u043a\u043e\u0432: \u043f\u0435\u0440\u0432\u044b\u0439 \u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437 \u043d\u0443\u043b\u0435\u0439. . \u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 CBC \u0438\u043c\u0435\u0435\u043c:<\/p>\n<p> \u0422\u043e\u0433\u0434\u0430  \u2014 \u043a\u043b\u044e\u0447 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0439\u0434\u0435\u043d.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 28: Implement a SHA-1 keyed MAC<\/h3>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435. \u041d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443 MAC:<\/p>\n<pre><code class=\"python\">MAC = SHA1(key || message) <\/code><\/pre>\n<p>\u0425\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>SHA-1<\/code> \u0441\u0442\u043e\u0438\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043d\u0443\u043b\u044f, \u044d\u0442\u043e \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u0434\u0430\u043d\u0438\u044f\u0445.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 29-30: Break a SHA-1 keyed MAC using length extension<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0445\u0435\u043c\u044b MAC:<\/p>\n<pre><code class=\"python\">MAC = SHA1(key || message) <\/code><\/pre>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 SHA-1:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u043e\u043a\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0441\u0436\u0430\u0442\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435  \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u0435\u0448\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c  \u2014 \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0436\u0430\u0442\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0445\u0435\u0448  \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0445\u0435\u0448 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0436\u0430\u0442\u0438\u044f \u043d\u0435 \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f , \u0430 \u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f .<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u0430\u0451\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 \u043e\u0440\u0430\u043a\u0443\u043b\u0443 <code>original-message<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u043e\u0442\u0432\u0435\u0442 <code>h = SHA1(key || original-message || padding)<\/code><\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e SHA1 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <code>key || original-message || padding || new-message || padding<\/code> \u043d\u043e \u043d\u0435 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f , \u0430 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0435\u0440\u043d\u043e\u0435 \u0445\u0435\u0448-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f <code>key || original-message || padding || new-message<\/code><\/p>\n<\/li>\n<\/ol>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 30 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e SHA1 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f MD4.<\/p>\n<h3>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 31-32: Implement and break HMAC-SHA1 with an artificial timing leak<\/h3>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442 \u0441 \u043f\u043e\u043d\u044f\u0442\u0438\u0435\u043c timing-\u0430\u0442\u0430\u043a \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/HMAC\" rel=\"noopener noreferrer nofollow\">HMAC<\/a>.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u043f\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u043e, \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u0442\u0435\u043c \u0434\u043e\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 HMAC.<\/p>\n<p><strong>\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0430 python:<\/strong> <a href=\"https:\/\/github.com\/seregablog\/cryptopals\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/seregablog\/cryptopals<\/a><\/p>\n<hr\/>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u0443 \u043c\u0435\u043d\u044f \u0432 <a href=\"https:\/\/t.me\/+LQI0gTuGj5M0YTky\" rel=\"noopener noreferrer nofollow\">\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0435<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/803077\/\"> https:\/\/habr.com\/ru\/articles\/803077\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-371892","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/371892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=371892"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/371892\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=371892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=371892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=371892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}