ãã®èšäºã§ã¯ãéçº/ãã¹ãç°å¢ã§Crypto Proã®äœ¿çšãåæ¢ããBouncy Castleã«åãæ¿ããæ¹æ³ã«ã€ããŠèª¬æããŸãã
èšäºã®åé ã§ãSMEVãšãã®ã¯ã©ã€ã¢ã³ãã«ã€ããŠè©³ãã説æããŸããæåŸã«ãä»ããéå§ã§ããããã«ãã³ããŒãšè²Œãä»ããå®äºããããŒã®å€æã«ã€ããŠè©³ãã説æããŸãã
泚ç®ãéããç»åïŒ
ãããŠããã«çãïŒ
ãã£ã¹ã¯ã©ããŒ
ãã¡ãããCrypto Proã¯ãã·ã¢ã®æå·åã®èŠå¡ã§ãããããCrypto Proããéããããšã¯ã§ããŸããã 圌ã¯ç®¡èœåœå±ã®èŠä»¶ãæºãããå¥çŽããã³å¥çŽã«ç»é²ãããŠãããå šåœããä¿¡é ŒãããŠããããªã©ãªã©ã ãããã£ãŠã以äžã®ãã¹ãŠã¯ãç§ãã¡ãç§ãã¡èªèº«ã®ãã¹ã¿ãŒã§ããéçºãŸãã¯ãã¹ãç°å¢ã«é©çšãããŸãã
æè¿ãçåºéé»åçžäºäœçšã·ã¹ãã ãšé£æºãããµãŒãã¹ã®äœææ¹æ³ãç解ããå¿
èŠããããŸããã
æžããããã®ã¯ãã¹ãŠãè¡ãããäœæ¥ããå¯èœãªéãæœåºããããããããªèª¿æ»ã®çµæã«ãããŸããã ãããŠãæ¬åœã«äžãã決å®ã«ã€ããŠäœããæšæž¬ããããšããäžå¯èœã ãšç§ã¯ãã§ãã¯ããŸããã
æ¢è£œã®ã¯ã©ã€ã¢ã³ãã®å¿ èŠæ§ã®æ£åœå
ã¯ã©ã€ã¢ã³ãã®ãœãŒã¹ã³ãŒãã¯æè¡ããŒã¿ã«SMEV3ã«ãããŸãããåé¡ã¯ãããããCryptoProã«åºå®ãããŠããããšã§ãã ãœãŒã¹ã«æ瀺ãæ·»ä»ãããWordãã¡ã€ã«ã«ã¯ããããæãçŽæ¥çãªæ¹æ³ã§èšèŒãããŠããŸãã ãšã«ããããœãŒã¹ããŒãCryptoPro圢åŒã§ãã æ¬çªç°å¢ã§ã¯ããã¯æ£åžžã§ããããã¹ãç°å¢ã«ãšã£ãŠã¯éåžžã«äžäŸ¿ã§ãã ç§ã¯ãããåãé€ãããã§ãã
ãµã€ãã«ã¯ããææ°ããšãæšå¥šãã®2ã€ã®ããŒãžã§ã³ããããŸãã ãªããããªã®ãããããŠçŸåšã®ããŒãžã§ã³ãæšå¥šãããŠããããæšå¥šããŒãžã§ã³ãé¢é£ããŠããªãçç±-ããçš®ã®ã³ããŒã©ã€ã¿ãŒã®ãžã¬ã³ã:)次ã«ããé¢é£ãããã¯ã©ã€ã¢ã³ãã«ã€ããŠè©±ããŸãã
å³å¯ã«èšãã°ããœãŒã¹ã¢ãŒã«ã€ãã«ã©ã€ã»ã³ã¹ããã¹ãããªãããã䜿çšããããšã¯ã§ããŸããããããã£ãŠã掟çã©ã€ã»ã³ã¹ãã©ã®ã©ã€ã»ã³ã¹ã§é åžããã®ããæ確ã§ã¯ãããŸããã ããŒã¿ã«ã«æžããããµããŒãã®é»è©±çªå·ã«é»è©±ããããéµäŸ¿å±ã«æçŽãæžããŠãç§ã®ã¢ããªã±ãŒã·ã§ã³ãæè¡ãµããŒãã¬ãã«ãšå®è¡çµç¹ã®éãã©ã®ããã«ç§»åããããæ°é±é芳å¯ããŸããã
ã¿ã¹ã¯ã¯å®äºããŠããŸããããå®äºããŠçµäºããŠããŸããé©ãã¹ãããšã§ãã ãŸãã圌ããšå°çã«...
ã³ãŒãã§çŽæ¥äœ¿çšããããšã¯ã§ããŸããããããã¯çŽ æŽããããã¹ãã±ãŒã¹ã§ãã å®éã®ãšãããSMEVã®æ¹æ³è«çãªæšå¥šäºé ã¯ã0.5ãªããã«ãªãããŠç解ããããšã¯ã§ããŸããããŸããæ¢æã®ã©ã€ãã³ãŒãã¯ç解ãæ·±ããã®ã«éåžžã«åœ¹ç«ã¡ãŸãã
ææžåã®äž»ãªäž»åŒµã¯ãäºååŠçãšã€ã³ã¿ãŒãããäžã®ããããªèª¬æã§ãã
段èœããããã€ãã®åèªã§1ã€ã®æãäœæããã³ããŒã©ã€ã¿ãŒã«ã€ããŠã®ããŒã ãèŠããŠããŸããïŒ SMEVã®ããã¥ã¡ã³ãã®å Žåãããã¯ãããšãã°ãããã§ä»»æã®1ã€ã®ãã¬ãŒãºã«å¯Ÿãããªãã¡ã¯ã¿ãªã³ã®ãã§ãŒã³ã§ãã
ã2.ã³ã³ã·ã¥ãŒãIPã¯CMEAã«çåºéãªã¯ãšã¹ããéä¿¡ããŸããã
ã2.ã³ã³ã·ã¥ãŒãIPã¯MEISã«ãªã¯ãšã¹ããéä¿¡ããŸããã
ã2.ã³ã³ã·ã¥ãŒãIPããªã¯ãšã¹ããéä¿¡ããŸããã
ã2.æ¶è²»è
ããªã¯ãšã¹ããéä¿¡ããŸããã
ã2.æ¶è²»è
ã®èŠæ±;ã
èŠããã«ãå®æããå®è£ ãæã€ããšã¯è¯ãããšã§ãã
Crypto Pro JCPãåªããŠããçç±
- 圌ã¯åããŠããŸã
- BoncyCastleã®ãœãŒã¹ããå€æãããšãCryptoProã®ä»²éãéçºã«åå ããGOSTã«åŸã£ãŠã¢ã«ãŽãªãºã ãè¿œå ããŸãã
Crypto Pro JCPãæªã§ããçç±
- å€ãã®éçºè ãšä»®æ³ãã·ã³ãããå Žåãã©ã€ã»ã³ã¹ãè³Œå ¥ããããªã
- ãããã©ã€ãšã¿ãªã§ããããã以äžã§èª¬æãããã¹ãŠã®ãã°ãä¿®æ£ããããšã¯ã§ããŸããã ããæ£ç¢ºã«ã¯ãããã¯å¯èœã§ãïŒéã¢ã»ã³ãã©ã¯ãã¹ãªãã§æ®åœ±ããŸãïŒããéæ³ã§ããããã¹ãŠã®ä¿èšŒã倱ãããŸã-ãªãã·ã§ã³ã§ã¯ãããŸãã
- OSXã®Java 8ã§ã¯ãååŸã§ããŸããã§ããïŒJCPã®ããŒãžã§ã³ã¯ãããŸããïŒã ã»ãšãã©ã®å Žåãããã¯ããã«ä¿®æ£ãããŸãã Facebookã®ç§ã®æçš¿ã«ä»£è¡šè ãè¿ä¿¡ããŸãã
- äžè¬ã«ãOSXã§éå§ããããšã¯ã§ããŸããã§ããã ã¬ã€ç®¡çè -ããŒãã¯ãŒã«ãŒããšã©ãŒãããŒããã°ã¢ã®æçãæ©èœããŸããã
- Linuxã®ã€ã³ã¿ãŒãã§ãŒã¹ã«ããã°ããããŸã
- ãããããããWindowsã®ã€ã³ã¹ããŒã©ãŒã¯ã³ã³ãœãŒã«ã«ã¯ããæžããŸããïŒæ°ããããŒãžã§ã³ããã§ãã¯ããŸããã§ãã-ããããä¿®æ£ãããŸããïŒ
- Javaé åžãããã®ã€ã³ã¹ããŒã«ã æåŸã®æ段ã§ã¯ãJavaãããæ¹æ³ã䜿çšããŠãœãããŠã§ã¢ãã€ã³ã¹ããŒã«ããããšã¯æªã§ãããšèªèããŠããŸãããã®ããã人暩è£å€æã¯ããã³ã®ã³ã°ã䌎ã6åã®éæãåœããã¹ãã§ãã
- ãã¹ãŠã®Javaã«ããããé©çšã§ããããã§ã¯ãããŸãããçå£ã«èªåãæããããã«å¿ èŠãªéæ³ã®çµã¿åãããèŠã€ããããã§ãã çŸæç¹ã§ã¯ãææ°ããŒãžã§ã³ã®Javaã§éçºããæ°ããããŒãžã§ã³ã®ãã¹ããè¡ãããšãéèŠã§ãïŒèšäºã®å·çæç¹-JDK9ïŒããããã£ãŠãJavaã®ããŒãžã§ã³ã«å¯Ÿããå¶éã¯ãã®ãŸãŸã§ãã
- 管çããã«ãã€ã³ã¹ããŒã«ããŠå®è¡ããæ¹æ³-ã²ã©ããŽãïŒãããèŠãªããã°ãªããŸããïŒ
ãã¹ãç°å¢ã®ä»£æ¿ãšããŠãPKCS12ãŸãã¯JKSã³ã³ãããŒã§Bouncy Castleã䜿çšããããšããå§ãããŸãã ããã¯ããªãŒãã³ãœãŒã¹ã®ç¡æããã³ç¡æãœãããŠã§ã¢ã§ãã
Crypto Proã®éçºè
ã®å瞟ãšããŠã圌ãã¯ãã®éçºã«åå ããããã§ãã
Crypto Proããè±åºããããã«å®æããã¯ã©ã€ã¢ã³ãã§ä»äžããå¿ èŠããããã®
ã³ãŒãã¯æ¡åŒµæ©èœã«å¯ŸããŠéåžžã«ããããããããã«èšè¿°ãããŠãããããKeyStoreWrapperJCPã¯ã©ã¹ãåºç€ãšããŠãKeyStoreWrapperBouncyCastlePKCS12ãKeyStoreWrapperBouncyCastleJKSãåãæ¹æ³ã§èšè¿°ããããšãã§ããŸãã
DigitalSignatureFactoryãæžãæããŠããã¡ã€ã«ã·ã¹ãã äžã®æå·ã³ã³ãããŒãžã®ãã¹ãšãã®ãã¹ã¯ãŒããå ¥åãšããŠåãå ¥ãå§ããããã«ããŸãïŒCryptoProã®å Žåãããã¯åã«å¿ èŠãããŸããïŒã æå·åãããã€ããŒã®ã¿ã€ãããã§ãã¯ããã¹ã€ããããããŸããBOUNCY_JKSãBOUNCY_PKCS12ãªã©ã®ååã®å Žåãããã«2ã€ã®ã±ãŒã¹ãè¿œå ããŠãé©åãªKeyWrapperã䜿çšããŠinitXmlSecãåŒã³åºãå¿ èŠããããŸãã
initXmlSecã§ã¯ãè¿œå ããå¿
èŠããããŸã
1ïŒcryptoproã ãã§ãªããäžè¬çã«ãããããããã€ããŒãåãå
¥ããæ©èœïŒããã¯äŸ¿å©ã§ãïŒ
2ïŒSecurity.addProviderïŒæ°ããBouncyCastleProviderïŒïŒïŒ;
3ïŒXMLDSIG_SIGN_METHODã«åãæ¿ããïŒCryptoProã®å Žåãã¢ã«ãŽãªãºã ã¯ãGOST3411withGOST3410ELããšåŒã°ããBouncyCastleã¢ã«ãŽãªãºã ã¯ãGOST3411WITHECGOST3410ããšåŒã°ããŸãã
ãŸãããã®ãããªãã®ã ãã®CMEã¯ã©ã€ã¢ã³ãã®ã©ã€ã»ã³ã¹ãããã£ãŠããå ŽåãApache License 2ã®äžã«ç¹å®ã®ã³ãŒããæ·»ä»ããŸããããã¯åãªãã¢ã€ãã¢ã®ãªã¹ãã§ãã
Santuarioã§XML眲åãåæåãã
ãããããèå³æ·±ãç¹ã1ã€ãããŸãã ãããã¯ãŒã¯ã«ã¯ãSMEVã«é¢ããå€ãã®ãã³ãããããŸããããã«ã¯ãXMLekã®æå解æããã®ä»ã®ãµã³ã»ãããå«ãŸããŸãããããã¯ç§ãã¡ã®æ¹æ³ã§ã¯ãããŸããïŒã¯ã©ã€ã¢ã³ãã®äœæè ã䜿çšããæ¹æ³ã§ããããŸããïŒ
ããŒãã£ã³ã°ã§ã¯ãã²ã¹ãã«ããèªå·±çœ²åããŒã®çæãç°¡åã§ãïŒSOãžã®ã³ããŒããŒã¹ãã¯æ°ç§ã§æ€çŽ¢ãããŸãïŒã ãããã眲åãã-ããããã€ã³ã¿ãŒãããåŠçã«ãããšãBouncycastleã¯xml-signatureããµããŒãããŠããªããšèšãããŠããŸãã å ·äœçã«ã¯ãApache Santuarioã䜿çšããå Žåãsantuario-xmlsecã®XMLSignatureã¯ãxmlSignature.signïŒprivateKeyïŒãåŒã³åºããšãã«ã¡ãœãã "xmldsig-moreïŒgostr34102001-gostr3411"ãåŠçããããã«äœã䜿çšããããç解ããŸããã
å¥ã®åè«ã¯ããããã¬ãŒã®ã¹ããããééã£ãå Žæã§æ£ãããœãŒã¹ã«æã蟌ãããšã«ãã£ãŠxmlsecãåãé¢ãããšãããšãIntelliJ IDEAã³ãã¥ããã£ãŒããã°ã ãšããããšã§ãã Ideaã®ãã¹ãŠã®åççãªããŒãžã§ã³ãè©Šããã®ã§ãSportlotoã§æŠè¡çãªæçŽãæžããŠç²ç®çã«åäœããæ¹æ³ãç解ããå¿ èŠããããŸãã ããã¯ã¢ã€ãã¢ãéé£ãããã®ã§ã¯ãªããçæ³çãªããŒã«ã¯ãªããåé¡ãç解ããé床ã«åœ±é¿ããèŠå ã«ãããŸããã
åäœãããã«ã¯ã次ã®ãã®ãå¿ èŠã§ãã
1ïŒApache Santuarioã®SignatureAlgorithmSpiã®å®è£ ãå®è£ ããŸãã GetEngineUriã§æ¬¡ã®è¡ãè¿ããŸã ïŒ " http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411 "ïŒãŸãã¯ããã«ãããã®ïŒã ãããéèŠãªéæ³ã§ãã ãã®ã¯ã©ã¹ã¯ãè³¢ãããšãäžåããŠã¯ãããŸããã
ã©ã€ãã¿ã€ã ã¢ããªã±ãŒã·ã§ã³ã§1ååæåããïŒã·ã³ã°ã«ãã³Spring Beanãªã©ïŒïŒ
2ïŒJDKã«ããããé©çšããªãããã«ãããã€ããŒãããŠã³ããŒãããŸãã
Security.addProvider(new BouncyCastleProvider());
3ïŒäœæããã°ããã®ã¯ã©ã¹ãã©ã³ã¿ã€ã ã«æž¡ããŸãã
String algorithmClassName = "fully qualified name SignatureAlgorithmSpi"; Class.forName(algorithmClassName); SignatureAlgorithm.providerInit(); SignatureAlgorithm.register("http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411", algorithmClassName);
4ïŒJCEã¢ã«ãŽãªãºã ã®ãããã³ã°ã«é¢ããããã¯ïŒ
String ns = "http://www.xmlsecurity.org/NS/#configuration"; Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Element rootElement = document.createElementNS(ns, "JCEAlgorithmMappings"); Element algorithms = document.createElementNS(ns, "Algorithms");
5ïŒã¡ãœãããã¢ã«ãŽãªãºã ã«ãããã³ã°ããŸãã
Element aElem = document.createElementNS(NameSpace, "Algorithm"); aElem.setAttribute("URI", "http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411"); aElem.setAttribute("Description", "GOST R 34102001 Digital Signature Algorithm with GOST R 3411 Digest"); aElem.setAttribute("AlgorithmClass", "Signature"); aElem.setAttribute("RequirementLevel", "OPTIONAL"); aElem.setAttribute("JCEName", "GOST3411WITHECGOST3410"); algorithms.appendChild(aElem);
6ïŒãããã³ã°ãé©çšããŸãã
org.apache.xml.security.Init.init(); JCEMapper.init(rootElement);
6ïŒå©çïŒ
ãã®åŸãXMLSignatureã¯ãã®ã¡ãœãããçªç¶ç解ãå§ããxmlSignature.signãå®è¡ãå§ããŸãã
GOSTãšé£æºããããã®OpenSSLã®æºå
èšäºã®åé ã§å£ã«OpenSSLãã¶ãäžãã£ãŠããå Žåããã€ãééããªãæ®åœ±ãããŸãã
ã¯ããããã¯ãããªãããã¹ãã®å®è£
ã«å¿
èŠãªéèŠãªãã€ã³ãã§ãã
- Crypto ProããããMacã§ã¯èµ·åããªããããWindowsïŒWindows XPã§ãå¯èœïŒãæèŒããä»®æ³ãã·ã³ãšCryptãã€ã³ã¹ããŒã«ãããŠããå¿ èŠããããŸãã
- å¯èœãªéãææ°ããŒãžã§ã³ã®OpenSSLãã€ã³ã¹ããŒã«ããŸãïŒæ¢ã«GOSTããµããŒããããŠããããã«ïŒã
https://wiki.openssl.org/index.php/Binaries
https://slproweb.com/products/Win32OpenSSL.html - ã€ã³ã¹ããŒã«ãããããŒãžã§ã³ã«gost.dllãã¡ã€ã«ãããããšã確èªããŸã
- ã€ã³ã¹ããŒã«ãããOpenSSLã§ãopenssl.cfgãã¡ã€ã«ãèŠã€ããŸã
- ãã¡ã€ã«ã®æåã«æ¬¡ã®è¡ãè¿œå ããŸãã
openssl_conf = openssl_def
ãã¡ã€ã«ã®æåŸã«è¡ãè¿œå ããŸãã
[openssl_def] engines = engine_section [engine_section] gost = gost_section [gost_section] engine_id = gost dynamic_path = ./gost.dll default_algorithms = ALL CRYPT_PARAMS = id-Gost28147-89-CryptoPro-A-ParamSet
- å©ç
Crypto Proã«ããŒã®æäŸãäŸé Œããã«ã¯ã©ãããã°ããã§ããïŒå®éããããïŒã
ãã§ã«å®éã®ïŒèªå·±çœ²åã§ã¯ãªãïŒããŒãããå Žåãããããå®éã«ãã§ãã¯ããããšã¯å®å šã«éé žæ§ã§ãã ã¯ãããã¹ãã®ç®æšã«ã€ããŠè©±ããŸããããŸã ä¿¡é ŒããŠããŸããã確èªããŠãã ããïŒ
Windowsãä»®æ³ãã·ã³ã«å ¥ããŠãããã§Crypto ProãããŒã«ããããŒãã€ã³ã¹ããŒã«ããŠãšã¯ã¹ããŒãããããšãããšããšã¯ã¹ããŒã¿ãŒããšã¯ã¹ããŒã¿ãŒã®PKCS12ã§åäœããããšã¯ã¹ããŒã¿ãŒã®ä»ã®ãã¹ãŠã®æ¹åããããã¯ãããŸãïŒè±èªã®ãã°ã¬ãŒè¡šç€ºãïŒã
Googleãšã©ãŒãå
¬åŒãã©ãŒã©ã ã«ã¯äœã衚瀺ãããŸããïŒ
https://www.cryptopro.ru/forum2/default.aspx?g=posts&t=2425
ãçãã¯ã¢ã¬ã¯ã»ã€ã»ãã·ãã³ããåãåã£ãïŒ
ããã«ã¡ã¯ PKCS12ã¯ãç§å¯éµã¹ãã¬ãŒãžã«é¢ããFSBã»ãã¥ãªãã£èŠä»¶ãæºãããŠããŸããã çè«çã«ã¯ãç§å¯éµã¯ããããããªã ãŒããã«ãã¡ãã£ã¢ã«ä¿åããå¿
èŠããããŸãã å®éããã®ããããšã¯ã¹ããŒãã¯æ©èœããŸãããã
ãšã¯ã¹ããŒãçšã®GUIããããŸãããããžãã¹ããžãã¯ããããŸããã
ãããã£ãŠãã¯ãªãã¯ãããã£ãã¯ã«é¢ä¿ãªããã¬ã€ãã¹ã¿ãŒã®æåŸã®ã¹ãããã§åžžã«ãšã©ãŒãçºçããŸãã
ãªããŠæ®å¿µã ã
ç¥æ§
ãããããã¹ãŠæ®ºããŠãã ããã
æãã°ã¬ãã°ã
Crypto Proã«ããŒãäžããããšã倧ãŸãã«åŒ·å¶ããã«ã¯ã©ãããã°ããã§ãã
OpenSSLãªã©ã®æ¯èŠªã䜿çšããŠãã³ã³ããããããŒãå·®ãåŒãããã«C ++ãããŒã«ã¢ããããããšãããšãéåžžã«é·ãéèŠããããšããããŸãã ç§ã¯æ£çŽã«è©ŠããŠã¿ãŠã岩ã®äžã®è¹ã®ãããªåé¡ã«ã€ããŠcrashèœããŸããïŒå°ãªããšãããããé·ãéãã£ãŠããªã人ã«ãšã£ãŠã¯1æ¥ä»¥äžã®åé¡ã§ãïŒã åã岩ã®äžã§ã¯ã©ãã·ã¥ããã®ã¯ã€ã³ã¿ãŒãããäžã ãã§ã¯ãããŸããïŒ http : //gigamir.net/techno/pub903517
ãç®ãæ¶ãæµãåã³ã ããšããç¬éããã£ãŠããã Lissi SoftãšåŒã°ããç¹å®ã®ãªãã£ã¹ã¯ãããã2000ã«ãŒãã«ã®ç¬åµçãªãŠãŒãã£ãªãã£P12FromGostCSPãæäŸããŸãã ãã®äœæè ã¯ãã³ãã¥ããã£ãå§åããªããšããåé¡ãæã¡è² ãããPFXã®éµãåŒãè£ããŸããã åã³-ãããæ©èœããããã
æ¶ã§-ããã¯ç¬èªã®ãã®ã§ããã圌女ã®FIGã¯ãããã©ã®ããã«æ©èœããããç¥ã£ãŠããŸãã
åçã§ã¯ããªãã£ãŒãã»ã¹ããŒã«ãã³ã¯é©ããããã«ããããªãã¯æ¬åœã«å¥ã®ææè
ã®å©ããåããŠææè
ãšæŠã£ãŠããŸããïŒããšå°ããŸãã
ãã®ãããããŒã®åå ¥åã®æé ã¯æ¬¡ã®ããã«ãªããŸãã
- Crypto Pro CSPãã€ã³ã¹ããŒã«ãããŠããWindowsã§ãã¹ãŠã®ã¢ã¯ã·ã§ã³ãå®è¡ããŸãïŒä»®æ³ãã·ã³ãå®è¡ããŸãïŒã
- æ瀺ïŒãã®èšäºã§å ¥æå¯èœïŒã«åŸã£ãŠãGOSTã§OpenSSLãæºåããŸãã
- P12FromGostCSPãè³Œå ¥ããŸãã æ³£ãã
- ãœãŒã¹ããŒãCryptoProã«ã€ã³ã¹ããŒã«ããŸãïŒããã¯å¥ã®æ瀺ã«å€ããŸãããããã¯googleã§ãïŒã
- P12FromGostCSPãèµ·åããŸãïŒãã®åã«ãRichard Stallmanã®ã¢ã€ã³ã³ãããŒãã«ã®äžã«é ããŠãæææš©ãéå§ããããã«ããªããåªããªãããã«ããŸãïŒ
- ã€ã³ã¹ããŒã«ããã蚌ææžãéžæããCryptoPro蚌ææžã®ãã¹ã¯ãŒããæå®ããŸã
- PFXããŒãã¢ã®ä»»æã®æ°ãããã¹ã¯ãŒãïŒãã¹ãã¬ãŒãºïŒãæå®ãã
- ãã¡ã€ã«ãä¿åããå Žæãæå®ããŸãã p12.pfx圢åŒã§ãã¡ã€ã«ã«ååãä»ããæ¹ãè¯ãã§ãïŒããã¯ããã©ã«ãã®ååã§ãã觊ããªãæ¹ãè¯ãã§ã-ååãå€æŽãããšãã°ããããšèšãããŸãïŒ
- pemãã¡ã€ã«ãååŸããŸãã
openssl pkcs12 -in p12.pfx -out private.key.pem -name "alias"
- ïŒ-name "alias"-ãã®ãªãã·ã§ã³ã¯ãã³ã³ããå ã®ããŒã®ååãå€æŽããŸããããã¯ãP12FromGostCSPãå ã®ãšã€ãªã¢ã¹ãä¿åããã«ããŒãã©ã³ãã ã«ïŒå®éã«ã¯é çªã«ïŒåœåããããã«å¿ èŠã§ãã
- pkcs12ãã¡ã€ã«ãååŸããŸãã
openssl pkcs12 -export -out private.key.pkcs12 -in private.key.pem -name "alias"
- å®äº
èªå·±çœ²åããŒããã¹ããã
ããããã¹ãŠãã¹ãç®çã§è¡ã£ãŠãããããã¯ã©ã€ããã¯ã¹ã«éããèªåèªèº«ã«ããŒãçºè¡ãå§ããŸãã
Crypto Pro圢åŒã§ããŒãçºè¡ããæ¹æ³ã¯ãç¹ã«æ°ã«ããŸããã§ãããããã¯ãçŸåšã®ã¿ã¹ã¯ã®äžéšãšããŠåã«å¿ èŠã§ã¯ãªãããã§ãã ãã ãã念ã®ããããã®ãããªããŒãçºè¡ãããµãŒãã¹ããããŸãïŒ http : //www.cryptopro.ru/certsrv/
- Crypto Pro CSPãã€ã³ã¹ããŒã«ãããŠããWindowsã§ãã¹ãŠã®ã¢ã¯ã·ã§ã³ãå®è¡ããŸãïŒä»®æ³ãã·ã³ãå®è¡ããŸãïŒã
- ãµã€ããéããããŒã®çºè¡ã«é²ã¿ãŸãã
- ãéµãçæããŠèšŒææžèŠæ±ãéä¿¡ããããéžæããŠãã次ãžããã¯ãªãã¯ããå¿ èŠããããŸãã
- ããã®CAã«èŠæ±ãäœæããŠçºè¡ããããªã³ã¯ãã¯ãªãã¯ããŸãã
- å¿ é ãã£ãŒã«ãã«å ¥åããŸãã
- [çºè¡]ãã¿ã³ãæŒãããŠããŸãã
- 蚌ææžãã€ã³ã¹ããŒã«ããŸãã
JKSã³ã³ããã®åé¡
ãã®è³ªåã¯ã€ã³ã¿ãŒãããäžã§åºãè¡šçŸãããŠãããããããã«StackoverflowãèŠãããšãã§ããŸãã
http://stackoverflow.com/questions/14580340/generate-gost-34-10-2001-keypair-and-save-it-to-some-keystore
ãšã«ããBouncy Castleã䜿çšããã®ã§ãããã䜿çšããŠããŒãçæã§ããŸãã
ãã®ã³ãŒãã¯æãçæ³çã§ã¯ãããŸããããå®éã«æ©èœããå®è£
ãæäŸããŸãïŒå®éã«ã¯ã䟿å©ãªã€ã³ã¿ãŒãã§ãŒã¹ãäœæããããã«ããã€ãã®ãã«ã¯ã¯ã©ã¹ãååŸããŸããïŒ
Security.addProvider( new org.bouncycastle.jce.provider.BouncyCastleProvider() ); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance( "ECGOST3410", "BC" ); keyPairGenerator.initialize( new ECGenParameterSpec( "GostR3410-2001-CryptoPro-A" ) ); KeyPair keyPair = keyPairGenerator.generateKeyPair(); org.bouncycastle.asn1.x500.X500Name subject = new org.bouncycastle.asn1.x500.X500Name( "CN=Me" ); org.bouncycastle.asn1.x500.X500Name issuer = subject; // self-signed BigInteger serial = BigInteger.ONE; // serial number for self-signed does not matter a lot Date notBefore = new Date(); Date notAfter = new Date( notBefore.getTime() + TimeUnit.DAYS.toMillis( 365 ) ); org.bouncycastle.cert.X509v3CertificateBuilder certificateBuilder = new org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder( issuer, serial, notBefore, notAfter, subject, keyPair.getPublic() ); org.bouncycastle.cert.X509CertificateHolder certificateHolder = certificateBuilder.build( new org.bouncycastle.operator.jcajce.JcaContentSignerBuilder( "GOST3411withECGOST3410" ) .build( keyPair.getPrivate() ) ); org.bouncycastle.cert.jcajce.JcaX509CertificateConverter certificateConverter = new org.bouncycastle.cert.jcajce.JcaX509CertificateConverter(); X509Certificate certificate = certificateConverter.getCertificate( certificateHolder ); KeyStore keyStore = KeyStore.getInstance( "JKS" ); keyStore.load( null, null ); // initialize new keystore keyStore.setEntry( "alias", new KeyStore.PrivateKeyEntry( keyPair.getPrivate(), new Certificate[] { certificate } ), new KeyStore.PasswordProtection( "entryPassword".toCharArray() ) ); keyStore.store( new FileOutputStream( "test.jks" ), "keystorePassword".toCharArray()
PKCS12ã³ã³ãããŒã®åé¡
JKSãçºè¡ããããã®ã·ã³ãã«ã§äŸ¿å©ãªæ¹æ³ããã§ã«ãããJKS for Javaãæããã€ãã£ããªãœãªã¥ãŒã·ã§ã³ã§ãããããååãšããŠããã¯ç¹ã«å¿ èŠã§ã¯ãããŸããã ããããå®å šãæãããã«ãããããããŠãã ããã
- æ瀺ïŒãã®èšäºã§å ¥æå¯èœïŒã«åŸã£ãŠãGOSTã§OpenSSLãæºåããŸãã
- 蚌ææžçœ²åãªã¯ãšã¹ã+ç§å¯éµãäœæããŸãïŒå¿
èŠãªéµæ
å ±ãå
¥åããŠãã ããïŒïŒïŒ
openssl req -newkey gost2001 -pkeyopt paramset:A -passout pass:aofvlgzm -subj "/C=RU/ST=Moscow/L=Moscow/O=foo_bar/OU=foo_bar/CN=developer/emailAddress=olegchiruhin@gmail.com" -keyout private.key.pem -out csr.csr
- ç§å¯éµã§çœ²åããŸãïŒWindowsã§ã¯ããã®æäœã¯ç®¡çè
æš©éã§å®è¡ããå¿
èŠããããŸããããããªããšãããã©ã³ãã ãªç¶æ
ããæžã蟌ããŸããããšãããšã©ãŒã§å€±æããŸãïŒã
openssl x509 -req -days 365 -in csr.csr -signkey private.key.pem -out crt.crt
- å
¬ééµãååŸïŒ
openssl x509 -inform pem -in crt.crt -pubkey -noout > public.key.pem
- GOST2001-md_gost94 hexïŒå¿
èŠãªå ŽåïŒïŒ
openssl.exe dgst -hex -sign private.key.pem message.xml
- MIMEã¢ããªã±ãŒã·ã§ã³/ x-pkcs7-signatureïŒå¿
èŠãªå ŽåïŒïŒ
openssl smime -sign -inkey private.key.pem -signer crt.crt -in message.xml
- pemãpkcs12ã«å€æããŸãã
openssl pkcs12 -export -out private.key.pkcs12 -in private.key.pem -name "alias"
ãŸãšã
äžèšã®ãã¹ãŠã®ã¢ã¯ã·ã§ã³ã®çµæãšããŠãCrypto Proã®éãè² æ ãåãé€ãæ¯èŒçç°¡åãªæ¹æ³ãåŸãããŸããã
å°æ¥çã«ã¯ãæçµçãªåå©ã®åã«é£²ã¿ç©ãæ±ããŠéäºãç¶ããããšæããŸãããã¹ãŠã®ãŠãŒãã£ãªãã£ãããŒãžã§ãã¬ãŒã¿ãèªäœã®smevã¯ã©ã€ã¢ã³ããªã©ãGithubã®1ã€ã®ãªããžããªã®åœ¢ã«é 眮ããŸãã ããã§ããå ¬åŒã®SMEVã¯ã©ã€ã¢ã³ãã®èš±å®¹ã©ã€ã»ã³ã¹ã®äžã§ä¿®æ£ããã³é åžããæš©å©ãåãåããããšæããŸãã ããããã°ããã®èšäºã®ååã¯åã«äžèŠã«ãªããGithubããå¿ èŠãªã³ãŒããããŠã³ããŒãããããšã§åé¡ã解決ããŸãã