Search code examples
cgnupg

Using GPG with C?


I am writing a communication program in C and I am looking for the best way to use GnuPG encryption. I am already using symmetric encryption algorithms via the mcrypt library but wish to incorporate some public-key capabilities, preferably using GnuPG if possible. Is there a good library available to accomplish this? Would it be better to try to interact with GPG itself directly via the program to accomplish this? Any insight would be appreciated as I would like to keep this implementation as clean as possible. Thanks.


Solution

  • Unfortunately, GnuPG is designed to be used interactively, and not as an API.

    You mention that you are looking to incorporate some public-key capabilities. SSL and TLS are alternatives to GPG which see much more frequent use.

    If public-key capabilities in general are what you seek, GnuTLS is an API for use in network based programs that provides exactly what you want. It enjoys a great deal of support, and provides SSL and TLS public-key encryption capabilities.

    However, if you are dead set on using GPG, GPGME is a project that exists to wrap an API around GPG. I have not used it and cannot advise on its use, but suspect that it may be somewhat forced.