Skip to content

Initial Code #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
Aug 20, 2019
Merged

Initial Code #1

merged 49 commits into from
Aug 20, 2019

Conversation

brentru
Copy link
Member

@brentru brentru commented Aug 19, 2019

CircuitPython_RSA is a port of Python-RSA, a pure-Python RSA implementation.

Modifications from initial library.

  • The command-line-specific (utils.py) tools have been removed from the library to save space.
  • CPython Logging has been replaced with the Adafruit CircuitPython Logger Module.
  • Miller–Rabin Primality test algorithm modified to support library's fast_pow, CircuitPython's pow() does not support modular exponentiation.
  • adafruit_rsa/tools added, pure-python binascii, warnings, and hashlib modules.

Support for:

  • RSA Key pair (private/public) generation
  • Message encryption and decryption
  • Signature creation and verification
    • w/SHA-256, SHA-384, SHA-512

Examples are provided for signature creation/verification, keypair generation and encryption/decryption, and a unit-test-like for testing future modifications to this library.

brentru and others added 30 commits July 30, 2019 14:13
…TE: this implementation does not have SHA1
…ve sha1 reference, add mit license to top of init
…so far until a pyasn1 lib exists for circuitpython
@brentru brentru requested a review from a team August 19, 2019 15:53
Copy link
Member

@ladyada ladyada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm dya want to split hashlib out? i think that would be useful separate rather than embedded?

@brentru
Copy link
Member Author

brentru commented Aug 19, 2019

@ladyada I could split hashlib out - I held off splitting it off since it'll eventually be a core module. Should I also bring binascii out as well so we have pure-python versions of these two modules? TheJWT module, and prob. a lot of future modules currently depends on the hashlib and binascii from this library, for example.

@brentru
Copy link
Member Author

brentru commented Aug 20, 2019

@ladyada Removed the adafruit_rsa/tools/ folder. Hashlib and binascii have been split out into new repositories. Adafruit_RSA has been modified to reflect these changes.

Replaced tools/warnings.py with the circuitpython logger module, instead of warnings.

Updated code successfully passes tests

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit PyPortal with samd51j20

soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Testing: <function test_encrypt_decrypt at 0x20003400>
2314.25: DEBUG - find_p_q(128): Finding p
2316.53: DEBUG - find_p_q(128): Finding q
OK!
Testing: <function test_mod_msg at 0x200033e0>
2317.87: DEBUG - find_p_q(128): Finding p
2318.51: DEBUG - find_p_q(128): Finding q
OK!
Testing: <function test_randomness at 0x200033f0>
2322.82: DEBUG - find_p_q(128): Finding p
2325.37: DEBUG - find_p_q(128): Finding q
OK!
Testing: <function test_sign_verify_sha256 at 0x20003410>
2329.66: DEBUG - find_p_q(248): Finding p
2356.35: DEBUG - find_p_q(248): Finding q
OK!
Testing: <function test_sign_verify_sha384 at 0x20003460>
2376.34: DEBUG - find_p_q(312): Finding p
2449.32: DEBUG - find_p_q(312): Finding q
OK!
Testing: <function test_sign_verify_sha512 at 0x20003510>
2530.8: DEBUG - find_p_q(376): Finding p
2586.87: DEBUG - find_p_q(376): Finding q
OK!
Ran 6 tests in 283.514 seconds

@brentru brentru merged commit f253a47 into adafruit:master Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants