Skip to main content

No project description provided

Project description

Библиотека для работы с Cryptopro CSP в python

Установка

  • Установить КриптоПро CSP.

  • Установить пакеты lsb-cprocsp-devel-.noarch.rpm и cprocsp-pki-amd64-cades.rpm из состава КриптоПро ЭЦП SDK.

  • При необходимости, создать симлинк:

ln -s /opt/cprocsp/lib/amd64/libcades.so.2.0.0 /opt/cprocsp/lib/amd64/libcades.so

Пример установки пакетов можно посмотреть в pycryptoprosdk/compose/Dockerfile.

  • Установить pycryptoprosdk:

pip install pycryptoprosdk

Примеры использования

from pycryptoprosdk import CryptoProSDK


sdk = CryptoProSDK()


# верификация отсоединенной подписи:
with open('doc.txt', 'rb') as f:
    content = b64encode(f.read())

with open('doc.txt.sig', 'rb') as f:
    signature = b64encode(f.read())

res = sdk.verify_detached(content, signature)


# создание хэша файла алгоритмом ГОСТ Р 34.11-94:
with open('doc.txt'), 'rb') as f:
    content = f.read()
h = sdk.create_hash(content, alg='CALG_GR3411')


# поиск сертификата в хранилище MY по отпечатку:
cert = sdk.get_cert_by_thumbprint('MY', '046255290b0eb1cdd1797d9ab8c81f699e3687f3')


# поиск сертификата по имени:
cert = sdk.get_cert_by_subject('MY', 'CRYPTO-PRO Test Center 2')


# установка сертификата в хранилище MY:
with open('certificate.cer'), 'rb') as f:
    cert_content = f.read()
sdk.install_certificate('MY', b64encode(cert_content))


# удаление сертификата из хранилища MY по отпечатку:
sdk.delete_certificate('MY', '9e78a331020e528c046ffd57704a21b7d2241cb3')


# извлечение сертификата подписанта из подписи:
with open('signature.sig', 'rb') as f:
    signature_content = f.read()
cert = sdk.get_signer_cert_from_signature(signature_content)

Сборка образа и запуск тестов

docker-compose up --build --force-recreate

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycryptoprosdk-0.1.5.tar.gz (10.3 kB view details)

Uploaded Source

File details

Details for the file pycryptoprosdk-0.1.5.tar.gz.

File metadata

  • Download URL: pycryptoprosdk-0.1.5.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.2

File hashes

Hashes for pycryptoprosdk-0.1.5.tar.gz
Algorithm Hash digest
SHA256 3aa110aec6d32350f6498118e7b727b3afbbee28e71495a0fadb9082f536d747
MD5 55363ab61c58ba0059c0bd2a28fd4cd2
BLAKE2b-256 b6145ec9a3e9d9c59c30f7fa042df510cbfc671c2cffee92c4d5707aa989e01a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page