Use conditional compilation for cryptographic functions.
[tinc] / src / openssl / rsagen.c
index 0f4a4fa..3a8c8ad 100644 (file)
@@ -1,6 +1,6 @@
 /*
     rsagen.c -- RSA key generation and export
-    Copyright (C) 2008 Guus Sliepen <guus@tinc-vpn.org>
+    Copyright (C) 2008-2013 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#include "system.h"
+#include "../system.h"
 
 #include <openssl/pem.h>
 #include <openssl/err.h>
 
-#include "logger.h"
-#include "rsagen.h"
+#define __TINC_RSA_INTERNAL__
+typedef RSA rsa_t;
+
+#include "../logger.h"
+#include "../rsagen.h"
 
 /* This function prettyprints the key generation process */
 
@@ -63,21 +66,16 @@ static void indicator(int a, int b, void *p) {
 
 // Generate RSA key
 
-bool rsa_generate(rsa_t *rsa, size_t bits, unsigned long exponent) {
-       *rsa = RSA_generate_key(bits, exponent, indicator, NULL);
-
-       return *rsa;
+rsa_t *rsa_generate(size_t bits, unsigned long exponent) {
+       return RSA_generate_key(bits, exponent, indicator, NULL);
 }
 
 // Write PEM RSA keys
 
 bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) {
-       PEM_write_RSAPublicKey(fp, *rsa);
-
-       return true;
+       return PEM_write_RSAPublicKey(fp, rsa);
 }
 
 bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) {
-       PEM_write_RSAPrivateKey(fp, *rsa, NULL, NULL, 0, NULL, NULL);
-       return true;
+       return PEM_write_RSAPrivateKey(fp, rsa, NULL, NULL, 0, NULL, NULL);
 }