Rev 4 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 6 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * php_clientchallenge |
2 | * php_clientchallenge |
3 | * Copyright 2021 Daniel Marschall, ViaThinkSoft |
3 | * Copyright 2021-2022 Daniel Marschall, ViaThinkSoft |
4 | * |
4 | * |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | * you may not use this file except in compliance with the License. |
6 | * you may not use this file except in compliance with the License. |
7 | * You may obtain a copy of the License at |
7 | * You may obtain a copy of the License at |
8 | * |
8 | * |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | * |
10 | * |
11 | * Unless required by applicable law or agreed to in writing, software |
11 | * Unless required by applicable law or agreed to in writing, software |
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | * See the License for the specific language governing permissions and |
14 | * See the License for the specific language governing permissions and |
15 | * limitations under the License. |
15 | * limitations under the License. |
16 | */ |
16 | */ |
17 | 17 | ||
18 | function vts_validated_call(getChallengeScript, callback, params, error_cb) { |
18 | function vts_validated_call(getChallengeScript, callback, params, error_cb) { |
19 | $.ajax({ |
19 | $.ajax({ |
20 | type: "POST", |
20 | type: "POST", |
21 | url: getChallengeScript, |
21 | url: getChallengeScript, |
22 | data: { |
22 | data: { |
23 | }, |
23 | }, |
24 | success: function(data) { |
24 | success: function(data) { |
- | 25 | if ("error" in data) { |
|
- | 26 | error_cb(null,null,data["error"]); |
|
- | 27 | return; |
|
- | 28 | } |
|
25 | var starttime = data[0]; |
29 | var starttime = data[0]; |
26 | var ip_target = data[1]; |
30 | var ip_target = data[1]; |
27 | var challenge = data[2]; |
31 | var challenge = data[2]; |
28 | var min = data[3]; |
32 | var min = data[3]; |
29 | var max = data[4]; |
33 | var max = data[4]; |
30 | var challenge_integrity = data[5]; |
34 | var challenge_integrity = data[5]; |
31 | for (i=min; i<=max; i++) { |
35 | for (i=min; i<=max; i++) { |
32 | if (challenge == sha3_512(starttime+"/"+ip_target+"/"+i)) { |
36 | if (challenge == sha3_512(starttime+"/"+ip_target+"/"+i)) { |
33 | var answer = i; |
37 | var answer = i; |
34 | var vts_validation_result = JSON.stringify([starttime, ip_target, challenge, answer, challenge_integrity]); |
38 | var vts_validation_result = JSON.stringify([starttime, ip_target, challenge, answer, challenge_integrity]); |
35 | callback(params, vts_validation_result); |
39 | callback(params, vts_validation_result); |
36 | break; |
40 | break; |
37 | } |
41 | } |
38 | } |
42 | } |
39 | }, |
43 | }, |
40 | error: error_cb |
44 | error: error_cb |
41 | }); |
45 | }); |
42 | } |
46 | } |
43 | 47 |