X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet.c;h=d89c7c6f0c51de45cf032611849654129604c1e9;hp=538584ddcb9f645c6271d523f71c77d3f350d801;hb=a0f7af3ed79c55d9680cbb0a569b3c8987581d43;hpb=2293304748f7e4e9a18ee848b8264bdecebae37f diff --git a/src/net.c b/src/net.c index 538584dd..d89c7c6f 100644 --- a/src/net.c +++ b/src/net.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.c,v 1.35.4.84 2000/11/30 22:33:16 zarq Exp $ + $Id: net.c,v 1.35.4.86 2000/11/30 23:18:19 zarq Exp $ */ #include "config.h" @@ -59,6 +59,12 @@ # include #endif +#ifdef HAVE_OPENSSL_PEM_H +# include +#else +# include +#endif + #ifdef HAVE_TUNTAP #include LINUX_IF_TUN_H #endif @@ -692,18 +698,43 @@ cp return 0; } +int read_rsa_public_key(RSA **key, const char *file) +{ + FILE *fp; + + if((fp = fopen(file, "r")) == NULL) + { + syslog(LOG_ERR, _("Error reading RSA public key file `%s': %m"), + file); + return -1; + } + if(PEM_read_RSAPublicKey(fp, key, NULL, NULL) == NULL) + { + syslog(LOG_ERR, _("Reading RSA private key file `%s' failed: %m"), + file); + return -1; + } + + return 0; +} + int read_rsa_private_key(RSA **key, const char *file) { FILE *fp; if((fp = fopen(file, "r")) == NULL) { - syslog(LOG_ERR, _("Error reading RSA key file `%s': %m"), + syslog(LOG_ERR, _("Error reading RSA private key file `%s': %m"), file); return -1; } if(PEM_read_RSAPrivateKey(fp, key, NULL, NULL) == NULL) - return -1; + { + syslog(LOG_ERR, _("Reading RSA private key file `%s' failed: %m"), + file); + return -1; + } + return 0; } @@ -719,13 +750,7 @@ int read_rsa_keys(void) myself->rsa_key = RSA_new(); - if(read_rsa_private_key(&(myself->rsa_key), cfg->data.ptr) < 0) - { - syslog(LOG_ERR, _("Reading RSA private key file `%s' failed: %m"), - cfg->data.ptr); - return -1; - } - return 0; + return read_rsa_private_key(&(myself->rsa_key), cfg->data.ptr); } /* @@ -766,15 +791,7 @@ cp return -1; } cp - if(!(cfg = get_config_val(myself->config, config_publickey))) - { - syslog(LOG_ERR, _("Public key for tinc daemon required!")); - return -1; - } - else - { - BN_hex2bn(&myself->rsa_key->n, cfg->data.ptr); - } + /* if(RSA_check_key(myself->rsa_key) != 1) {