Added error descriptions

This commit is contained in:
danogentili 2016-11-15 16:31:32 +03:00
parent 84d25bfaa2
commit 6720199a33
2 changed files with 18 additions and 5 deletions

View File

@ -71,7 +71,7 @@ class AuthKeyHandler extends AckHandler
}
if (!isset($public_key_fingerprint)) {
throw new Exception("couldn't find our key in the server_public_key_fingerprints vector.");
throw new Exception("Couldn't find our key in the server_public_key_fingerprints vector.");
}
$pq_bytes = $ResPQ['pq'];
@ -284,7 +284,7 @@ class AuthKeyHandler extends AckHandler
*/
if ($dh_prime->compare($twoe2047) <= 0 // 2^2047 < dh_prime or dh_prime > 2^2047 or ! dh_prime <= 2^2047
|| $dh_prime->compare($twoe2048) >= 0 // dh_prime < 2^2048 or ! dh_prime >= 2^2048
|| $dh_prime->compare($twoe2048) >= 0 // dh_prime < 2^2048 or ! dh_prime >= 2^2048
) {
throw new Exception("g isn't a safe 2048-bit prime (2^2047 < dh_prime < 2^2048 is false).");
}
@ -295,7 +295,7 @@ class AuthKeyHandler extends AckHandler
* 1 < g < dh_prime - 1
*/
if ($g->compare($one) <= 0 // 1 < g or g > 1 or ! g <= 1
|| $g->compare($dh_prime->subtract($one)) >= 0 // g < dh_prime - 1 or ! g >= dh_prime - 1
|| $g->compare($dh_prime->subtract($one)) >= 0 // g < dh_prime - 1 or ! g >= dh_prime - 1
) {
throw new Exception('g is invalid (1 < g < dh_prime - 1 is false).');
}
@ -306,7 +306,7 @@ class AuthKeyHandler extends AckHandler
* 1 < g_a < dh_prime - 1
*/
if ($g_a->compare($one) <= 0 // 1 < g_a or g_a > 1 or ! g_a <= 1
|| $g_a->compare($dh_prime->subtract($one)) >= 0 // g_a < dh_prime - 1 or ! g_a >= dh_prime - 1
|| $g_a->compare($dh_prime->subtract($one)) >= 0 // g_a < dh_prime - 1 or ! g_a >= dh_prime - 1
) {
throw new Exception('g_a is invalid (1 < g_a < dh_prime - 1 is false).');
}

View File

@ -41,7 +41,20 @@ class ResponseHandler extends MsgIdHandler
break;
case 'bad_msg_notification':
throw new Exception('Received bad_msg_notification '.var_export($response, true));
$error_codes = [
16 => 'msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)',
17 => 'msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)',
18 => 'incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)',
19 => 'container msg_id is the same as msg_id of a previously received message (this must never happen)',
20 => 'message too old, and it cannot be verified whether the server has received a message with this msg_id or not',
32 => 'msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno)',
33 => 'msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno)',
34 => 'an even msg_seqno expected (irrelevant message), but odd received',
35 => 'odd msg_seqno expected (relevant message), but even received',
48 => 'incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it)',
64 => 'invalid container.',
];
throw new Exception('Received bad_msg_notification for '.$response['bad_msg_id'].': '.$error_codes[$response['error_code']]);
break;
case 'bad_server_salt':
$this->settings['authorization']['temp_auth_key']['server_salt'] = $response['new_server_salt'];