Can I use PGP on a Photon?

Is there any possible way to use a Photon to encrypt and decrypt messages with PGP/GPG?

I’ve googled this but I haven’t found anything substantial.

I think this is technically possible (especially since the Particle Cloud handshake already uses RSA to confirm identities). I think the problems you will run into are around code space for whatever application you are try to copy or talk to.

If you google “PGP Arduino” you find people that have worked on this type of idea.

Thanks. I think was confusing RSA and PGP.

Is there a RSA library that you would recommend for the photon?

I’d like to encrypt and decrypt messages on the photon.


I just figured out mbedtls was a thing.

I’m trying to include pk.h in my firmware but I keep getting:

fatal error: pk.h: No such file or directory

If you want to use the copy in firmware/crypto/mbedtls/include/mbedtls/ then you would have to switch to monolithic building using gcc.

Your other choice is to replicate the files in your project with some loss of code space, but a gain in convenience.

Longer term if you think lots of users would want to do what you are doing, you could put in a GitHub request to have Particle add some crypto functions the HAL or dynalib so you can link against the existing code but you need to have a good case. When Particle uses mbedtls, they only use a couple of pieces of it, the rest is not linked against and therefore not in system firmware or Device OS, so having overlap would also be key.

1 Like

AFAICT the most mature encryption library for application code on Particle devices is @hirotakaster’s TlsTcpClient library (also based on mbedTLS).
If you don’t need the TCPClient stuff, you may at least be able to take some pointers from his repo.