diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-13 01:13:55 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-13 01:13:55 +0000 |
commit | c98908daa9cb992bf485a13ba837aea331419222 (patch) | |
tree | 95144ad0d984d3594395237766f6e9a10b023e1b /update/library/trunk | |
parent | da014e7e1ae7559a89e4218fed6a59cd18b7c7e7 (diff) | |
download | instadisc-c98908daa9cb992bf485a13ba837aea331419222.tar.gz instadisc-c98908daa9cb992bf485a13ba837aea331419222.tar.bz2 instadisc-c98908daa9cb992bf485a13ba837aea331419222.zip |
Update: Seperated Encryption ID from Verifiction ID
The Client was failing to properly decrypt encrypted data because of a key generation issue, the key is generated from a password and a Verification ID. However, because Verifcation IDs must be unique, the encryption key and the decryption key would differ. However, the Central Server needs to be modified so as to pass on the Encryption Key. Refs #10
Diffstat (limited to 'update/library/trunk')
-rw-r--r-- | update/library/trunk/instadisc.php | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/update/library/trunk/instadisc.php b/update/library/trunk/instadisc.php index 3f9f945..6cf5e09 100644 --- a/update/library/trunk/instadisc.php +++ b/update/library/trunk/instadisc.php | |||
@@ -14,14 +14,11 @@ $idusActivationKey = array(); | |||
14 | $idusEncryptionKey = array(); | 14 | $idusEncryptionKey = array(); |
15 | $instaDisc_subCount = 0; | 15 | $instaDisc_subCount = 0; |
16 | 16 | ||
17 | function instaDisc_sendItem($id, $title, $author, $url, $semantics, $verID = 0) | 17 | function instaDisc_sendItem($id, $title, $author, $url, $semantics) |
18 | { | 18 | { |
19 | global $idusUsername, $idusPassword, $idusCentralServer, $idusSubscriptionURI; | 19 | global $idusUsername, $idusPassword, $idusCentralServer, $idusSubscriptionURI; |
20 | 20 | ||
21 | if ($verID == 0) | 21 | $verID = rand(1,65536); |
22 | { | ||
23 | $verID = rand(1,65536); | ||
24 | } | ||
25 | 22 | ||
26 | $client = new xmlrpc_client($idusCentralServer[$id]); | 23 | $client = new xmlrpc_client($idusCentralServer[$id]); |
27 | $msg = new xmlrpcmsg("InstaDisc.sendFromUpdate", array( new xmlrpcval($idusUsername[$id], 'string'), | 24 | $msg = new xmlrpcmsg("InstaDisc.sendFromUpdate", array( new xmlrpcval($idusUsername[$id], 'string'), |
@@ -31,7 +28,8 @@ function instaDisc_sendItem($id, $title, $author, $url, $semantics, $verID = 0) | |||
31 | new xmlrpcval($title, 'string'), | 28 | new xmlrpcval($title, 'string'), |
32 | new xmlrpcval($author, 'string'), | 29 | new xmlrpcval($author, 'string'), |
33 | new xmlrpcval($url, 'string'), | 30 | new xmlrpcval($url, 'string'), |
34 | new xmlrpcval(serialize($semantics), 'string'))); | 31 | new xmlrpcval(serialize($semantics), 'string'), |
32 | new xmlrpcval('0', 'int'))); | ||
35 | $client->send($msg); | 33 | $client->send($msg); |
36 | } | 34 | } |
37 | 35 | ||
@@ -39,15 +37,15 @@ function instaDisc_sendEncrypted($id, $title, $author, $url, $semantics) | |||
39 | { | 37 | { |
40 | global $idusEncryptionKey; | 38 | global $idusEncryptionKey; |
41 | 39 | ||
42 | $verID = 0; | 40 | $encID = 0; |
43 | while ($verID == 0) | 41 | while ($encID == 0) |
44 | { | 42 | { |
45 | $verID = rand(1,65536); | 43 | $encID = rand(1,65536); |
46 | } | 44 | } |
47 | 45 | ||
48 | $cipher = "rijndael-128"; | 46 | $cipher = "rijndael-128"; |
49 | $mode = "cbc"; | 47 | $mode = "cbc"; |
50 | $key = substr(md5(substr(str_pad($idusEncryptionKey[$id],16,$verID),0,16)),0,16); | 48 | $key = substr(md5(substr(str_pad($idusEncryptionKey[$id],16,$encID),0,16)),0,16); |
51 | 49 | ||
52 | $td = mcrypt_module_open($cipher, "", $mode, ""); | 50 | $td = mcrypt_module_open($cipher, "", $mode, ""); |
53 | mcrypt_generic_init($td, $key, strrev($key)); | 51 | mcrypt_generic_init($td, $key, strrev($key)); |
@@ -63,7 +61,19 @@ function instaDisc_sendEncrypted($id, $title, $author, $url, $semantics) | |||
63 | mcrypt_generic_deinit($td); | 61 | mcrypt_generic_deinit($td); |
64 | mcrypt_module_close($td); | 62 | mcrypt_module_close($td); |
65 | 63 | ||
66 | instaDisc_sendItem($id, $title, $author, $url, $semantics, $verID); | 64 | $verID = rand(1,65536); |
65 | |||
66 | $client = new xmlrpc_client($idusCentralServer[$id]); | ||
67 | $msg = new xmlrpcmsg("InstaDisc.sendFromUpdate", array( new xmlrpcval($idusUsername[$id], 'string'), | ||
68 | new xmlrpcval(md5($idusUsername[$id] . ":" . md5($idusPassword[$id]) . ":" . $verID), 'string'), | ||
69 | new xmlrpcval($verID, 'int'), | ||
70 | new xmlrpcval($idusSubscriptionURI[$id], 'string'), | ||
71 | new xmlrpcval($title, 'string'), | ||
72 | new xmlrpcval($author, 'string'), | ||
73 | new xmlrpcval($url, 'string'), | ||
74 | new xmlrpcval(serialize($semantics), 'string'), | ||
75 | new xmlrpcval($encID, 'int'))); | ||
76 | $client->send($msg); | ||
67 | } | 77 | } |
68 | 78 | ||
69 | function instaDisc_addSubscription($username, $password, $central, $uri, $title, $category, $key = '', $enc = '') | 79 | function instaDisc_addSubscription($username, $password, $central, $uri, $title, $category, $key = '', $enc = '') |