{"id":272226,"date":"2016-01-15T21:46:02","date_gmt":"2016-01-15T18:46:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=272226"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=272226","title":{"rendered":"\u0427\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 OpenSSL"},"content":{"rendered":"<p>       \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u0444\u0430\u0439\u043b\u0430\u0445 primary.key, masks.key \u0438 header.key, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0445\u0445\u0445\u0445\u0445.000 \u043d\u0430 \u0444\u043b\u0435\u0448\u043a\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 \u043a\u0440\u0438\u043f\u0442\u043e\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043a\u0440\u0438\u043f\u0442\u043e\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e, \u0444\u043e\u0440\u043c\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d. \u0426\u0435\u043b\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0442\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 OpenSSL. \u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0435 \u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u0432\u0438\u0434\u0430 (primary_key XOR masks_key) \u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c (raw) \u0432\u0438\u0434\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0437\u0430\u0431\u0435\u0433\u0430\u044f \u0432\u043f\u0435\u0440\u0435\u0434, \u043c\u043e\u0436\u043d\u043e \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c 2000 (\u0434\u0432\u0443\u0445 \u0442\u044b\u0441\u044f\u0447) \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u044b <a href=\"http:\/\/soft.lissi.ru\/downloads\/\">P12FromGostCSP<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 P12, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 OpenSSL, \u043d\u043e \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:   <\/p>\n<ul>\n<li>\u0427\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u0447\u0435\u0440\u0435\u0437 \u043a\u0440\u0438\u043f\u0442\u043e\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043c, \u0433\u0434\u0435 \u043a\u0440\u043e\u043c\u0435 OpenSSL \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043a\u043b\u044e\u0447\u0430 \u043d\u0435 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e, \u0447\u0442\u043e \u043a\u043b\u044e\u0447 \u00ab\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439\u00bb, \u0442\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/li>\n<li>\u0412 \u0434\u0435\u043c\u043e \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043a\u043b\u044e\u0447\u043e\u043c, \u044d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/li>\n<\/ul>\n<h1>\u0424\u0430\u0439\u043b primary.key<\/h1>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 32 \u0431\u0430\u0439\u0442\u0430 \u043a\u043b\u044e\u0447\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Asn1. \u042d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043a\u043b\u044e\u0447\u0430, \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e Q \u043d\u0430 \u043c\u0430\u0441\u043a\u0443. \u041f\u043e\u043b\u0435, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0435 \u043c\u043e\u0434\u0443\u043b\u044c Q \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 OpenSSL \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 order. \u041c\u0430\u0441\u043a\u0430 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0444\u0430\u0439\u043b\u0435 masks.key<br \/>  <img decoding=\"async\" alt=\"primary.key\" src=\"https:\/\/habrastorage.org\/files\/0aa\/ee2\/1ef\/0aaee21ef1774fd790b79cdaa1aa6bf3.png\"\/><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h1>\u0424\u0430\u0439\u043b masks.key<\/h1>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 32 \u0431\u0430\u0439\u0442\u0430 \u043c\u0430\u0441\u043a\u0438 \u043a\u043b\u044e\u0447\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Asn1, \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u043a\u043b\u044e\u0447\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f pwd_key. \u0414\u0430\u043b\u0435\u0435 12 \u0431\u0430\u0439\u0442 \u00ab\u0437\u0430\u0442\u0440\u0430\u0432\u043e\u0447\u043d\u043e\u0439\u00bb \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f pwd_key, \u0435\u0441\u043b\u0438 \u043a\u0440\u0438\u043f\u0442\u043e\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0437\u0430\u0449\u0438\u0449\u0435\u043d \u043f\u0430\u0440\u043e\u043b\u0435\u043c, \u0442\u043e \u043f\u0430\u0440\u043e\u043b\u044c \u0442\u0430\u043a\u0436\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. <\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430 (\u0438\u043c\u0438\u0442\u043e\u0437\u0430\u0449\u0438\u0442\u0430) 4 \u0431\u0430\u0439\u0442\u0430. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0443\u0442\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u044b\u0445 8 \u0431\u0430\u0439\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043f\u043e\u043b\u0435\u043c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 header.key<br \/>  <img decoding=\"async\" alt=\"masks.key\" src=\"https:\/\/habrastorage.org\/files\/675\/6dc\/117\/6756dc11714849d6a26ffdca792675bd.png\"\/><\/p>\n<h1>\u0424\u0430\u0439\u043b header.key<\/h1>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 CryptoProParamSet (\u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u043e \u043a\u0440\u0430\u0441\u043d\u044b\u043c).  <\/p>\n<ul>\n<li>GostR3410_2001_CryptoPro_A_ParamSet \u2014 1.2.643.2.2.35.1<\/li>\n<li>GostR3410_2001_CryptoPro_B_ParamSet \u2014 1.2.643.2.2.35.2<\/li>\n<li>GostR3410_2001_CryptoPro_C_ParamSet \u2014 1.2.643.2.2.35.3<\/li>\n<li>GostR3410_2001_CryptoPro_XchA_ParamSet \u2014 1.2.643.2.2.36.0<\/li>\n<li>GostR3410_2001_CryptoPro_XchB_ParamSet \u2014 1.2.643.2.2.36.1<\/li>\n<\/ul>\n<p>  \u0410 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0432\u044b\u0435 8 \u0431\u0430\u0439\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 (\u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u043e) \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e.<br \/>  <img decoding=\"async\" alt=\"header.key\" src=\"https:\/\/habrastorage.org\/files\/bbb\/049\/353\/bbb049353e3048fd84751d45cdcdfc84.png\"\/><\/p>\n<h1>\u0427\u0438\u0442\u0430\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c<\/h1>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0430\u0439\u043b privkey.c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt;  #include &lt;openssl\/pem.h&gt; #include &lt;openssl\/cms.h&gt; #include &lt;openssl\/err.h&gt; #include &quot;gost_lcl.h&quot;  \/* Convert little-endian byte array into bignum *\/ BIGNUM *reverse32bn(char *b, BN_CTX *ctx) { \tBIGNUM *res; \tchar buf[32]; \tBUF_reverse(buf, b, 32); \tres = BN_bin2bn(buf, 32, BN_CTX_get(ctx)); \tOPENSSL_cleanse(buf, sizeof(buf)); \treturn res; }  void xor_material(char *buf36, char *buf5C, char *src) { \tint i; \tfor(i = 0; i &lt; 32; i++) \t{ \t\tbuf36[i] = src[i] ^ 0x36; \t\tbuf5C[i] = src[i] ^ 0x5C; \t} }  int make_pwd_key(char *result_key, char *start12, int start12_len, char *passw) { \tint result; \tint i; \tchar pincode4[1024]; \tint pin_len; \tchar current[32]; \tchar material36[32]; \tchar material5C[32]; \tchar hash_result[32]; \tgost_hash_ctx ctx; \tinit_gost_hash_ctx(&ctx, &GostR3411_94_CryptoProParamSet); \tmemset(pincode4, 0, sizeof(pincode4)); \tpin_len = strlen(passw); \tif (pin_len*4 &gt; sizeof(pincode4)) {\tresult = 1;\tgoto err; } \tfor(i = 0; i &lt; pin_len; i++) \t\tpincode4[i*4] = passw[i];  \tstart_hash(&ctx); \thash_block(&ctx, start12, start12_len); \tif (pin_len)  \t\thash_block(&ctx, pincode4, pin_len * 4); \tfinish_hash(&ctx, hash_result);  \tmemcpy(current, (char*)&quot;DENEFH028.760246785.IUEFHWUIO.EF&quot;, 32);  \tfor(i = 0; i &lt; (pin_len?2000:2); i++) \t{ \t\txor_material(material36, material5C, current); \t\tstart_hash(&ctx); \t\thash_block(&ctx, material36, 32); \t\thash_block(&ctx, hash_result, 32); \t\thash_block(&ctx, material5C, 32); \t\thash_block(&ctx, hash_result, 32); \t\tfinish_hash(&ctx, current); \t}  \txor_material(material36, material5C, current);  \tstart_hash(&ctx); \thash_block(&ctx, material36, 32); \thash_block(&ctx, start12, start12_len); \thash_block(&ctx, material5C, 32); \tif (pin_len)  \t\thash_block(&ctx, pincode4, pin_len * 4); \tfinish_hash(&ctx, current);  \tstart_hash(&ctx); \thash_block(&ctx, current, 32); \tfinish_hash(&ctx, result_key);  \tresult = 0; \/\/ok err: \treturn result; }  BIGNUM *decode_primary_key(char *pwd_key, char *primary_key, BN_CTX *bn_ctx) { \tBIGNUM *res; \tchar buf[32]; \tgost_ctx ctx; \tgost_init(&ctx, gost_cipher_list-&gt;sblock); \tgost_key(&ctx, pwd_key); \tgost_dec(&ctx, primary_key, buf, 4); \tres = reverse32bn(buf, bn_ctx); \tOPENSSL_cleanse(buf, sizeof(buf)); \treturn res; }  BIGNUM *remove_mask_and_check_public(char *oid_param_set8, BIGNUM *key_with_mask, BIGNUM *mask, char *public8, BN_CTX *ctx) { \tint result; \tEC_KEY *eckey = NULL; \tconst EC_POINT *pubkey; \tconst EC_GROUP *group; \tBIGNUM *X, *Y, *order, *raw_secret, *mask_inv; \tchar outbuf[32], public_X[32]; \tASN1_OBJECT *obj; \tint nid;  \torder = BN_CTX_get(ctx); \tmask_inv = BN_CTX_get(ctx); \traw_secret = BN_CTX_get(ctx); \tX = BN_CTX_get(ctx); \tY = BN_CTX_get(ctx); \tif (!order || !mask_inv || !raw_secret || !X || !Y) { result = 1; goto err; }  \tobj = ASN1_OBJECT_create(0, oid_param_set8+1, *oid_param_set8, NULL, NULL); \tnid = OBJ_obj2nid(obj); \tASN1_OBJECT_free(obj);  \tif (!(eckey = EC_KEY_new())) { result = 1; goto err; } \tif (!fill_GOST2001_params(eckey, nid)) { result = 1; goto err; } \tif (!(group = EC_KEY_get0_group(eckey))) { result = 1; goto err; } \tif (!EC_GROUP_get_order(group, order, ctx)) { result = 1; goto err; }  \tif (!BN_mod_inverse(mask_inv, mask, order, ctx)) { result = 1; goto err; } \tif (!BN_mod_mul(raw_secret, key_with_mask, mask_inv, order, ctx)) { result = 1; goto err; }  \tif (!EC_KEY_set_private_key(eckey, raw_secret)) { result = 1; goto err; } \tif (!gost2001_compute_public(eckey)) { result = 1; goto err; } \tif (!(pubkey = EC_KEY_get0_public_key(eckey))) { result = 1; goto err; } \tif (!EC_POINT_get_affine_coordinates_GFp(group, pubkey, X, Y, ctx)) { result = 1; goto err; }  \tstore_bignum(X, outbuf, sizeof(outbuf)); \tBUF_reverse(public_X, outbuf, sizeof(outbuf)); \tif (memcmp(public_X, public8, 8) != 0) { result = 1; goto err; }  \tresult = 0; \/\/ok err: \tif (eckey) EC_KEY_free(eckey); \tif (result == 0) return raw_secret; \treturn NULL; }  int file_length(char *fname) { \tint len; \tFILE *f = fopen(fname, &quot;rb&quot;); \tif (f == NULL) return -1; \tfseek(f, 0, SEEK_END); \tlen = ftell(f); \tfclose(f); \treturn len; }  int read_file(char *fname, int start_pos, char *buf, int len) { \tint read_len; \tFILE *f = fopen(fname, &quot;rb&quot;); \tif (f == NULL) return 1; \tif (start_pos) fseek(f, start_pos, SEEK_SET); \tread_len = fread(buf, 1, len, f); \tfclose(f); \tif (read_len != len) return 1; \treturn 0; \/\/ok }  int get_asn1_len(unsigned char *buf, int *size_hdr) { \tint n, i, res; \tint pos = 0; \tif ((buf[pos]&0x80) == 0) { \t\t*size_hdr = 1; \t\treturn buf[pos]; \t} \tn = buf[pos++]&0x7f; \tres = 0; \tfor(i = 0; i &lt; n; i++) { \t\tres = res*256 + buf[pos++]; \t} \t*size_hdr = n+1; \treturn res; }  #define MAX_HEADER 20000 int read_container(char *fpath, int flag2, char *salt12, char *primary_key, char *masks_key, char *public8, char *oid_param_set8) { \tint result; \tchar primary_path[1024+30]; \tchar masks_path[1024+30]; \tchar header_path[1024+30]; \tchar header_buf[MAX_HEADER]; \tint header_len; \tint i, len, pos, size_hdr;  \tif (strlen(fpath)&gt;1024) { result = 1; goto err; }  \tsprintf(header_path, &quot;%s\/header.key&quot;, fpath); \tif (flag2 == 0) \t{ \t\tsprintf(primary_path, &quot;%s\/primary.key&quot;, fpath); \t\tsprintf(masks_path, &quot;%s\/masks.key&quot;, fpath); \t} \telse \t{ \t\tsprintf(primary_path, &quot;%s\/primary2.key&quot;, fpath); \t\tsprintf(masks_path, &quot;%s\/masks2.key&quot;, fpath); \t}  \tif (read_file(primary_path, 4, primary_key, 32)) { result = 1; goto err; } \tif (read_file(masks_path, 4, masks_key, 32)) { result = 1; goto err; } \tif (read_file(masks_path, 0x26, salt12, 12)) { result = 1; goto err; }  \theader_len = file_length(header_path); \tif (header_len &lt; 0x42 || header_len &gt; MAX_HEADER) { result = 1; goto err; } \tif (read_file(header_path, 0, header_buf, header_len)) { result = 1; goto err; }  \/\/------------- skip certificate --------------------------- \tpos = 0; \tfor(i = 0; i &lt; 2; i++) \t{ \t\tget_asn1_len(header_buf+pos+1, &size_hdr); \t\tpos += size_hdr+1; \t\tif (pos &gt; header_len-8) { result = 2; goto err; } \t}  \/\/------------------ get oid_param_set8 ----------------------- #define PARAM_SET_POS 34 \tif (memcmp(header_buf+pos+PARAM_SET_POS, &quot;\\x6\\x7&quot;, 2) != 0) { result = 2; goto err; } \tmemcpy(oid_param_set8, header_buf+pos+PARAM_SET_POS+1, 8);  \/\/------------------ get public8 ----------------------- \tresult = 2; \/\/not found \tpos += 52; \tfor(i = 0; i &lt; 3; i++) \t{ \t\tlen = get_asn1_len(header_buf+pos+1, &size_hdr); \t\tif (len == 8 && memcmp(header_buf+pos, &quot;\\x8a\\x8&quot;, 2) == 0) \t\t{ \t\t\tmemcpy(public8,header_buf+pos+2,8); \t\t\tresult = 0; \/\/ok \t\t\tbreak; \t\t} \t\tpos += len+size_hdr+1; \t\tif (pos &gt; header_len-8) { result = 2; goto err; } \t} err: \tOPENSSL_cleanse(header_buf, sizeof(header_buf)); \treturn result; }  #define START_OID 0x12 #define START_KEY 0x28 unsigned char asn1_private_key[72] = { \t0x30,0x46,2,1,0,0x30,0x1c,6,6,0x2a,0x85,3,2,2,0x13,0x30,0x12,6,7,0x11, \t0x11,0x11,0x11,0x11,0x11,0x11,6,7,0x2a,0x85,3,2,2,0x1e,1,4,0x23,2,0x21,0 };  int main(int argc, char **argv) { \tint result; \tchar *container_path; \tchar *passw; \tchar salt12[12]; \tchar primary_key[32]; \tchar masks_key[32]; \tchar public8[8]; \tchar oid_param_set8[8]; \tBN_CTX *ctx; \tBIGNUM *key_with_mask; \tBIGNUM *mask; \tBIGNUM *raw_key; \tchar pwd_key[32]; \tchar outbuf[32];  \tctx = BN_CTX_new();  \tif (argc == 2) \t{ \t\tcontainer_path = argv[1]; \t\tpassw = &quot;&quot;; \t} \telse \tif (argc == 3) \t{ \t\tcontainer_path = argv[1]; \t\tpassw = argv[2]; \t} \telse \t{ \t\tprintf(&quot;get_private container_path [passw]\\n&quot;); \t\tresult = 1; \t\tgoto err; \t}  \tif (read_container(container_path, 0, salt12, primary_key, masks_key, public8, oid_param_set8) != 0 && \t\tread_container(container_path, 1, salt12, primary_key, masks_key, public8, oid_param_set8) != 0) \t{ \t\tprintf(&quot;can not read container from %s\\n&quot;, container_path); \t\tresult = 2; \t\tgoto err; \t}  \tmake_pwd_key(pwd_key, salt12, 12, passw); \tkey_with_mask = decode_primary_key(pwd_key, primary_key, ctx); \tOPENSSL_cleanse(pwd_key, sizeof(pwd_key)); \tmask = reverse32bn(masks_key, ctx); \traw_key = remove_mask_and_check_public(oid_param_set8, key_with_mask, mask, public8, ctx);  \tif (raw_key) \t{ \t\tBIO *bio; \t\tstore_bignum(raw_key, outbuf, sizeof(outbuf)); \t\tmemcpy(asn1_private_key+START_OID, oid_param_set8, 8); \t\tmemcpy(asn1_private_key+START_KEY, outbuf, 32); \t\t\/\/bio = BIO_new_file(&quot;private.key&quot;, &quot;w&quot;); \t\tbio = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT); \t\tPEM_write_bio(bio, &quot;PRIVATE KEY&quot;, &quot;&quot;, asn1_private_key, sizeof(asn1_private_key)); \t\tBIO_free(bio); \t\tOPENSSL_cleanse(outbuf, sizeof(outbuf)); \t\tOPENSSL_cleanse(asn1_private_key, sizeof(asn1_private_key)); \t\tresult = 0; \/\/ok \t} \telse \t{ \t\tprintf(&quot;Error check public key\\n&quot;); \t\tresult = 3; \t}  err: \tBN_CTX_free(ctx); \tOPENSSL_cleanse(salt12, sizeof(salt12)); \tOPENSSL_cleanse(primary_key, sizeof(primary_key)); \tOPENSSL_cleanse(masks_key, sizeof(masks_key)); \treturn result; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 3 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u044e\u0447 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 12-\u0442\u0438 \u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0439 \u00ab\u0441\u043e\u043b\u0438\u00bb \u0438 \u043f\u0430\u0440\u043e\u043b\u044f.  <\/p>\n<pre><code class=\"cpp\">make_pwd_key(pwd_key, salt12, 12, passw); <\/code><\/pre>\n<p>  2. \u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 \u043a\u043b\u044e\u0447\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f.  <\/p>\n<pre><code class=\"cpp\">key_with_mask = decode_primary_key(pwd_key, primary_key, ctx); <\/code><\/pre>\n<p>  3. \u0414\u0435\u043b\u0438\u043c \u043a\u043b\u044e\u0447 \u0441 \u043c\u0430\u0441\u043a\u043e\u0439 \u043d\u0430 \u043c\u0430\u0441\u043a\u0443.   <\/p>\n<pre><code class=\"cpp\">raw_key = remove_mask_and_check_public(oid_param_set8, key_with_mask, mask, public8, ctx); <\/code><\/pre>\n<p>  \u041d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 OpenSLL \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0432\u0437\u044f\u0442\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c.  <\/p>\n<pre><code class=\"cpp\">if (!BN_mod_inverse(mask_inv, mask, order, ctx)) { result = 1; goto err; } if (!BN_mod_mul(raw_secret, key_with_mask, mask_inv, order, ctx)) { result = 1; goto err; } <\/code><\/pre>\n<h1>\u0421\u0431\u043e\u0440\u043a\u0430 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430<\/h1>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u0431\u043e\u0440\u043a\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u043b\u044f Linux \u0432\u0435\u0440\u0441\u0438\u0438. <\/p>\n<p>  \u0412\u0435\u0440\u0441\u0438\u044e \u0434\u043b\u044f Windows \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/cloud.mail.ru\/public\/HYAi\/LMK6PKgLF\">\u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043e\u0442\u0441\u044e\u0434\u0430<\/a> \u0442\u0430\u043c \u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <a href=\"https:\/\/downloads.embarcadero.com\/free\/c_builder\">Borland C++ 5.5<\/a><\/p>\n<h3>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f OpenSSL \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 <a href=\"https:\/\/github.com\/openssl\/openssl\">\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f<\/a> \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 openssl \u0432 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"cpp\">.\/config make <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 libcrypto.a \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. <br \/>  \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 engines\/ccgost \u0438 include.<\/p>\n<h3>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f privkey.c<\/h3>\n<p>  <\/p>\n<pre><code class=\"cpp\">gcc -o privkey -Iengines\/ccgost -Iinclude privkey.c libcrypto.a -pthread -ldl <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 private.key<\/h3>\n<p>  <\/p>\n<pre><code class=\"cpp\">.\/privkey \/mnt\/usbflash\/lp-9a0fe.000 <\/code><\/pre>\n<p>  \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432 \u043a\u0440\u0438\u043f\u0442\u043e\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 lp-9a0fe.000, \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 signer.cer \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/cloud.mail.ru\/public\/HYAi\/LMK6PKgLF\">\u0432\u0437\u044f\u0442\u044c \u043e\u0442\u0441\u044e\u0434\u0430<\/a><\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b:  <\/p>\n<pre><code class=\"cpp\">-----BEGIN PRIVATE KEY----- MEYCAQAwHAYGKoUDAgITMBIGByqFAwICJAAGByqFAwICHgEEIwIhAKzsrv\/l1Uwk uzph\/LQN9mux0Jz0yaW21kOYEFv0Xyut -----END PRIVATE KEY----- <\/code><\/pre>\n<p>  C\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 private.key<\/p>\n<h3>\u041f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c private.key \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 file.txt<\/h3>\n<p>  <\/p>\n<pre><code class=\"cpp\">openssl cms -sign -inkey private.key -in file.txt -CAfile CA.cer -signer signer.cer -engine gost -out test.sign -outform DER -noattr -binary <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u044c<\/h3>\n<p>  <\/p>\n<pre><code class=\"cpp\">openssl cms -verify -content file.txt -in test.sign -CAfile CA.cer -signer signer.cer -engine gost -inform DER -noattr -binary <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e!<br \/>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u042d\u0442\u043e \u0431\u044b\u043b\u0430 \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0445\u0430\u0431\u0440\u0435.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/275039\/\"> http:\/\/habrahabr.ru\/post\/275039\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043e \u0444\u0430\u0439\u043b\u0430\u0445 primary.key, masks.key \u0438 header.key, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0445\u0445\u0445\u0445\u0445.000 \u043d\u0430 \u0444\u043b\u0435\u0448\u043a\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 \u043a\u0440\u0438\u043f\u0442\u043e\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043a\u0440\u0438\u043f\u0442\u043e\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e, \u0444\u043e\u0440\u043c\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d. \u0426\u0435\u043b\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0442\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 OpenSSL. \u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0435 \u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u0432\u0438\u0434\u0430 (primary_key XOR masks_key) \u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c (raw) \u0432\u0438\u0434\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0437\u0430\u0431\u0435\u0433\u0430\u044f \u0432\u043f\u0435\u0440\u0435\u0434, \u043c\u043e\u0436\u043d\u043e \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0438\u0437 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c 2000 (\u0434\u0432\u0443\u0445 \u0442\u044b\u0441\u044f\u0447) \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u044b <a href=\"http:\/\/soft.lissi.ru\/downloads\/\">P12FromGostCSP<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 P12, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 OpenSSL, \u043d\u043e \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:   <\/p>\n<ul>\n<li>\u0427\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u0447\u0435\u0440\u0435\u0437 \u043a\u0440\u0438\u043f\u0442\u043e\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043c, \u0433\u0434\u0435 \u043a\u0440\u043e\u043c\u0435 OpenSSL \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043a\u043b\u044e\u0447\u0430 \u043d\u0435 \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e, \u0447\u0442\u043e \u043a\u043b\u044e\u0447 \u00ab\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439\u00bb, \u0442\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/li>\n<li>\u0412 \u0434\u0435\u043c\u043e \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u043a\u043b\u044e\u0447\u043e\u043c, \u044d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/li>\n<\/ul>\n<h1>\u0424\u0430\u0439\u043b primary.key<\/h1>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u0442 32 \u0431\u0430\u0439\u0442\u0430 \u043a\u043b\u044e\u0447\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Asn1. \u042d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043a\u043b\u044e\u0447\u0430, \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e Q \u043d\u0430 \u043c\u0430\u0441\u043a\u0443. \u041f\u043e\u043b\u0435, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0435 \u043c\u043e\u0434\u0443\u043b\u044c Q \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 OpenSSL \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 order. \u041c\u0430\u0441\u043a\u0430 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0444\u0430\u0439\u043b\u0435 masks.key<br \/>  <img decoding=\"async\" alt=\"primary.key\" src=\"https:\/\/habrastorage.org\/files\/0aa\/ee2\/1ef\/0aaee21ef1774fd790b79cdaa1aa6bf3.png\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-272226","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272226","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=272226"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272226\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}