Your task is to integrate with a remote service that works according to GOST and "only through CRYPTO-COM", and you want to use OpenSSL with gost? On the Signal-COM forum, you see heaps of messages that "keys from the CRYPTO-COM format cannot be converted to the OpenSSL-GOST-compatible format"? Actually conversion is possible.
tl; dr: http://gostcrypto.com/demo-sc-keys.html
How to convert existing keys from proprietary to orthodox format?
Go to http://gostcrypto.com/demo-sc-keys.html and specify the container files of type "mk.db3", "masks.db3", "kek.opq", "rand.opq" and the private key file by type "Keys \ 00000001.key", click "Export PrivateKey".
In the current version of gostcrypto.com, the key will not be quite PEM-compatible, since over 64 characters are used:
-----BEGIN PRIVATE KEY----- MEYCAQAwHQYGKoUDAgITMBMGByqFAwICIwEGCCqFAwcBAQICBCIEIG0GEmE3dhrHzm1KfFDpKBWEmMydwcmP0hNKvXXbEbLO -----END PRIVATE KEY-----
To make it PEM compliant, just add a new line after 64 characters:
-----BEGIN PRIVATE KEY----- MEYCAQAwHQYGKoUDAgITMBMGByqFAwICIwEGCCqFAwcBAQICBCIEIG0GEmE3dhrH zm1KfFDpKBWEmMydwcmP0hNKvXXbEbLO -----END PRIVATE KEY-----
At the time of the publication of this article, gostcrypto is not node-ficient and there is an attempt at its node-fication in a pull request. There's also a cli-utility for exporting to PEM-compatible format.
Put it and try to export the key:
sudo npm install -g https://github.com/garex/nodejs-gost-crypto/archive/nodefy.tar.gz cd /tmp wget https://www.contact-sys.com/files/redactor/files/TestContactKey.zip unzip TestContactKey.zip -d TestContactKey gost-export-signalcom-key --pse TestContactKey --key Keys/00000001.key
As a result, we get in STDOUT:
-----BEGIN PRIVATE KEY----- MEYCAQAwHQYGKoUDAgITMBMGByqFAwICIwEGCCqFAwcBAQICBCIEIG0GEmE3dhrH zm1KfFDpKBWEmMydwcmP0hNKvXXbEbLO -----END PRIVATE KEY-----
And in STDERR:
OK: Private SignalCom key successfully exported in STDOUT in "PEM" format.
Source: https://habr.com/ru/post/317406/
All Articles