{"id":457209,"date":"2025-04-24T09:01:09","date_gmt":"2025-04-24T09:01:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=457209"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2025-04-24T09:01:09","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=457209","title":{"rendered":"<span>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0413\u041e\u0421\u0422 32.12. \u0421\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0439 \u0448\u0438\u0444\u0440 \u041a\u0443\u0437\u043d\u0435\u0447\u0438\u043a<\/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>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>\u0412\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0440\u0430\u0437\u0431\u043e\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430 \u00ab\u043a\u0443\u0437\u043d\u0435\u0447\u0438\u043a\u00bb. \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c.<\/p>\n<p>\u0412\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u00a0C.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0411\u043b\u043e\u043a\u00a0\u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437 16\u0442\u0438 \u0431\u0430\u0439\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0430\u0441\u0442\u0435\u0440\u043a\u043b\u044e\u0447\u00a0\u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u044e\u0447 \u0434\u043b\u044f\u00a0\u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f(\u0434\u043b\u0438\u043d\u0430 32\u0431\u0430\u0439\u0442\u0430). \u0418\u0437\u00a0\u043d\u0435\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0435 \u043a\u043b\u044e\u0447. \u0421\u0430\u043c \u043a\u043b\u044e\u0447 \u0432\u00a0\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043d\u0435\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0439 \u043a\u043b\u044e\u0447\u00a0\u2014 \u043a\u043b\u044e\u0447, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0438\u0437\u00a0\u043c\u0430\u0441\u0442\u0435\u0440 \u043a\u043b\u044e\u0447\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435(\u043f\u0440\u044f\u043c\u043e\u0435)\u00a0\u2014 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438(\u0431\u043b\u043e\u043a\u043e\u043c). \u0423\u0441\u043b\u043e\u0432\u043d\u043e: \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\/\u0438\u043b\u0438 \u0438\u0445 \u0444\u043e\u0440\u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0437\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0410\u00a0\u0432\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0411.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0\u2014 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438(\u0431\u043b\u043e\u043a\u043e\u043c). \u0423\u0441\u043b\u043e\u0432\u043d\u043e: \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\/\u0438\u043b\u0438 \u0438\u0445 \u0444\u043e\u0440\u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0437\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0411 \u0432\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0410. \u041e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u044f\u043c\u043e\u043c\u0443 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u00a0\u2014 \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f\u00a0\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442\u00a0\u0436\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447.<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u043e\u0447\u043d\u044b\u0439 \u0448\u0438\u0444\u0440\u00a0\u2014 \u044d\u0442\u043e \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0439 \u0431\u043b\u043e\u043a \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0432\u00a0\u0431\u043b\u043e\u043a \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0442\u043e\u0439\u00a0\u0436\u0435 \u0434\u043b\u0438\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0436\u0438\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f\u00a0\u2014 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u043b\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041e\u0431\u0437\u043e\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439<\/h2>\n<h3>\u041d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (S \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435)<\/h3>\n<p>\u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438. <\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0430 \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u0431\u043b\u043e\u043a\u0435 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. \u0411\u0435\u0440\u0451\u043c \u0431\u0430\u0439\u0442, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u0435\u0433\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c.<\/p>\n<pre><code class=\"cpp\">void S(uint8_t *blck) {     for (int i = 0; i &lt; BLOCK_SIZE; i++) {         blck[i] = Pi[blck[i]];     } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 S \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 &#8212; \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 Pi:<\/p>\n<pre><code class=\"cpp\">void reverse_S(uint8_t *blck) {     for (int i = 0; i &lt; BLOCK_SIZE; i++) {         blck[i] = reverse_Pi[blck[i]];     } }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451. \u0418\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 \u0432 \u043f\u043e\u043b\u0435 \u0413\u0430\u043b\u0443\u0430 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0430.<\/h3>\n<p>\u042d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435. <\/p>\n<p>GF(2) &#8212; \u043f\u043e\u043b\u0435 \u0413\u0430\u043b\u0443\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 2.<br \/>\u0427\u0442\u043e \u0436\u0435 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442? <br \/>\u0412\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043f\u043e\u043b\u044f \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e\u0441\u0442\u043e. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430: 0 \u0438 1. \u0418 \u0443 \u043d\u0430\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0434\u0432\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435. <br \/>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u044e:<\/p>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\"><strong>a<\/strong><\/p>\n<\/th>\n<th>\n<p align=\"left\"><strong>b<\/strong><\/p>\n<\/th>\n<th>\n<p align=\"left\"><strong>a + b<\/strong><\/p>\n<\/th>\n<th>\n<p align=\"left\"><strong>a \u00d7 b<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 GF(2^8). \u042d\u0442\u043e \u043f\u043e\u043b\u0435 \u0438\u0437 256 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e <strong>\u043f\u043e\u043b\u0438\u043d\u043e\u043c\u044b \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u043e 7 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e<\/strong>, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u2014 0 \u0438\u043b\u0438 1.<\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/> a\u2087x\u2077 + a\u2086x\u2076 + a\u2085x\u2075 + a\u2084x\u2074 + a\u2083x\u00b3 + a\u2082x\u00b2 + a\u2081x\u00b9 + a\u2080<br \/> \u0413\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 a\u1d62 \u2208 {0, 1}<\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442.<br \/> \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<br \/> \u042d\u043b\u0435\u043c\u0435\u043d\u0442:  0xD4 = 11010100<br \/> \u041f\u043e\u043b\u0438\u043d\u043e\u043c:\u00a0 x\u2077 + x\u2076 + x\u2074 + x\u00b2<\/p>\n<h3>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u0432 \u043d\u0430\u0434 \u043f\u043e\u043b\u0435\u043c \u0413\u0430\u043b\u0443\u0430<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0443\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 \u043d\u0430\u0434 \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u0435\u043c:<br \/>\u041f\u0443\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043b\u0438\u043d\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"A(x) = 1 \\cdot x^4 + 0 \\cdot x^3 + 0 \\cdot x^2 + 1 \\cdot x^1 + 1 \\cdot x^0 = x^4 + x + 1\" alt=\"A(x) = 1 \\cdot x^4 + 0 \\cdot x^3 + 0 \\cdot x^2 + 1 \\cdot x^1 + 1 \\cdot x^0 = x^4 + x + 1\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8\/81\/817\/817981cd6c1e1398580981b96e198db2.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8\/81\/817\/817981cd6c1e1398580981b96e198db2.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8\/81\/817\/817981cd6c1e1398580981b96e198db2.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0410 \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"B(x) = 1 \\cdot x^4 + 1 \\cdot x^3 + 0 \\cdot x^2 + 0 \\cdot x^1 + 1 \\cdot x^0 = x\u2074 + x\u00b3 + 1\" alt=\"B(x) = 1 \\cdot x^4 + 1 \\cdot x^3 + 0 \\cdot x^2 + 0 \\cdot x^1 + 1 \\cdot x^0 = x\u2074 + x\u00b3 + 1\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6\/6b\/6b0\/6b07d76c2ff6d78986a19b3df34cc7c2.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6\/6b\/6b0\/6b07d76c2ff6d78986a19b3df34cc7c2.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/6\/6b\/6b0\/6b07d76c2ff6d78986a19b3df34cc7c2.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0432 \u0448\u043a\u043e\u043b\u0435: \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0442\u043e\u0440\u043e\u0433\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f xor:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"x^4 \\cdot (x\u2074 + x\u00b3 + 1) = x^8 + x^7 + x^4\" alt=\"x^4 \\cdot (x\u2074 + x\u00b3 + 1) = x^8 + x^7 + x^4\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/07\/072\/072be3b4ec8153f0120d3430815b65cd.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/07\/072\/072be3b4ec8153f0120d3430815b65cd.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/07\/072\/072be3b4ec8153f0120d3430815b65cd.svg 781w\" loading=\"lazy\" decode=\"async\"\/><img decoding=\"async\" class=\"formula\" source=\"x \\cdot (x\u2074 + x\u00b3 + 1) = x^5 + x^4 + x\" alt=\"x \\cdot (x\u2074 + x\u00b3 + 1) = x^5 + x^4 + x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/114\/4f4\/9bd\/1144f49bd608fddbb61262f9f5294e22.svg\" width=\"261\" height=\"25\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/114\/4f4\/9bd\/1144f49bd608fddbb61262f9f5294e22.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/114\/4f4\/9bd\/1144f49bd608fddbb61262f9f5294e22.svg 781w\" loading=\"lazy\" decode=\"async\"\/><img decoding=\"async\" class=\"formula\" source=\"1 \\cdot (x\u2074 + x\u00b3 + 1) = x^4 + x^3 + 1\" alt=\"1 \\cdot (x\u2074 + x\u00b3 + 1) = x^4 + x^3 + 1\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/7f\/7fc\/7fc1aa98d155fd45e10e29ca8887ce93.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/7f\/7fc\/7fc1aa98d155fd45e10e29ca8887ce93.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/7f\/7fc\/7fc1aa98d155fd45e10e29ca8887ce93.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"x^8 + x^7 + x^5 + x^4 + x^4 + x^4 + x^3 + x + 1 + 1= x^8 + x^7 + x^5 + x^4 + x^3 + x\" alt=\"x^8 + x^7 + x^5 + x^4 + x^4 + x^4 + x^3 + x + 1 + 1= x^8 + x^7 + x^5 + x^4 + x^3 + x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/f9\/f97\/f977656238a5be07313c9a8fdfa60738.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/f9\/f97\/f977656238a5be07313c9a8fdfa60738.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/f9\/f97\/f977656238a5be07313c9a8fdfa60738.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u043e\u0441\u044c \u0434\u0432\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"x^4\" alt=\"x^4\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/3c\/3c6\/3c626f97ef8464ab0a967e301fb8a76a.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/3c\/3c6\/3c626f97ef8464ab0a967e301fb8a76a.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/3c\/3c6\/3c626f97ef8464ab0a967e301fb8a76a.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0438 \u0435\u0434\u0438\u043d\u0438\u0447\u043a\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u043e \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u043e\u043c\u0443 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e.<\/p>\n<p>\u041d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438.<br \/>\u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431:<br \/>\u041d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d &#8212; \u044d\u0442\u043e \u044d\u0442\u043e \u0430\u043d\u0430\u043b\u043e\u0433 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043c\u0438\u0440\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432, \u0442.\u0435 \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438.<\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431(\u043e\u043d \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \ud83d\ude0a):<br \/>\u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d \u043a \u043d\u0443\u043b\u044e, \u0442\u043e \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u043b\u0435(\u043d\u0435\u0442 \u043a\u043e\u0440\u043d\u0435\u0439).<\/p>\n<p>\u0412 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u043c \u0433\u043e\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d:<\/p>\n<p>x^8 + x^7 + x^6 + x^1 + 1<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0433\u043e \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0435 \u043a \u043d\u0443\u043b\u044e, \u0442\u043e \u043d\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"x = 0\" alt=\"x = 0\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/3d\/3da\/3dad28281778d5ef4b7a78c7bc7a6b09.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/3d\/3da\/3dad28281778d5ef4b7a78c7bc7a6b09.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/3d\/3da\/3dad28281778d5ef4b7a78c7bc7a6b09.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043d\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"x = 1\" alt=\"x = 1\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d3\/d37\/d37ffc54b67ce8de1f01efb1f2e33689.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d3\/d37\/d37ffc54b67ce8de1f01efb1f2e33689.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d3\/d37\/d37ffc54b67ce8de1f01efb1f2e33689.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u043d\u0430\u0448 \u0432\u044b\u0448\u0435\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u0432 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u044d\u0442\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0430:<\/p>\n<p>\u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u044d\u0442\u043e \u043d\u0430\u0439\u0442\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>\u041c\u044b \u0434\u0435\u043b\u0438\u043c <img decoding=\"async\" class=\"formula inline\" source=\"A(x)\" alt=\"A(x)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/78\/785\/7852db5d43d5ab2b22775d9f2131b869.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/78\/785\/7852db5d43d5ab2b22775d9f2131b869.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/78\/785\/7852db5d43d5ab2b22775d9f2131b869.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043d\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"M(x)\" alt=\"M(x)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee0\/ee0295d66460adab8de72f343ba13550.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee0\/ee0295d66460adab8de72f343ba13550.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee0\/ee0295d66460adab8de72f343ba13550.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u0442\u043e \u0435\u0441\u0442\u044c<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"A(x)\\mod M(x)\" alt=\"A(x)\\mod M(x)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5e2\/912\/a12\/5e2912a12787578d1fcc0247380924e8.svg\" width=\"158\" height=\"22\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5e2\/912\/a12\/5e2912a12787578d1fcc0247380924e8.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5e2\/912\/a12\/5e2912a12787578d1fcc0247380924e8.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, \u0433\u0434\u0435:<\/p>\n<ul>\n<li>\n<p><img decoding=\"async\" class=\"formula inline\" source=\"A(x) = x^8 + x^7 + x^5 + x^4 + x^3 + x\" alt=\"A(x) = x^8 + x^7 + x^5 + x^4 + x^3 + x\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f27\/bc9\/3c2\/f27bc93c21a24b986b127f5f40f85b57.svg\" width=\"298\" height=\"25\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f27\/bc9\/3c2\/f27bc93c21a24b986b127f5f40f85b57.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f27\/bc9\/3c2\/f27bc93c21a24b986b127f5f40f85b57.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<\/li>\n<li>\n<p><img decoding=\"async\" class=\"formula inline\" source=\"M(x) = x^8 + x^7 + x^6 + x + 1\" alt=\"M(x) = x^8 + x^7 + x^6 + x + 1\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee5\/ee5f700bd3f5f7f35e7edfa5d13e3196.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee5\/ee5f700bd3f5f7f35e7edfa5d13e3196.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee5\/ee5f700bd3f5f7f35e7edfa5d13e3196.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<\/li>\n<\/ul>\n<p>\u0426\u0435\u043b\u044c \u2014 \u043d\u0430\u0439\u0442\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"A(x)\" alt=\"A(x)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/78\/785\/7852db5d43d5ab2b22775d9f2131b869.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/78\/785\/7852db5d43d5ab2b22775d9f2131b869.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7\/78\/785\/7852db5d43d5ab2b22775d9f2131b869.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043d\u0430 <img decoding=\"async\" class=\"formula inline\" source=\"M(x).\" alt=\"M(x).\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/b3\/b37\/b3720253f04ba5e9ddab892b434f5f88.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/b3\/b37\/b3720253f04ba5e9ddab892b434f5f88.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/b3\/b37\/b3720253f04ba5e9ddab892b434f5f88.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435 \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435 \u0441\u0442\u043e\u043b\u0431\u0438\u043a\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e9f\/ac7\/4c5\/e9fac74c5c515c2fe8a157457c395ac0.png\" alt=\"\u0414\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0430 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\" title=\"\u0414\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0430 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\" width=\"1374\" height=\"288\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e9f\/ac7\/4c5\/e9fac74c5c515c2fe8a157457c395ac0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e9f\/ac7\/4c5\/e9fac74c5c515c2fe8a157457c395ac0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0414\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0430 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0440\u0430\u0432\u043d\u044b\u0439 <img decoding=\"async\" class=\"formula inline\" source=\"x^6 + x^5 + x^4 + x^3 + 1\" alt=\"x^6 + x^5 + x^4 + x^3 + 1\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/b3\/b38\/b38e371cf0ffe835c6d7a705b27b0b6c.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/b3\/b38\/b38e371cf0ffe835c6d7a705b27b0b6c.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/b3\/b38\/b38e371cf0ffe835c6d7a705b27b0b6c.svg 781w\" loading=\"lazy\" decode=\"async\"\/> &#8212; \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448 \u043e\u0442\u0432\u0435\u0442.<br \/> \u0424\u0443\u0443\u0443\u0443\u0443\u0445.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u043a\u043e\u0434\u0435, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u043e\u043e\u043e\u043e\u0449\u0435 &#8212; \u0432\u0441\u0451 \u0441\u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f \u0432 \u043c\u0430\u0442\u0440\u0451\u0448\u043a\u0443\ud83e\ude86.<\/p>\n<pre><code class=\"cpp\">static uint8_t GF_mul(uint8_t a, uint8_t b) {     uint8_t c = 0, hi_bit;     for (int i = 0; i &lt; 8; i++) {         if (b &amp; 1) c ^= a;         hi_bit = a &amp; 0x80;         a &lt;&lt;= 1;         if (hi_bit) a ^= 0xC3;         b &gt;&gt;= 1;     }     return c; }<\/code><\/pre>\n<p>\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8212; \u0431\u0430\u0439\u0442\u044b, \u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u044b<br \/>c &#8212; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f<br \/>hi_bit \u2014 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c, \u0432\u044b\u043b\u0435\u0437 \u043b\u0438 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 (x^7), \u043f\u0440\u0438 \u0441\u0434\u0432\u0438\u0433\u0435 a.<\/p>\n<p>\u0426\u0438\u043a\u043b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0431\u0438\u0442\u0443. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c \u0447\u0442\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0434\u0432\u0438\u0433 \u0431\u0438\u0442\u043e\u0432 \u0432\u043f\u0440\u0430\u0432\u043e(<code>b &amp;gt;&amp;gt;= 1<\/code>) \u0438 \u043f\u0440\u0438 \u043d\u043e\u0432\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0443\u0436\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0431\u0438\u0442, \u0430 \u043a\u0430\u043a \u0431\u044b \u043f\u0435\u0440\u0432\u044b\u0439, \u0432\u0442\u043e\u0440\u043e\u0439 \u0438 \u0442.\u0434.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0438\u0442 \u0443 \u0431\u0430\u0439\u0442\u0430 b, \u0435\u0441\u043b\u0438 \u043e\u043d \u0440\u0430\u0432\u0435\u043d 1, \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c <code>xor(c, a)<\/code>.<br \/>\u0415\u0441\u043b\u0438 \u0431\u044b \u043e\u043d \u0431\u044b\u043b \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0441\u043e\u0440 \u0442\u0430\u043a xor \u0441 \u043d\u0443\u043b\u0451\u043c \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0435\u0441\u043b\u0438 \u0432 \u0447\u0438\u0441\u043b\u0435 b \u0431\u0438\u0442 \u0440\u0430\u0432\u0435\u043d 0, \u0442\u043e \u0435\u0433\u043e \u0432\u043a\u043b\u0430\u0434 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0438 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0442\u044c (XOR\u0438\u0442\u044c) a \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443. \u042d\u0442\u043e \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043b\u0438 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u0432 a.<\/p>\n<pre><code class=\"cpp\">hi_bit = a &amp; 0x80;<\/code><\/pre>\n<p>0x80 \u2014 \u044d\u0442\u043e <strong>\u043c\u0430\u0441\u043a\u0430<\/strong> \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u0431\u0430\u0439\u0442\u0430, \u0442\u043e \u0435\u0441\u0442\u044c, \u0431\u0438\u0442 \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 x^7.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u043c a \u043d\u0430 1 \u0431\u0438\u0442 \u0432\u043b\u0435\u0432\u043e: \u2014 \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u0430 x, \u0447\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 \u043d\u0430 1. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0446\u0438\u043a\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c x \u0438\u0437 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u044f b.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u0440\u0430\u0432\u0435\u043d 1, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0441\u0434\u0432\u0438\u0433\u0430 \u043d\u0430 \u043e\u0434\u0438\u043d \u0440\u0430\u0437\u0440\u044f\u0434 \u0432\u043b\u0435\u0432\u043e \u043c\u044b \u0432\u044b\u0439\u0434\u0435\u043c \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b x^7 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c x^8, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0437\u044f\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<pre><code class=\"cpp\">if (hi_bit) a ^= 0xC3;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 <strong>\u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u0431\u044b\u043b \u0440\u0430\u0432\u0435\u043d 1<\/strong> (\u0442\u043e \u0435\u0441\u0442\u044c, \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u043f\u0435\u0440\u0435\u0434 \u0441\u0434\u0432\u0438\u0433\u043e\u043c \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d), \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c <strong>XOR<\/strong> \u0441 \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u043c 0xC3, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043f\u043e\u043b\u0435 \u0413\u0430\u043b\u0443\u0430 GF(2^8).<\/p>\n<p>(\u041c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d 0xC3 \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u2014 \u044d\u0442\u043e 11000011, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442<br \/> <img decoding=\"async\" class=\"formula inline\" source=\"x^8 + x^7 + x^6 + x + 1\" alt=\"x^8 + x^7 + x^6 + x + 1\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ad\/bf0\/b62\/8adbf0b62dc364b52a09c3ca8db45e4c.svg\" width=\"177\" height=\"22\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ad\/bf0\/b62\/8adbf0b62dc364b52a09c3ca8db45e4c.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ad\/bf0\/b62\/8adbf0b62dc364b52a09c3ca8db45e4c.svg 781w\" loading=\"lazy\" decode=\"async\"\/> )<\/p>\n<p>\u042d\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043d\u043e \u043a\u0430\u043a\u043e\u0439 \u0435\u0441\u0442\u044c. \u041e\u043d \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d, \u0438 \u0442\u0435\u043c \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043e\u0434\u043e\u043c \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e &#8212; \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0432\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u042f \u0432\u0430\u0441 \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e. \u0421\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u043f\u043e\u0437\u0430\u0434\u0438 &#8212; \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043f\u043b\u043e\u0448\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435 ))<\/p>\n<h3>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 R<\/h3>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 \u0432\u043f\u0440\u0430\u0432\u043e, \u0434\u0430\u043b\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c l_vec, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 tmp \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e xor. \u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0431\u043b\u043e\u043a \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e tmp.<\/p>\n<pre><code class=\"cpp\">void R(uint8_t *block) {     cyclic_shift_right(block);     uint8_t tmp = 0; \/\/ zero or the 16th element???      for (int i = 0; i &lt; 16; i++) {         tmp ^= GF_mul(block[i], l_vec[15 - i]); \/\/ mul + xor     }      block[0] = tmp; }<\/code><\/pre>\n<pre><code class=\"cpp\">void cyclic_shift_right(uint8_t *block) {     const uint8_t last = block[BLOCK_SIZE - 1];     for (int i = BLOCK_SIZE - 1; i &gt; 0; i--) {         block[i] = block[i - 1];     }     block[0] = last; }  void cyclic_shift_left(uint8_t *block) {     const uint8_t first = block[0];     for (int i = 0; i &lt; BLOCK_SIZE - 1; i++) {         block[i] = block[i + 1];     }     block[BLOCK_SIZE - 1] = first; }<\/code><\/pre>\n<pre><code class=\"cpp\">const uint8_t l_vec[16] = {     0x94, 0x20, 0x85, 0x10, 0xC2, 0xC0, 0x01, 0xFB,     0x01, 0xC0, 0xC2, 0x10, 0x85, 0x20, 0x94, 0x01 };<\/code><\/pre>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/711\/444\/3c1\/7114443c1d12a9b1823ae7821d80d91b.png\" alt=\"\u0421\u0445\u0435\u043c\u0430 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430\" title=\"\u0421\u0445\u0435\u043c\u0430 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430\" width=\"1268\" height=\"782\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/711\/444\/3c1\/7114443c1d12a9b1823ae7821d80d91b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/711\/444\/3c1\/7114443c1d12a9b1823ae7821d80d91b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0443\u0442 \u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 R. \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 (\u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 GF \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c):<\/p>\n<pre><code class=\"cpp\">void reverse_R(uint8_t *block) {     uint8_t tmp = 0;      for (int i = 0; i &lt; 16; i++) {         tmp ^= GF_mul(block[i], l_vec[15 - i]); \/\/ mul + xor     }     block[0] = tmp;     cyclic_shift_left(block); }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u043c\u0435\u0442\u043e\u0434 L, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 16 \u0440\u0430\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 R, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0439\u0442 \u043f\u0440\u043e\u0448\u0451\u043b \u0447\u0435\u0440\u0435\u0437 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cpp\">void L(uint8_t *block) {     for (int i = 0; i &lt; 16; i++) {         R(block);     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 F.<br \/>\u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0434\u0432\u0430 \u0431\u043b\u043e\u043a\u0430. \u041a\u0441\u043e\u0440\u0438\u0442 \u0438\u0445 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0432\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f: S \u0438 L, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438.<\/p>\n<pre><code class=\"cpp\">uint8_t* F(uint8_t *k1, uint8_t *c) {     uint8_t *tmp = xor_blocks(k1, c);     S(tmp);     L(tmp);     return tmp; }<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439.<\/p>\n<h3>\u0413\u0415\u041d\u0415\u0420\u0410\u0426\u0418\u042f \u0420\u0410\u0423\u041d\u0414\u041e\u0412\u042b\u0425 \u041a\u041b\u042e\u0427\u0415\u0419<\/h3>\n<p>\u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b. \u041e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0413\u041e\u0421\u0422 \u043e\u043d\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c:<\/p>\n<pre><code class=\"cpp\">void gen_constants(uint8_t *constants[32]) {     for (int i = 0; i &lt; 32; i++) {         constants[i] = malloc(BLOCK_SIZE); \/\/ allocate memory         memset(constants[i], 0, BLOCK_SIZE); \/\/ zero          constants[i][15] = i + 1;         L(constants[i]);     } }<\/code><\/pre>\n<ul>\n<li>\n<p>\u0423 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e 32 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0432\u0438\u0434\u0430:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cpp\">0x00, 0x00, 0x00 ... 0x00 0x00, 0x00, 0x00 ... 0x01 0x00, 0x00, 0x00 ... 0x02         .... 0x00, 0x00, 0x00 ... 0x20<\/code><\/pre>\n<ul>\n<li>\n<p>\u041a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u044d\u0442\u0438\u0445 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043e\u043a \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434 L<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0435\u0439, \u0441\u043a\u043e\u0440\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0441\u043b\u043e\u0436\u0438\u0442\u0441\u044f.<\/p>\n<pre><code class=\"cpp\">\/\/ key generation void gen_keys(uint8_t *keys[10], uint8_t *masterkey) {     uint8_t *constants[32]; \/\/ array for keys_constants     gen_constants(constants);      uint8_t *k1 = malloc(16);     uint8_t *k2 = malloc(16);      \/\/ memory copy for masterKey immutability     memcpy(k1, masterkey, 16);     memcpy(k2, masterkey + 16, 16);      keys[0] = malloc(BLOCK_SIZE);     keys[1] = malloc(BLOCK_SIZE);      memcpy(keys[0], k1, BLOCK_SIZE);     memcpy(keys[1], k2, BLOCK_SIZE);      for (int i = 0; i &lt; 32; i++) {         uint8_t *tmp = F(k1, constants[i]);         tmp = xor_blocks(tmp, k2);         k2 = k1;         k1 = tmp;          if ((i + 1) % 8 == 0) {             int a = (i + 1) \/ 4;              \/\/write a value with memcpy, cos k1 k2 still needed             keys[a] = malloc(BLOCK_SIZE);             memcpy(keys[a], k1, BLOCK_SIZE);             keys[a + 1] = malloc(BLOCK_SIZE);             memcpy(keys[a + 1], k2, BLOCK_SIZE);         }     }     for (int i = 0; i &lt; 32; i++) {         free(constants[i]);     } }<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u043c\u044b<\/p>\n<ol>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c, \u043f\u043e\u0434\u0435\u043b\u0438\u0432 \u043c\u0430\u0441\u0442\u0435\u0440\u043a\u043b\u044e\u0447 \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0442\u044c \u0444\u0435\u0439\u0441\u0442\u0435\u043b\u044f, \u043e\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0430 \u043d\u0430 \u0441\u0445\u0435\u043c\u0435 \u043d\u0438\u0436\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0435 8 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u043c\u044b \u0441\u043d\u0438\u043c\u0430\u0435\u043c \u043f\u043e 2 \u043a\u043b\u044e\u0447\u0430.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/40e\/af2\/b76\/40eaf2b760f0af8d96d9b8dc50e9cbda.png\" alt=\"\u0421\u0435\u0442\u044c \u0444\u0435\u0439\u0441\u0442\u0435\u043b\u044f\" title=\"\u0421\u0435\u0442\u044c \u0444\u0435\u0439\u0441\u0442\u0435\u043b\u044f\" width=\"1186\" height=\"1976\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/40e\/af2\/b76\/40eaf2b760f0af8d96d9b8dc50e9cbda.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/40e\/af2\/b76\/40eaf2b760f0af8d96d9b8dc50e9cbda.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0421\u0435\u0442\u044c \u0444\u0435\u0439\u0441\u0442\u0435\u043b\u044f<\/figcaption><\/div>\n<\/figure>\n<h3>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0430<\/h3>\n<p>\u0414\u043b\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c 10 \u0440\u0430\u0443\u043d\u0434\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0442\u0440\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041a\u0441\u043e\u0440 \u0441 \u043a\u043b\u044e\u0447\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u041b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u041d\u041e! \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0440\u0430\u0443\u043d\u0434\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e XOR &#8212; \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cpp\">void encrypt_block(uint8_t *text_bytes, uint8_t *keys[10]) {     for (int i = 0; i &lt; 9; i++) {         xor_blocks_void(text_bytes, keys[i]);         S(text_bytes);         L(text_bytes);     }     xor_blocks_void(text_bytes, keys[9]); }<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u044d\u0442\u0438\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<pre><code class=\"cpp\">void decrypt_block(uint8_t *text_bytes, uint8_t *keys[10]) {     xor_blocks_void(text_bytes, keys[9]);     for (int i = 8; i &gt;= 0; i--) {         reverse_L(text_bytes);         reverse_S(text_bytes);         xor_blocks_void(text_bytes, keys[i]);     } }<\/code><\/pre>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430 \u044d\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0436\u0435 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u044e \u0441\u0442\u0430\u0442\u0435\u0439\u043a\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u043a\u0440\u044b\u043b\u0438 \u0432\u0441\u0451 \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0413\u041e\u0421\u0422\u0430. \u041c\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a\u0438, \u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u0430\u044f.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<ul>\n<li>\n<p>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0430, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0431\u0430\u0439\u0442\u043e\u0432 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0436\u0438\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f CBC<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430:<br \/>\u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0443 \u0432\u0430\u0441 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0442\u0435\u043d 16\u0442\u0438 \u0431\u0430\u0439\u0442\u0430\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0434\u043e\u0431\u0438\u0432\u0430\u0442\u044c \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430, \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043d\u0443 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0447\u0442\u043e\u0431\u044b \u043a\u0440\u0438\u043f\u0442\u043e\u0441\u0442\u043e\u0439\u043a\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c).<\/p>\n<p>\u042d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:<\/p>\n<p>\u042f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u043a\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e \u0444\u043b\u0430\u0433 \u043d\u0430\u0434\u043e \u043b\u0438 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0438\u0444\u0440\u0443\u0435\u043c\u044b\u0439 \u0431\u043b\u043e\u043a. \u0414\u0430\u043a \u0432\u043e\u0442, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0434\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043c\u044b \u0434\u043e\u0431\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e 0xFF:<\/p>\n<pre><code class=\"cpp\">if (bytes_read &lt; BLOCK_SIZE) {     padding_bytes = BLOCK_SIZE - bytes_read;     memset(buffer + bytes_read, 0xFF, BLOCK_SIZE - bytes_read); }<\/code><\/pre>\n<p>\u0418 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438.<br \/>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043c\u044b \u0432\u0441\u0451 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043b\u0438 \u043c\u044b \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435(\u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0430\u0439\u0442\u044b). \u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043d\u043e\u0432\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432, \u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0434\u0432\u0430 \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u043b\u043e\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 0xFF, \u0438\u043d\u0430\u0447\u0435 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0431\u043b\u043e\u043a \u0438 \u0432 \u0435\u0433\u043e \u043d\u0443\u043b\u0435\u0432\u043e\u043c \u0431\u0430\u0439\u0442\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438.<\/p>\n<pre><code class=\"cpp\">const int is_whole_blocks = (file_size % BLOCK_SIZE == 0); if (is_whole_blocks) {       \/\/ if an input file has integer number of block add two empty blocks       memset(buffer, 0xFF, BLOCK_SIZE);       fwrite(buffer, 1, BLOCK_SIZE, output_file);        memset(buffer, 0xFF, BLOCK_SIZE);       fwrite(buffer, 1, BLOCK_SIZE, output_file);    } else {       \/\/ if an input file has not integer number of block, add block with number of added 0xFF       memset(buffer, 0xFF, BLOCK_SIZE);       buffer[0] = (uint8_t)padding_bytes;       fwrite(buffer, 1, BLOCK_SIZE, output_file);   }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u044d\u0442\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430: \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u043e\u0439 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0431\u0430\u0439\u0442. \u0415\u0441\u043b\u0438 \u043e\u043d \u043f\u043e\u043b\u043d\u044b\u0439 0xFF, \u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c, \u043d\u0435 \u0447\u0438\u0442\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0434\u0432\u0430 \u0431\u0430\u0439\u0442\u0430, \u0438\u043d\u0430\u0447\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0431\u0430\u0439\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">int zeros; for (int i = 0; i &lt; BLOCK_SIZE; i++) {     if (buffer[i] != 0xFF) {         is_buffer_zero = false;         zeros = buffer[0];         break;     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0447\u0442\u043e\u00a0\u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0436\u0438\u043c\u0430 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u00a0\u0440\u0435\u0436\u0438\u043c ECB (\u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u043a\u043d\u0438\u0433\u0438), \u0442\u043e \u0435\u0441\u0442\u044c \u0431\u0435\u0437\u00a0\u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0431\u043b\u043e\u043a\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439\u00a0\u2014 \u043d\u0435\u00a0\u043e\u0447\u0435\u043d\u044c \u0441\u0435\u043a\u044c\u044e\u0440\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a\u00a0\u043e\u0434\u043d\u0430 \u0432\u0445\u043e\u0434\u043d\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439\u00a0\u0436\u0435. \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u00a0\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439, \u0435\u0451 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0432\u00a0\u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e5a\/c6a\/449\/e5ac6a449b7e262b71fb0baaf258fe5b.png\" width=\"1242\" height=\"1754\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e5a\/c6a\/449\/e5ac6a449b7e262b71fb0baaf258fe5b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e5a\/c6a\/449\/e5ac6a449b7e262b71fb0baaf258fe5b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u042d\u0442\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a\u00a0\u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0430, \u043d\u043e\u00a0\u043c\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0447\u0442\u043e\u00a0\u0442\u0430\u043c\u00a0\u0431\u044b\u043b\u043e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\ud83e\udd14, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u043d\u0430\u0441 \u043d\u0435\u00a0\u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442.<\/p>\n<p>\u0412\u044b\u0431\u0440\u0430\u043b \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u0437\u00a0\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445\u00a0\u2014 CBC. \u0412\u043e\u0442 \u043a\u0430\u043a\u00a0\u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a9e\/2a8\/d05\/a9e2a8d05257e8529a5467c8192e8275.png\" alt=\"CBC mode\" title=\"CBC mode\" width=\"646\" height=\"509\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/a9e\/2a8\/d05\/a9e2a8d05257e8529a5467c8192e8275.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a9e\/2a8\/d05\/a9e2a8d05257e8529a5467c8192e8275.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>CBC mode<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043a\u0441\u043e\u0440 \u0441 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 gamma, \u0437\u0430\u0442\u0435\u043c gamma \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e \u0441\u0445\u0435\u043c\u043e\u0439.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0412\u0435\u043a\u0442\u043e\u0440\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438(\u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f gamma) \u044f \u0432\u0437\u044f\u043b \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0439 \u043a\u043b\u044e\u0447.<\/p>\n<pre><code class=\"cpp\">  uint8_t* gamma = malloc(BLOCK_SIZE);   memcpy(gamma, keys[1], BLOCK_SIZE);<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 xor \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">  while ((bytes_read = fread(buffer, 1, BLOCK_SIZE, input_file)) &gt; 0) {       if (bytes_read &lt; BLOCK_SIZE) {           padding_bytes = BLOCK_SIZE - bytes_read;           memset(buffer + bytes_read, 0xFF, BLOCK_SIZE - bytes_read);       }       xor_blocks_void(buffer, gamma); \/\/ CBC: xor with gamma       encrypt_block(buffer, keys);       memcpy(gamma, buffer, BLOCK_SIZE); \/\/ CBC: refresh gamma       fwrite(buffer, 1, BLOCK_SIZE, output_file);   }<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430, \u0442\u0430\u043a \u043a\u0430\u043a\u00a0\u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0431\u043b\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e\u00a0\u0431\u044b\u043b\u043e\u00a0\u0431\u044b \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043d\u043e\u00a0\u043f\u043e\u0440\u0430 \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u044f\u0442\u044c\u0441\u044f, \u0432\u00a0\u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430\u00a0\u043c\u043e\u0451 github.<\/p>\n<p>\u042d\u0442\u0430 \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c, \u043a\u0440\u0438\u0442\u0438\u043a\u0435, \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0444\u0430\u0432\u043e\u0440\u0438\u0442\u0430\u043c \u043d\u0430\u00a0github.<\/p>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0430<\/p>\n<p><code>[project](<\/code><a href=\"https:\/\/github.com\/awsCartman\/kuznec\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/awsCartman\/kuznec<\/a><code>)<\/code><\/p>\n<p><code>---<\/code><\/p>\n<p><code>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430\u043c\u0435\u043d:<\/code><\/p>\n<pre><code class=\"cpp\">const uint8_t Pi[256] = {     0xFC, 0xEE, 0xDD, 0x11, 0xCF, 0x6E, 0x31, 0x16, 0xFB, 0xC4, 0xFA, 0xDA, 0x23, 0xC5, 0x04, 0x4D,     0xE9, 0x77, 0xF0, 0xDB, 0x93, 0x2E, 0x99, 0xBA, 0x17, 0x36, 0xF1, 0xBB, 0x14, 0xCD, 0x5F, 0xC1,     0xF9, 0x18, 0x65, 0x5A, 0xE2, 0x5C, 0xEF, 0x21, 0x81, 0x1C, 0x3C, 0x42, 0x8B, 0x01, 0x8E, 0x4F,     0x05, 0x84, 0x02, 0xAE, 0xE3, 0x6A, 0x8F, 0xA0, 0x06, 0x0B, 0xED, 0x98, 0x7F, 0xD4, 0xD3, 0x1F,     0xEB, 0x34, 0x2C, 0x51, 0xEA, 0xC8, 0x48, 0xAB, 0xF2, 0x2A, 0x68, 0xA2, 0xFD, 0x3A, 0xCE, 0xCC,     0xB5, 0x70, 0x0E, 0x56, 0x08, 0x0C, 0x76, 0x12, 0xBF, 0x72, 0x13, 0x47, 0x9C, 0xB7, 0x5D, 0x87,     0x15, 0xA1, 0x96, 0x29, 0x10, 0x7B, 0x9A, 0xC7, 0xF3, 0x91, 0x78, 0x6F, 0x9D, 0x9E, 0xB2, 0xB1,     0x32, 0x75, 0x19, 0x3D, 0xFF, 0x35, 0x8A, 0x7E, 0x6D, 0x54, 0xC6, 0x80, 0xC3, 0xBD, 0x0D, 0x57,     0xDF, 0xF5, 0x24, 0xA9, 0x3E, 0xA8, 0x43, 0xC9, 0xD7, 0x79, 0xD6, 0xF6, 0x7C, 0x22, 0xB9, 0x03,     0xE0, 0x0F, 0xEC, 0xDE, 0x7A, 0x94, 0xB0, 0xBC, 0xDC, 0xE8, 0x28, 0x50, 0x4E, 0x33, 0x0A, 0x4A,     0xA7, 0x97, 0x60, 0x73, 0x1E, 0x00, 0x62, 0x44, 0x1A, 0xB8, 0x38, 0x82, 0x64, 0x9F, 0x26, 0x41,     0xAD, 0x45, 0x46, 0x92, 0x27, 0x5E, 0x55, 0x2F, 0x8C, 0xA3, 0xA5, 0x7D, 0x69, 0xD5, 0x95, 0x3B,     0x07, 0x58, 0xB3, 0x40, 0x86, 0xAC, 0x1D, 0xF7, 0x30, 0x37, 0x6B, 0xE4, 0x88, 0xD9, 0xE7, 0x89,     0xE1, 0x1B, 0x83, 0x49, 0x4C, 0x3F, 0xF8, 0xFE, 0x8D, 0x53, 0xAA, 0x90, 0xCA, 0xD8, 0x85, 0x61,     0x20, 0x71, 0x67, 0xA4, 0x2D, 0x2B, 0x09, 0x5B, 0xCB, 0x9B, 0x25, 0xD0, 0xBE, 0xE5, 0x6C, 0x52,     0x59, 0xA6, 0x74, 0xD2, 0xE6, 0xF4, 0xB4, 0xC0, 0xD1, 0x66, 0xAF, 0xC2, 0x39, 0x4B, 0x63, 0xB6 };  const uint8_t reverse_Pi[256] = {     0xa5, 0x2d, 0x32, 0x8f, 0x0e, 0x30, 0x38, 0xc0, 0x54, 0xe6, 0x9e, 0x39, 0x55, 0x7e, 0x52, 0x91,     0x64, 0x03, 0x57, 0x5a, 0x1c, 0x60, 0x07, 0x18, 0x21, 0x72, 0xa8, 0xd1, 0x29, 0xc6, 0xa4, 0x3f,     0xe0, 0x27, 0x8d, 0x0c, 0x82, 0xea, 0xae, 0xb4, 0x9a, 0x63, 0x49, 0xe5, 0x42, 0xe4, 0x15, 0xb7,     0xc8, 0x06, 0x70, 0x9d, 0x41, 0x75, 0x19, 0xc9, 0xaa, 0xfc, 0x4d, 0xbf, 0x2a, 0x73, 0x84, 0xd5,     0xc3, 0xaf, 0x2b, 0x86, 0xa7, 0xb1, 0xb2, 0x5b, 0x46, 0xd3, 0x9f, 0xfd, 0xd4, 0x0f, 0x9c, 0x2f,     0x9b, 0x43, 0xef, 0xd9, 0x79, 0xb6, 0x53, 0x7f, 0xc1, 0xf0, 0x23, 0xe7, 0x25, 0x5e, 0xb5, 0x1e,     0xa2, 0xdf, 0xa6, 0xfe, 0xac, 0x22, 0xf9, 0xe2, 0x4a, 0xbc, 0x35, 0xca, 0xee, 0x78, 0x05, 0x6b,     0x51, 0xe1, 0x59, 0xa3, 0xf2, 0x71, 0x56, 0x11, 0x6a, 0x89, 0x94, 0x65, 0x8c, 0xbb, 0x77, 0x3c,     0x7b, 0x28, 0xab, 0xd2, 0x31, 0xde, 0xc4, 0x5f, 0xcc, 0xcf, 0x76, 0x2c, 0xb8, 0xd8, 0x2e, 0x36,     0xdb, 0x69, 0xb3, 0x14, 0x95, 0xbe, 0x62, 0xa1, 0x3b, 0x16, 0x66, 0xe9, 0x5c, 0x6c, 0x6d, 0xad,     0x37, 0x61, 0x4b, 0xb9, 0xe3, 0xba, 0xf1, 0xa0, 0x85, 0x83, 0xda, 0x47, 0xc5, 0xb0, 0x33, 0xfa,     0x96, 0x6f, 0x6e, 0xc2, 0xf6, 0x50, 0xff, 0x5d, 0xa9, 0x8e, 0x17, 0x1b, 0x97, 0x7d, 0xec, 0x58,     0xf7, 0x1f, 0xfb, 0x7c, 0x09, 0x0d, 0x7a, 0x67, 0x45, 0x87, 0xdc, 0xe8, 0x4f, 0x1d, 0x4e, 0x04,     0xeb, 0xf8, 0xf3, 0x3e, 0x3d, 0xbd, 0x8a, 0x88, 0xdd, 0xcd, 0x0b, 0x13, 0x98, 0x02, 0x93, 0x80,     0x90, 0xd0, 0x24, 0x34, 0xcb, 0xed, 0xf4, 0xce, 0x99, 0x10, 0x44, 0x40, 0x92, 0x3a, 0x01, 0x26,     0x12, 0x1a, 0x48, 0x68, 0xf5, 0x81, 0x8b, 0xc7, 0xd6, 0x20, 0x0a, 0x08, 0x00, 0x4c, 0xd7, 0x74, };<\/code><\/pre>\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\/903938\/\"> https:\/\/habr.com\/ru\/articles\/903938\/<\/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>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>\u0412\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0440\u0430\u0437\u0431\u043e\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430 \u00ab\u043a\u0443\u0437\u043d\u0435\u0447\u0438\u043a\u00bb. \u041f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c.<\/p>\n<p>\u0412\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u00a0C.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u0411\u043b\u043e\u043a\u00a0\u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437 16\u0442\u0438 \u0431\u0430\u0439\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0430\u0441\u0442\u0435\u0440\u043a\u043b\u044e\u0447\u00a0\u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u044e\u0447 \u0434\u043b\u044f\u00a0\u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f(\u0434\u043b\u0438\u043d\u0430 32\u0431\u0430\u0439\u0442\u0430). \u0418\u0437\u00a0\u043d\u0435\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0435 \u043a\u043b\u044e\u0447. \u0421\u0430\u043c \u043a\u043b\u044e\u0447 \u0432\u00a0\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043d\u0435\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0439 \u043a\u043b\u044e\u0447\u00a0\u2014 \u043a\u043b\u044e\u0447, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0439 \u0438\u0437\u00a0\u043c\u0430\u0441\u0442\u0435\u0440 \u043a\u043b\u044e\u0447\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435(\u043f\u0440\u044f\u043c\u043e\u0435)\u00a0\u2014 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438(\u0431\u043b\u043e\u043a\u043e\u043c). \u0423\u0441\u043b\u043e\u0432\u043d\u043e: \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\/\u0438\u043b\u0438 \u0438\u0445 \u0444\u043e\u0440\u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0437\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0410\u00a0\u0432\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0411.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0\u2014 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438(\u0431\u043b\u043e\u043a\u043e\u043c). \u0423\u0441\u043b\u043e\u0432\u043d\u043e: \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\/\u0438\u043b\u0438 \u0438\u0445 \u0444\u043e\u0440\u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0437\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0411 \u0432\u00a0\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0410. \u041e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u044f\u043c\u043e\u043c\u0443 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u00a0\u2014 \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f\u00a0\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442\u00a0\u0436\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447.<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u043e\u0447\u043d\u044b\u0439 \u0448\u0438\u0444\u0440\u00a0\u2014 \u044d\u0442\u043e \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0439 \u0431\u043b\u043e\u043a \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0432\u00a0\u0431\u043b\u043e\u043a \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0442\u043e\u0439\u00a0\u0436\u0435 \u0434\u043b\u0438\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0436\u0438\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f\u00a0\u2014 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u043b\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041e\u0431\u0437\u043e\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439<\/h2>\n<h3>\u041d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 (S \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435)<\/h3>\n<p>\u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438. <\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0430 \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u0431\u043b\u043e\u043a\u0435 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. \u0411\u0435\u0440\u0451\u043c \u0431\u0430\u0439\u0442, \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u0435\u0433\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c.<\/p>\n<pre><code class=\"cpp\">void S(uint8_t *blck) {     for (int i = 0; i &lt; BLOCK_SIZE; i++) {         blck[i] = Pi[blck[i]];     } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 S \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 &#8212; \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 Pi:<\/p>\n<pre><code class=\"cpp\">void reverse_S(uint8_t *blck) {     for (int i = 0; i &lt; BLOCK_SIZE; i++) {         blck[i] = reverse_Pi[blck[i]];     } }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451. \u0418\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 \u0432 \u043f\u043e\u043b\u0435 \u0413\u0430\u043b\u0443\u0430 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0430.<\/h3>\n<p>\u042d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435. <\/p>\n<p>GF(2) &#8212; \u043f\u043e\u043b\u0435 \u0413\u0430\u043b\u0443\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 2.<br \/>\u0427\u0442\u043e \u0436\u0435 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442? <br \/>\u0412\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043f\u043e\u043b\u044f \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e\u0441\u0442\u043e. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430: 0 \u0438 1. \u0418 \u0443 \u043d\u0430\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0434\u0432\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438: \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435. <br \/>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u044e:<\/p>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\"><strong>a<\/strong><\/p>\n<\/th>\n<th>\n<p align=\"left\"><strong>b<\/strong><\/p>\n<\/th>\n<th>\n<p align=\"left\"><strong>a + b<\/strong><\/p>\n<\/th>\n<th>\n<p align=\"left\"><strong>a \u00d7 b<\/strong><\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0436\u0435 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 GF(2^8). \u042d\u0442\u043e \u043f\u043e\u043b\u0435 \u0438\u0437 256 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e <strong>\u043f\u043e\u043b\u0438\u043d\u043e\u043c\u044b \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u043e 7 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e<\/strong>, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u2014 0 \u0438\u043b\u0438 1.<\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/> a\u2087x\u2077 + a\u2086x\u2076 + a\u2085x\u2075 + a\u2084x\u2074 + a\u2083x\u00b3 + a\u2082x\u00b2 + a\u2081x\u00b9 + a\u2080<br \/> \u0413\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 a\u1d62 \u2208 {0, 1}<\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442.<br \/> \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<br \/> \u042d\u043b\u0435\u043c\u0435\u043d\u0442:  0xD4 = 11010100<br \/> \u041f\u043e\u043b\u0438\u043d\u043e\u043c:\u00a0 x\u2077 + x\u2076 + x\u2074 + x\u00b2<\/p>\n<h3>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u0432 \u043d\u0430\u0434 \u043f\u043e\u043b\u0435\u043c \u0413\u0430\u043b\u0443\u0430<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0443\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430 \u043d\u0430\u0434 \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u0435\u043c:<br \/>\u041f\u0443\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043b\u0438\u043d\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<p>\u0410 \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<p>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0432 \u0448\u043a\u043e\u043b\u0435: \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0442\u043e\u0440\u043e\u0433\u043e, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f xor:<\/p>\n<p>\u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u043e\u0441\u044c \u0434\u0432\u0430  \u0438 \u0435\u0434\u0438\u043d\u0438\u0447\u043a\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u043e \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u043e\u043c\u0443 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e.<\/p>\n<p>\u041d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438.<br \/>\u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431:<br \/>\u041d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d &#8212; \u044d\u0442\u043e \u044d\u0442\u043e \u0430\u043d\u0430\u043b\u043e\u0433 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043c\u0438\u0440\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432, \u0442.\u0435 \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438.<\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431(\u043e\u043d \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \ud83d\ude0a):<br \/>\u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d \u043a \u043d\u0443\u043b\u044e, \u0442\u043e \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u043b\u0435(\u043d\u0435\u0442 \u043a\u043e\u0440\u043d\u0435\u0439).<\/p>\n<p>\u0412 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u043c \u0433\u043e\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d:<\/p>\n<p>x^8 + x^7 + x^6 + x^1 + 1<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0433\u043e \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0435 \u043a \u043d\u0443\u043b\u044e, \u0442\u043e \u043d\u0438  \u043d\u0438  \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u043d\u0430\u0448 \u0432\u044b\u0448\u0435\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u043e\u0432 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u044d\u0442\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0430:<\/p>\n<p>\u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u044d\u0442\u043e \u043d\u0430\u0439\u0442\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>\u041c\u044b \u0434\u0435\u043b\u0438\u043c  \u043d\u0430 , \u0442\u043e \u0435\u0441\u0442\u044c<br \/> , \u0433\u0434\u0435:<\/p>\n<ul>\n<li>\n<\/li>\n<li>\n<\/li>\n<\/ul>\n<p>\u0426\u0435\u043b\u044c \u2014 \u043d\u0430\u0439\u0442\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f  \u043d\u0430 <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u044d\u0442\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435 \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435 \u0441\u0442\u043e\u043b\u0431\u0438\u043a\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0414\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u0430 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0440\u0430\u0432\u043d\u044b\u0439  &#8212; \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448 \u043e\u0442\u0432\u0435\u0442.<br \/> \u0424\u0443\u0443\u0443\u0443\u0443\u0445.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u043a\u043e\u0434\u0435, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u043e\u043e\u043e\u043e\u0449\u0435 &#8212; \u0432\u0441\u0451 \u0441\u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f \u0432 \u043c\u0430\u0442\u0440\u0451\u0448\u043a\u0443\ud83e\ude86.<\/p>\n<pre><code class=\"cpp\">static uint8_t GF_mul(uint8_t a, uint8_t b) {     uint8_t c = 0, hi_bit;     for (int i = 0; i &lt; 8; i++) {         if (b &amp; 1) c ^= a;         hi_bit = a &amp; 0x80;         a &lt;&lt;= 1;         if (hi_bit) a ^= 0xC3;         b &gt;&gt;= 1;     }     return c; }<\/code><\/pre>\n<p>\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#8212; \u0431\u0430\u0439\u0442\u044b, \u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u044b<br \/>c &#8212; \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f<br \/>hi_bit \u2014 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c, \u0432\u044b\u043b\u0435\u0437 \u043b\u0438 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 (x^7), \u043f\u0440\u0438 \u0441\u0434\u0432\u0438\u0433\u0435 a.<\/p>\n<p>\u0426\u0438\u043a\u043b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0431\u0438\u0442\u0443. \u042d\u0442\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c \u0447\u0442\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0434\u0432\u0438\u0433 \u0431\u0438\u0442\u043e\u0432 \u0432\u043f\u0440\u0430\u0432\u043e(<code>b &amp;gt;&amp;gt;= 1<\/code>) \u0438 \u043f\u0440\u0438 \u043d\u043e\u0432\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u044b \u0443\u0436\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0431\u0438\u0442, \u0430 \u043a\u0430\u043a \u0431\u044b \u043f\u0435\u0440\u0432\u044b\u0439, \u0432\u0442\u043e\u0440\u043e\u0439 \u0438 \u0442.\u0434.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0438\u0442 \u0443 \u0431\u0430\u0439\u0442\u0430 b, \u0435\u0441\u043b\u0438 \u043e\u043d \u0440\u0430\u0432\u0435\u043d 1, \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c <code>xor(c, a)<\/code>.<br \/>\u0415\u0441\u043b\u0438 \u0431\u044b \u043e\u043d \u0431\u044b\u043b \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0441\u043e\u0440 \u0442\u0430\u043a xor \u0441 \u043d\u0443\u043b\u0451\u043c \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0435\u0441\u043b\u0438 \u0432 \u0447\u0438\u0441\u043b\u0435 b \u0431\u0438\u0442 \u0440\u0430\u0432\u0435\u043d 0, \u0442\u043e \u0435\u0433\u043e \u0432\u043a\u043b\u0430\u0434 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0438 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0442\u044c (XOR\u0438\u0442\u044c) a \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443. \u042d\u0442\u043e \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043b\u0438 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u0432 a.<\/p>\n<pre><code class=\"cpp\">hi_bit = a &amp; 0x80;<\/code><\/pre>\n<p>0x80 \u2014 \u044d\u0442\u043e <strong>\u043c\u0430\u0441\u043a\u0430<\/strong> \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u0431\u0430\u0439\u0442\u0430, \u0442\u043e \u0435\u0441\u0442\u044c, \u0431\u0438\u0442 \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 x^7.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u043c a \u043d\u0430 1 \u0431\u0438\u0442 \u0432\u043b\u0435\u0432\u043e: \u2014 \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u0430 x, \u0447\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0430 \u043d\u0430 1. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0446\u0438\u043a\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c x \u0438\u0437 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u044f b.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u0440\u0430\u0432\u0435\u043d 1, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0441\u0434\u0432\u0438\u0433\u0430 \u043d\u0430 \u043e\u0434\u0438\u043d \u0440\u0430\u0437\u0440\u044f\u0434 \u0432\u043b\u0435\u0432\u043e \u043c\u044b \u0432\u044b\u0439\u0434\u0435\u043c \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b x^7 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c x^8, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0437\u044f\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<pre><code class=\"cpp\">if (hi_bit) a ^= 0xC3;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 <strong>\u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u0431\u044b\u043b \u0440\u0430\u0432\u0435\u043d 1<\/strong> (\u0442\u043e \u0435\u0441\u0442\u044c, \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442 \u043f\u0435\u0440\u0435\u0434 \u0441\u0434\u0432\u0438\u0433\u043e\u043c \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d), \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c <strong>XOR<\/strong> \u0441 \u043d\u0435\u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u043c 0xC3, \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043f\u043e\u043b\u0435 \u0413\u0430\u043b\u0443\u0430 GF(2^8).<\/p>\n<p>(\u041c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d 0xC3 \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u2014 \u044d\u0442\u043e 11000011, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442<br \/>  )<\/p>\n<p>\u042d\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043d\u043e \u043a\u0430\u043a\u043e\u0439 \u0435\u0441\u0442\u044c. \u041e\u043d \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d, \u0438 \u0442\u0435\u043c \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043e\u0434\u043e\u043c \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e &#8212; \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0432\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u042f \u0432\u0430\u0441 \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e. \u0421\u0430\u043c\u043e\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u043f\u043e\u0437\u0430\u0434\u0438 &#8212; \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043f\u043b\u043e\u0448\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435 ))<\/p>\n<h3>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 R<\/h3>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0434\u0432\u0438\u0433 \u0432\u043f\u0440\u0430\u0432\u043e, \u0434\u0430\u043b\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c l_vec, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 tmp \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e xor. \u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0431\u043b\u043e\u043a \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e tmp.<\/p>\n<pre><code class=\"cpp\">void R(uint8_t *block) {     cyclic_shift_right(block);     uint8_t tmp = 0; \/\/ zero or the 16th element???      for (int i = 0; i &lt; 16; i++) {         tmp ^= GF_mul(block[i], l_vec[15 - i]); \/\/ mul + xor     }      block[0] = tmp; }<\/code><\/pre>\n<pre><code class=\"cpp\">void cyclic_shift_right(uint8_t *block) {     const uint8_t last = block[BLOCK_SIZE - 1];     for (int i = BLOCK_SIZE - 1; i &gt; 0; i--) {         block[i] = block[i - 1];     }     block[0] = last; }  void cyclic_shift_left(uint8_t *block) {     const uint8_t first = block[0];     for (int i = 0; i &lt; BLOCK_SIZE - 1; i++) {         block[i] = block[i + 1];     }     block[BLOCK_SIZE - 1] = first; }<\/code><\/pre>\n<pre><code class=\"cpp\">const uint8_t l_vec[16] = {     0x94, 0x20, 0x85, 0x10, 0xC2, 0xC0, 0x01, 0xFB,     0x01, 0xC0, 0xC2, 0x10, 0x85, 0x20, 0x94, 0x01 };<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0445\u0435\u043c\u0430 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0434\u0432\u0438\u0433\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0443\u0442 \u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 R. \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 (\u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043e\u043c\u043c\u0443\u0442\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 GF \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0442\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c):<\/p>\n<pre><code class=\"cpp\">void reverse_R(uint8_t *block) {     uint8_t tmp = 0;      for (int i = 0; i &lt; 16; i++) {         tmp ^= GF_mul(block[i], l_vec[15 - i]); \/\/ mul + xor     }     block[0] = tmp;     cyclic_shift_left(block); }<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u043c\u0435\u0442\u043e\u0434 L, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 16 \u0440\u0430\u0437 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 R, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0431\u0430\u0439\u0442 \u043f\u0440\u043e\u0448\u0451\u043b \u0447\u0435\u0440\u0435\u0437 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cpp\">void L(uint8_t *block) {     for (int i = 0; i &lt; 16; i++) {         R(block);     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 F.<br \/>\u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0434\u0432\u0430 \u0431\u043b\u043e\u043a\u0430. \u041a\u0441\u043e\u0440\u0438\u0442 \u0438\u0445 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0434\u0432\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f: S \u0438 L, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438.<\/p>\n<pre><code class=\"cpp\">uint8_t* F(uint8_t *k1, uint8_t *c) {     uint8_t *tmp = xor_blocks(k1, c);     S(tmp);     L(tmp);     return tmp; }<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439.<\/p>\n<h3>\u0413\u0415\u041d\u0415\u0420\u0410\u0426\u0418\u042f \u0420\u0410\u0423\u041d\u0414\u041e\u0412\u042b\u0425 \u041a\u041b\u042e\u0427\u0415\u0419<\/h3>\n<p>\u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b. \u041e\u043d\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0413\u041e\u0421\u0422 \u043e\u043d\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c:<\/p>\n<pre><code class=\"cpp\">void gen_constants(uint8_t *constants[32]) {     for (int i = 0; i &lt; 32; i++) {         constants[i] = malloc(BLOCK_SIZE); \/\/ allocate memory         memset(constants[i], 0, BLOCK_SIZE); \/\/ zero          constants[i][15] = i + 1;         L(constants[i]);     } }<\/code><\/pre>\n<ul>\n<li>\n<p>\u0423 \u043d\u0430\u0441 \u0432\u0441\u0435\u0433\u043e 32 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0432\u0438\u0434\u0430:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cpp\">0x00, 0x00, 0x00 ... 0x00 0x00, 0x00, 0x00 ... 0x01 0x00, 0x00, 0x00 ... 0x02         .... 0x00, 0x00, 0x00 ... 0x20<\/code><\/pre>\n<ul>\n<li>\n<p>\u041a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u044d\u0442\u0438\u0445 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043e\u043a \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434 L<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0435\u0439, \u0441\u043a\u043e\u0440\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0441\u043b\u043e\u0436\u0438\u0442\u0441\u044f.<\/p>\n<pre><code class=\"cpp\">\/\/ key generation void gen_keys(uint8_t *keys[10], uint8_t *masterkey) {     uint8_t *constants[32]; \/\/ array for keys_constants     gen_constants(constants);      uint8_t *k1 = malloc(16);     uint8_t *k2 = malloc(16);      \/\/ memory copy for masterKey immutability     memcpy(k1, masterkey, 16);     memcpy(k2, masterkey + 16, 16);      keys[0] = malloc(BLOCK_SIZE);     keys[1] = malloc(BLOCK_SIZE);      memcpy(keys[0], k1, BLOCK_SIZE);     memcpy(keys[1], k2, BLOCK_SIZE);      for (int i = 0; i &lt; 32; i++) {         uint8_t *tmp = F(k1, constants[i]);         tmp = xor_blocks(tmp, k2);         k2 = k1;         k1 = tmp;          if ((i + 1) % 8 == 0) {             int a = (i + 1) \/ 4;              \/\/write a value with memcpy, cos k1 k2 still needed             keys[a] = malloc(BLOCK_SIZE);             memcpy(keys[a], k1, BLOCK_SIZE);             keys[a + 1] = malloc(BLOCK_SIZE);             memcpy(keys[a + 1], k2, BLOCK_SIZE);         }     }     for (int i = 0; i &lt; 32; i++) {         free(constants[i]);     } }<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0430\u0443\u043d\u0434\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u043c\u044b<\/p>\n<ol>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0430 \u043c\u044b<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-457209","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/457209","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=457209"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/457209\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=457209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=457209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=457209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}