adafruit / Adafruit_CircuitPython_HTTPServer

Simple HTTP Server for CircuitPython
MIT License
46 stars 30 forks source link

rsa message receiver example #89

Closed FoamyGuy closed 8 months ago

FoamyGuy commented 8 months ago

This example loads a public key from a JSON file and serves it to the front end in a cookie. Front end uses the JSEncrypt library to encrypt a message with the public key and POST it to the back end. Server then loads the matching private key from another json file and decrypts the message that was received.

My testing was on feather ESP32S3 TFT

michalpokusa commented 8 months ago

Maybe it is only me, but in my opinion it would be better to make a article about it like with this.

I am not sure but 11 files with 3.5k lines for a single example seems like a bit too much. Also, currently each example shows a general use case of the lib itself, while this is very specific use case, down to even particular JS lib.

FoamyGuy commented 8 months ago

I think it's still a fairly simple example that illustrates a specific thing. It's not really made for a particular JS lib, theoretically any front end library that supports RSA would work, even the built-in functions should work but they're limited to HTTPS only. JSEncrypt just happens to be the first one I found that I could get working. I would have linked it via CDN if I could have but I was unable to work out the correct way to do it with the import / export modules used for some of the other older utilities that JSEncrypt makes use of, there is probably still a way to do that it's just beyond my JS knowledge at the moment. I'll give it another go eventually because it would be quite nice not to have to include (or serve!) those other files from the microcontroller.

I'm not sure there is really enough of a project for a full Learn Guide and I don't think I'm a good person to try to explain the fundamentals of public key encryption to an audience of beginners who would be likely to find it in a Learn guide. Perhaps it's a good fit for the playground portion of the learn system, I may add to there at some point but for the time being I don't have any other longer form copy or information to go along with it so it would basically end up just being the code embedded with little else.

In any case I've closed this and moved the code into my own repo for now.