dmazzella / ucrypto

Micropython package for doing fast rsa and elliptic curve cryptography, specifically digital signatures
31 stars 11 forks source link

RSA worked for me on Pico W fairly quickly with bits=512 and using the default example #5

Closed sgbaird closed 1 year ago

sgbaird commented 1 year ago

I copied https://github.com/dmazzella/ucrypto/tree/master/modules/ufastrsa and https://github.com/dmazzella/ucrypto/blob/master/modules/functools.py into lib and ran a slightly modified version of the example from the README:

from ufastrsa.rsa import RSA, genrsa

def main():

    bits = 512
    print("RSA bits", bits)
    r = RSA(*genrsa(bits, e=65537))
    if r:
        print("RSA OK")
        data = b"a message to sign and encrypt via RSA"
        print("random data len:", len(data), data)
        assert r.pkcs_verify(r.pkcs_sign(data)) == data
        print("pkcs_verify OK")
        assert r.pkcs_decrypt(r.pkcs_encrypt(data)) == data
        print("pkcs_decrypt OK")

if __name__ == "__main__":
    main()

Thank you for the straightforward solution! xref https://github.com/orgs/micropython/discussions/10048#discussioncomment-4202935

dmazzella commented 1 year ago

@sgbaird Thank you for you report on this 👍🏻