From 55ce6b85ad01889bfe73647c6776e43c467ca3f2 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 12 May 2015 01:48:36 +0200 Subject: [PATCH] Added more debug stuff + $content needs to be a package hash generated for. Signed-off-by: Roland Haeder --- .../hub/main/package/class_NetworkPackage.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index 46c0e311e..291b8e578 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -659,6 +659,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R ); // Hash content and sender id together, use scrypt + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $senderId . ',content()=' . strlen($content)); $hash = Scrypt::hashScrypt($senderId . ':' . $content . ':' . $this->determineSenderPrivateKeyHash($data)); // Return it @@ -675,6 +676,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ private function isPackageHashValid (array $decodedArray) { // Check validity + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE])); //* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE)); $isHashValid = Scrypt::checkScrypt($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH]); @@ -700,7 +702,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('content(' . strlen($content) . ')=' . $content); // ... and compress it - $content = $this->getCompressorInstance()->compressStream($content); + $compressed = $this->getCompressorInstance()->compressStream($content); // Add magic in front of it and hash behind it, including BASE64 encoding $packageContent = sprintf(self::PACKAGE_MASK, @@ -708,8 +710,8 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->getCompressorInstance()->getCompressorExtension(), // - separator self::PACKAGE_MASK_SEPARATOR, - // 2.) Raw package content, encoded with BASE64 - base64_encode($content), + // 2.) Compressed raw package content, encoded with BASE64 + base64_encode($compressed), // - separator self::PACKAGE_MASK_SEPARATOR, // 3.) Tags @@ -717,7 +719,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R // - separator self::PACKAGE_MASK_SEPARATOR, // 4.) Checksum - $this->getHashFromContent($content) + $this->getHashFromContent($compressed) ); // Debug message @@ -729,7 +731,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R self::PACKAGE_DATA_RECIPIENT => $helperInstance->getRecipientType(), self::PACKAGE_DATA_CONTENT => $packageContent, self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_NEW, - self::PACKAGE_DATA_HASH => $this->generatePackageHash($packageContent, $this->getSessionId()) + self::PACKAGE_DATA_HASH => $this->generatePackageHash($content, $this->getSessionId()) )); // Debug message -- 2.39.2