From 52261db09ef9dbf5abc95baed22722c5c332f9f7 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 20 Jun 2006 17:33:26 +0000 Subject: Pulling OpenSSL 0.9.8b into trunk svn path=/openssl/trunk; revision=3 --- openssl/trunk/demos/maurice/loadkeys.c | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 openssl/trunk/demos/maurice/loadkeys.c (limited to 'openssl/trunk/demos/maurice/loadkeys.c') diff --git a/openssl/trunk/demos/maurice/loadkeys.c b/openssl/trunk/demos/maurice/loadkeys.c new file mode 100644 index 00000000..82fd22a9 --- /dev/null +++ b/openssl/trunk/demos/maurice/loadkeys.c @@ -0,0 +1,72 @@ +/* NOCW */ +/* + Please read the README file for condition of use, before + using this software. + + Maurice Gittens January 1997 + +*/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +EVP_PKEY * ReadPublicKey(const char *certfile) +{ + FILE *fp = fopen (certfile, "r"); + X509 *x509; + EVP_PKEY *pkey; + + if (!fp) + return NULL; + + x509 = PEM_read_X509(fp, NULL, 0, NULL); + + if (x509 == NULL) + { + ERR_print_errors_fp (stderr); + return NULL; + } + + fclose (fp); + + pkey=X509_extract_key(x509); + + X509_free(x509); + + if (pkey == NULL) + ERR_print_errors_fp (stderr); + + return pkey; +} + +EVP_PKEY *ReadPrivateKey(const char *keyfile) +{ + FILE *fp = fopen(keyfile, "r"); + EVP_PKEY *pkey; + + if (!fp) + return NULL; + + pkey = PEM_read_PrivateKey(fp, NULL, 0, NULL); + + fclose (fp); + + if (pkey == NULL) + ERR_print_errors_fp (stderr); + + return pkey; +} + + -- cgit v1.2.3