Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Public key implementation in C for Linux

I'm trying to use public key crypto to sign and later verify a file. The file is a simple plaintext file that contains user information for authoring purposes.

I tried different sites for a C implementation of a public key crypto algorithm but I haven't found anything. A lot of sites point to using certificates (x.509, etc) but that is way beyond what I need. I am just looking for a way to generate and public and private keys and use a relatively well known algorithm to sign and verify a file.

Any pointers to a pure C implementation out there? The focus is on code that I can reuse and not external libs. The main problem being that I don't want to have to link against a full lib and its dependencies in order to have a very basic public key system.

Thanks.

like image 410
Mr Aleph Avatar asked Dec 01 '22 06:12

Mr Aleph


2 Answers

OpenSSL is a very good package. You can just use the crypto library portion, which provides basic RSA implementations. That might be in line with what you are looking for.

Cryptlib is another alternative that could work for you. It has some strange licensing issues though, so consider those depending on how you will be using it.

Crypto++ is a set of different crypto technologies, and includes RSA, so you might try that.

Finally, RSA is not terribly complex to implement, so you could even implement it yourself using GMP, which provides the necessary mathematical functions you would need.

like image 97
samoz Avatar answered Dec 22 '22 03:12

samoz


You may want to look at the well-respected, debugged, and tested OpenSSL libraries. Although OpenSSL is primarily for SSL/TLS networking, it contains extremely good implementations of many cryptographic protocols, which are often used by themselves for general cryptography.

Hope this helps!

like image 24
templatetypedef Avatar answered Dec 22 '22 04:12

templatetypedef