Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PinkSign – a friendly Python library for NPKI (공동인증서, 구 공인인증서) certificates 🔑

License

Notifications You must be signed in to change notification settings

bandoche/PyPinkSign

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

185 Commits

Repository files navigation

PyPinkSign

Python code for PKI certificate. 공인인증서(공동인증서)를 다루는 파이썬 코드입니다.

Status

Build codecov

Support method

  • Load personal purpose of PKI a.k.a "NPKI" or "공동인증서 (formerly 공인인증서)"
  • Encrypt, Decrypt, Sign, Verify (part of Public-key cryptography)
  • Get Details (Valid date, Serial number, CN)
  • PKCS#7 sign

Usage example

Load public key file and private key file.

import pypinksign
p = pypinksign.PinkSign()
p.load_pubkey(pubkey_path="/path/signCert.der")
p.load_prikey(prikey_path="/path/signPri.key", prikey_password=b"my-0wn-S3cret")
sign = p.sign(b'1') 
verify = p.verify(sign, b'1') # True

Load specific certificate. (by CN)

import pypinksign
# choose_cert function automatically fetch path for certificates
# and load certificate which match CN and passpharase for Private Key
p = pypinksign.choose_cert(cn="홍길순", pw=b"i-am-h0ng")
sign = p.sign(b'1') 
verify = p.verify(sign, b'1') # True
envelop = p.pkcs7_signed_msg(b'message') # PKCS7 signed with K-PKI

Load PFX(p12) certificate.

import pypinksign
# choose_cert function automatically fetch path for certificates
# and load certificate which match DN and passpharase for Private Key
p = pypinksign.PinkSign(p12_path="홍길순.pfx", prikey_password=b"i-am-h0ng")
sign = p.sign(b'1') 
verify = p.verify(sign, b'1') # True
envelop = p.pkcs7_enveloped_msg(b'message') # Envelop with K-PKI - Temporary removed

Requirement & Dependency

  • Python 3.8 or above
  • PyASN1 for pyasn1
  • cryptography for cryptography.hazmat
  • OpenSSL 1.1.1 or above due to cryptography package

Installation

The easiest way to get PyPinkSign is pip

pip install pypinksign

The current development version can be found at http://github.com/bandoche/pypinksign/tarball/main

Changelog

v0.5.4 (2025年10月17日)

  • Update dependency (cryptography>=46.0.3) to include latest security patches and compatibility updates.
  • Require OpenSSL 3.0.0 or newer.
  • Add Python 3.14 support.

v0.5.3 (2025年02月22日)

  • Update dependency (cryptography==44.0.1) to resolves multiple vulnerabilities.
  • Update dependency (pyasn1==0.6.1) to support recent python versions.
  • Update cryptography deprecations. (move SEED algo, use not_valid_before/after_utc) (thanks to kerokim)
  • Drop Python 3.7 support.

v0.5.2 (2024年12月21日)

  • Update dependency (cryptography==42.0.8) to resolves multiple vulnerabilities.

v0.5.1 (2022年11月02日)

  • Update dependency (cryptography==38.0.3) which resolves CVE-2022-3602 and CVE-2022-3786.

v0.5.0 (2022年01月18日)

  • Upgrade dependency. (cryptography==36.0.1)
  • Fix file handle leakage.

v0.4.5 (2020年12月03日)

  • Fix import path issue. (thanks to Gyong1211)

v0.4.4 (2020年12月03日)

  • Fix CRT related param error.
  • Remove PyOpenSSL dependency.
  • Remove old OpenSSL version dependency with pure SEED implementation.
    • If SEED algorithm is not supported by local OpenSSL, use python version of SEED algorithm automatically.

v0.4.3 (2020年02月26日)

  • Fix seed_generator to generate bytes.

v0.4.2 (2020年02月26日)

  • Test code fix.

v0.4.1 (2020年02月26日)

  • Add PKCS7 sign message.

v0.4 (2020年02月26日)

  • Drop Python 2 support.
  • Support Python 3.6 or above.
  • Add type hinting.
  • Add test code.
  • Add PBKDF2 for support PBES2 private key. (by [yongminz])
  • Add function to inject r (rand num) value to private key.
  • Update pyasn1 to 0.4.8.
  • Update cryptography to 2.8.
  • Update pyOpenSSL to 19.1.0.
  • Temporary remove enveloping function.

v0.3 (2017年03月14日)

  • Add support for PFX (PKCS 12).
  • Add PyOpenSSL module for PFX support.
  • Remove PBKDF1 module.

v0.2.3 (2016年09月19日)

  • Update cryptography dependency version to 1.5.

v0.2.2 (2016年07月25日)

  • You can load private key file from string.
  • Update Docstring format.

v0.2.1 (2016年06月23日)

  • Bug fix.

v0.2 (2016年06月21日)

  • Add function for get serial number of cert.
  • Remove README.rst in repository.

v0.1.1 (2015年06月07日)

  • Add README.rst for PyPI.

v0.1 (2015年06月07日)

  • First release.

Thanks to

See also

About

PinkSign – a friendly Python library for NPKI (공동인증서, 구 공인인증서) certificates 🔑

Topics

Resources

License

Stars

Watchers

Forks

Contributors 5

Languages

AltStyle によって変換されたページ (->オリジナル) /