r2924 - in trunk/libmcrypto: include/libmcrypto/openssl source/openssl

mikma at minisip.org mikma at minisip.org
Sat Nov 18 11:17:54 CET 2006


Author: mikma
Date: 2006-11-18 11:17:53 +0100 (Sat, 18 Nov 2006)
New Revision: 2924

Modified:
   trunk/libmcrypto/include/libmcrypto/openssl/ZrtpDH.h
   trunk/libmcrypto/source/openssl/ZrtpDH.cxx
Log:
Move implementation of some ZrtpDH methods from .h to .cxx.
Don't include openssl headers directly in ZrtpDH.h


Modified: trunk/libmcrypto/include/libmcrypto/openssl/ZrtpDH.h
===================================================================
--- trunk/libmcrypto/include/libmcrypto/openssl/ZrtpDH.h	2006-11-17 20:32:32 UTC (rev 2923)
+++ trunk/libmcrypto/include/libmcrypto/openssl/ZrtpDH.h	2006-11-18 10:17:53 UTC (rev 2924)
@@ -27,11 +27,6 @@
 
 #include <stdint.h>
 
-#include <openssl/crypto.h>
-#include <openssl/bn.h>
-#include <openssl/rand.h>
-#include <openssl/dh.h>
-
 /**
  * Implementation of Diffie-Helman for ZRTP
  *
@@ -40,21 +35,22 @@
  * the ZRTP specification we use the MODP groups as defined by RFC3526 for
  * length 3072 and 4096.
  */
+
 class LIBMCRYPTO_API ZrtpDH {
     
 private:
-    DH *ctx;
+    void *priv;
     
 public:
     ZrtpDH(int32_t pkLength);
     ~ZrtpDH();
 
-    int32_t generateKey()                { return DH_generate_key(ctx); };
-    int32_t getSecretSize()              { return DH_size(ctx); };
-    int32_t getPubKeySize()              { return BN_num_bytes((ctx->pub_key)); };
-    int32_t getPubKeyBytes(uint8_t *buf) { return BN_bn2bin(ctx->pub_key, buf); };
+    int32_t generateKey();
+    int32_t getSecretSize();
+    int32_t getPubKeySize();
+    int32_t getPubKeyBytes(uint8_t *buf);
     int32_t computeKey(uint8_t *pubKeyBytes, int32_t length, uint8_t *secret);
-    void random(uint8_t *buf, int32_t length) { RAND_bytes(buf, length); };
+    void random(uint8_t *buf, int32_t length);
 };
 
 #endif // ZRTPDH_H

Modified: trunk/libmcrypto/source/openssl/ZrtpDH.cxx
===================================================================
--- trunk/libmcrypto/source/openssl/ZrtpDH.cxx	2006-11-17 20:32:32 UTC (rev 2923)
+++ trunk/libmcrypto/source/openssl/ZrtpDH.cxx	2006-11-18 10:17:53 UTC (rev 2924)
@@ -34,6 +34,8 @@
 // #include <libmcrypto/init.h>
 #include <libmcrypto/ZrtpDH.h>
 
+#define ctx ((DH*)priv)
+
 static BIGNUM *bnP3072 = NULL;
 static BIGNUM *bnP4096 = NULL;
 
@@ -136,7 +138,7 @@
 	dhinit = 1;
     }
 
-    ctx = DH_new();
+    priv = DH_new();
 
     ctx->g = BN_new();
     BN_set_word(ctx->g, DH_GENERATOR_2);
@@ -171,3 +173,23 @@
 
     return result;
 }
+
+int32_t ZrtpDH::generateKey() {
+	return DH_generate_key(ctx);
+}
+
+int32_t ZrtpDH::getSecretSize() {
+	return DH_size(ctx);
+}
+
+int32_t ZrtpDH::getPubKeySize() {
+	return BN_num_bytes((ctx->pub_key));
+}
+
+int32_t ZrtpDH::getPubKeyBytes(uint8_t *buf) {
+	return BN_bn2bin(ctx->pub_key, buf);
+}
+
+void ZrtpDH::random(uint8_t *buf, int32_t length) {
+	RAND_bytes(buf, length);
+}



More information about the Minisip-devel mailing list