Skip to content

Commit

Permalink
🗓 Dec 1, 2024 4:21:37 PM
Browse files Browse the repository at this point in the history
🐙 revert deps back for openssl
  • Loading branch information
securisec committed Dec 1, 2024
1 parent ca08a20 commit 8880ebf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
37 changes: 9 additions & 28 deletions chepy/modules/publickey.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from typing import Literal, TypeVar, Union

from ..core import ChepyCore, ChepyDecorators
from cryptography.hazmat.primitives.serialization import (
pkcs12,
Encoding,
PrivateFormat,
NoEncryption,
PublicFormat,
)
import lazy_import

RSA = lazy_import.lazy_module("Crypto.PublicKey.RSA")
Expand Down Expand Up @@ -222,27 +215,15 @@ def dump_pkcs12_cert(self, password: Union[str, bytes]) -> PublickeyT:
Chepy: The Chepy object.
"""
password = self._to_bytes(password)
key, cert, additional_certs = pkcs12.load_key_and_certificates(
self._convert_to_bytes(),
password=password,
)

private_key_pem, public_key_pem = None, None
if key:
private_key_pem = key.private_bytes(
encoding=Encoding.PEM,
format=PrivateFormat.PKCS8,
encryption_algorithm=NoEncryption(), # Use a password here if encryption is needed
)

if cert:
public_key = cert.public_key()
public_key_pem = public_key.public_bytes(
encoding=Encoding.PEM,
format=PublicFormat.SubjectPublicKeyInfo,
)

self.state = {"private": private_key_pem, "cert": public_key_pem}
pk12 = OpenSSL.crypto.load_pkcs12(self._convert_to_bytes(), password)
self.state = {
"private": OpenSSL.crypto.dump_privatekey(
OpenSSL.crypto.FILETYPE_PEM, pk12.get_privatekey()
),
"cert": OpenSSL.crypto.dump_certificate(
OpenSSL.crypto.FILETYPE_PEM, pk12.get_certificate()
),
}
return self

@ChepyDecorators.call_stack
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
base58
colorama
crccheck
cryptography==43.0.3
decorator
docstring-parser
emoji==2.0.0
Expand Down

0 comments on commit 8880ebf

Please sign in to comment.