Skip to content

Commit

Permalink
πŸ“… Commit Tue, 6 Jul 2021 09:34:40
Browse files Browse the repository at this point in the history
πŸ› update readthedocs
🚧 3.4.0
✨ generate_ecc_keypair
βœ… tests added/updated
  • Loading branch information
securisec committed Jul 6, 2021
1 parent ff64956 commit ea3aad3
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
image: latest

python:
version: 3.7
version: '3.8'
install:
- method: pip
path: .
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

![](https://github.com/securisec/chepy/workflows/tests/badge.svg)
![](https://img.shields.io/travis/com/securisec/chepy?logo=travis)
[![](https://img.shields.io/docker/cloud/build/securisec/chepy?logo=docker)](https://hub.docker.com/r/securisec/chepy)
<!-- [![](https://img.shields.io/docker/cloud/build/securisec/chepy?logo=docker)](https://hub.docker.com/r/securisec/chepy) -->

[![](https://img.shields.io/readthedocs/chepy.svg?logo=read-the-docs&label=Docs)](http://chepy.readthedocs.io/en/latest/)
[![](https://img.shields.io/pypi/v/chepy.svg?logo=pypi&label=pypi)](https://pypi.python.org/pypi/chepy)
Expand Down
9 changes: 5 additions & 4 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ Code:
New ideas:
☐ rubber ducky encode/decode
☐ save registers https://t.co/pBNRufibY8?amp=1
βœ” convert to nato alphabets: a = alpha, b = bravo
☐ cbor encode/decode https://github.com/agronholm/cbor2 (plugin)
☐ fuzzy search
βœ” rsa sign/verify
βœ” rsa generate random key (private and public)
βœ” rsa encrypt/decrpt
βœ” ecc generate
☐ pgp, generate, encrypt, decrypt, verify
☐ swap little and big endian

Expand Down Expand Up @@ -49,6 +46,10 @@ Misc:
☐ cyberchef recipe to chepy recipe converter

Archive:
βœ” convert to nato alphabets: a = alpha, b = bravo @project(New ideas)
βœ” rsa sign/verify @project(New ideas)
βœ” rsa generate random key (private and public) @project(New ideas)
βœ” rsa encrypt/decrpt @project(New ideas)
βœ” sqlite plugin @project(Plugins)
βœ” base 16 @project(Methods)
βœ” protobuf plugin @project(Plugins)
Expand Down
2 changes: 1 addition & 1 deletion chepy/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "3.3.0" # pragma: no cover
__version__ = "3.4.0" # pragma: no cover
__author__ = "Hapsida @securisec" # pragma: no cover
2 changes: 1 addition & 1 deletion chepy/chepy_plugins
Submodule chepy_plugins updated 1 files
+1 βˆ’1 .readthedocs.yml
22 changes: 22 additions & 0 deletions chepy/modules/publickey.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lazy_import

RSA = lazy_import.lazy_module("Crypto.PublicKey.RSA")
ECC = lazy_import.lazy_module("Crypto.PublicKey.ECC")
OpenSSL = lazy_import.lazy_module("OpenSSL")

from ..core import ChepyCore, ChepyDecorators
Expand Down Expand Up @@ -248,3 +249,24 @@ def generate_rsa_keypair(
priv = key.exportKey(passphrase=passphrase, format=format)
self.state = {"public": pub, "private": priv}
return self

@ChepyDecorators.call_stack
def generate_ecc_keypair(
self,
curve: Literal['p256', 'p384', 'p521'] = 'p256',
format: Literal["PEM", "DER"] = "PEM"
) -> PublickeyT:
"""Generate RSA key pair
Args:
curve (Literal[, optional): Curve for keys. Defaults to p256.
format (Literal[, optional): Output format type. Defaults to 'PEM'.
Returns:
Chepy: The Chepy object.
"""
key = ECC.generate(curve=curve)
pub = key.public_key().export_key(format=format)
priv = key.export_key(format=format)
self.state = {"public": pub, "private": priv}
return self
3 changes: 2 additions & 1 deletion chepy/modules/publickey.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ..core import ChepyCore
from typing import Any, TypeVar
from typing import Any, Literal, TypeVar

RSA: Any
OpenSSL: Any
Expand All @@ -17,3 +17,4 @@ class Publickey(ChepyCore):
def parse_private_pem(self: PublickeyT) -> PublickeyT: ...
def dump_pkcs12_cert(self: PublickeyT, password: str) -> PublickeyT: ...
def generate_rsa_keypair(self: PublickeyT, bits:int=..., format:str=..., passphrase:str=...) -> PublickeyT: ...
def generate_ecc_keypair(self: PublickeyT, curve:Literal['p256', 'p384', 'p521']=..., format:Literal['PEM', 'DER']=...) -> PublickeyT: ...
6 changes: 6 additions & 0 deletions tests/test_publickey.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,9 @@ def test_generate_rsa_keypair():
k = Chepy("").generate_rsa_keypair().o
assert b"PUBLIC" in k["public"]
assert b"PRIVATE" in k["private"]


def test_generate_ecc_keypair():
k = Chepy("").generate_ecc_keypair().o
assert "PUBLIC" in k["public"]
assert "PRIVATE" in k["private"]

0 comments on commit ea3aad3

Please sign in to comment.