Giter VIP home page Giter VIP logo

privkey's Introduction

privkey

Converts a private key CryptoPro => OpenSSL container

You need to install Strawberry perl and Visual Studio C++

Contents

  1. Download OpenSSL https://github.com/openssl/openssl/releases/tag/OpenSSL_1_1_1a and unpack it to dir "openssl-OpenSSL_1_1_1a"

  2. Compile OpenSSL via bat-file:

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
path=C:\Strawberry\perl\bin;C:\Users\D36B~1\AppData\Local\bin\NASM;%path%
perl Configure VC-WIN32 no-hw no-asm
nmake
  1. Download gost https://github.com/gost-engine/engine and unpack it to dir "engine-master"

  2. Use this bat-file to compile privkey.exe :

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
cl -DL_ENDIAN -Iopenssl-OpenSSL_1_1_1a\ms -Iopenssl-OpenSSL_1_1_1a\include -Iengine-master ^
   privkey.c ^
   engine-master\gost89.c engine-master\gosthash.c engine-master\gost_ameth.c ^
   engine-master\gost_crypt.c engine-master\gost_ctl.c engine-master\gost_asn1.c ^
   engine-master\gost_ec_sign.c engine-master\e_gost_err.c engine-master\gost_params.c ^
   engine-master\gosthash2012.c libcrypto.lib
  1. Convert CryptoPro container to OpenSSL container run:
privkey.exe a:\lp-9a0fe.000 > private.key
  1. Sign file using signer.cer and private.key:
openssl cms -sign -inkey private.key -in file.txt -CAfile CA.cer -signer signer.cer -engine gost -out file.txt.sgn -outform DER -noattr -binary
  1. Check sign file:
openssl cms -verify -content file.txt -in file.txt.sgn -CAfile CA.cer -signer signer.cer -engine gost -inform DER -noattr -binary

Executables

You can find the privkey.exe executable in the winfiles.rar arhive.
You can also compile Visual Studio 14.0 (as well as 2019) using comp_cl32.bat from winfiles.rar archive.

privkey's People

Contributors

kulikan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

privkey's Issues

privkey fails to read containers created by CryptPro 5.0

Здравствуйте, во-первых, большое спасибо за Ваш труд, статья на Хабре и эта утилита очень помогают в понимании структуры контейнеров КриптоПро.

Однако, видимо в основном из-за максимально упрощенного кода по разбору asn1, privkey не смог прочитать у меня ни одного контейнера, созданного КриптоПро 5.0.

  1. из имеющихся у меня 4-х разных файловых контейнеров КриптоПро (для типов провайдеров 75, 80 и 81) утилита не смогла сконвертировать ни один из них.
  2. изучение исходников утилиты показало, что источником проблемы является то, что утилита читает открытый и закрытый ключи по фиксированным смещениям в файлах контейнера, однако проверяемые сигнатуры по проверяемым смещениям не совпадают с ожиданиями утилиты и как результат она отказывается работать.

После изучения файлов в моих контейнерах я изменил смещение, по которому читаются ключи и после этого 3 из 4 моих контейнеров успешно прочитались и закрытый ключ из них был экспортирован. Контейнер, который по-прежнему не смог прочитаться - это единственный контейнер для КриптоПро Strong, с длиной ключа 512 бит. Все контейнеры с ключами длиной 256 бит успешно прочитались.

Возможно ли добавить полноценный asn1 парсер в privkey или как-то иначе решить проблему с чтением контейнеров КриптоПро 5.0?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.