Browse Source

Verschlüsselung berichtigt

Kolja Strohm 7 years ago
parent
commit
0e456684a3
1 changed files with 17 additions and 7 deletions
  1. 17 7
      Update/PSKlient.cpp

+ 17 - 7
Update/PSKlient.cpp

@@ -3,6 +3,7 @@
 #include <Datei.h>
 #include <Zeit.h>
 #include <InitDatei.h>
+#include "Keys.h"
 
 // Inhalt der PSKlient Klasse aus PSKlient.h
 // Konstruktor
@@ -23,8 +24,6 @@ PSKlient::PSKlient()
 	dat->lese( schlüssel, schlüsselLän );
 	dat->close();
 	dat = dat->release();
-	unsigned char tmp[ 20 ] = { 102, 139, 140, 143, 52, 52, 194, 167, 97, 106, 23, 72, 170, 121, 213, 178, 28, 28, 124, 185 };
-	memcpy( stdSchlüssel, tmp, 20 );
 	fehler = new Text();
 	ref = 1;
 }
@@ -74,9 +73,14 @@ bool PSKlient::verbinde()
 			msIp[ i ] = ipT->getText()[ i ];
 		ipT->release();
 		klient = new Klient();
-		unsigned char msSchlüssel[ 20 ] = { 199, 164, 172, 55, 246, 16, 155, 8, 151, 176, 250, 181, 227, 133, 30, 41, 200, 26, 7, 151 };
-		klient->setSendeKey( (char*)msSchlüssel, 20 );
-		klient->setEmpfangKey( (char*)msSchlüssel, 20 );
+        char *key;
+        int length;
+        Keys::getServerKey( &key, length, Keys::MAIN, Keys::SENDEN );
+        klient->setSendeKey( key, length );
+        delete[] key;
+        Keys::getServerKey( &key, length, Keys::MAIN, Keys::EMPFANGEN );
+        klient->setEmpfangKey( key, length );
+        delete[] key;
 		if( !klient->verbinde( msPort, msIp ) )
 		{
 			fehler->setText( "Fehler beim verbinden mit dem Main Server. Bitte versuche es Später erneut." );
@@ -174,8 +178,14 @@ bool PSKlient::verbinde( int port, const char *ip )
 		unlock();
 		return 0;
 	}
-	klient->setSendeKey( (char*)stdSchlüssel, 20 );
-	klient->setEmpfangKey( (char*)stdSchlüssel, 20 );
+    char *key;
+    int length;
+    Keys::getServerKey( &key, length, Keys::PATCH, Keys::SENDEN );
+	klient->setSendeKey( key, length );
+    delete[] key;
+    Keys::getServerKey( &key, length, Keys::PATCH, Keys::EMPFANGEN );
+    klient->setEmpfangKey( key, length );
+    delete[] key;
 	klient->sende( "\0", 1 ); // Verschlüsselung aktivieren
 	klient->sendeEncrypted( "\1", 1 );
 	klient->sendeEncrypted( (char*)&id, 4 );