Rev 2 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 4 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * php_clientchallenge |
2 | * php_clientchallenge |
3 | * Copyright 2021 Daniel Marschall, ViaThinkSoft |
3 | * Copyright 2021 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 | var starttime = data[0]; |
25 | var starttime = data[0]; |
26 | var ip_target = data[1]; |
26 | var ip_target = data[1]; |
27 | var challenge = data[2]; |
27 | var challenge = data[2]; |
28 | var min = data[3]; |
28 | var min = data[3]; |
29 | var max = data[4]; |
29 | var max = data[4]; |
- | 30 | var challenge_integrity = data[5]; |
|
30 | for (i=min; i<=max; i++) { |
31 | for (i=min; i<=max; i++) { |
31 | if (challenge == sha3_512(starttime+"/"+ip_target+"/"+i)) { |
32 | if (challenge == sha3_512(starttime+"/"+ip_target+"/"+i)) { |
32 | var answer = i; |
33 | var answer = i; |
33 | var vts_validation_result = JSON.stringify([starttime, ip_target, challenge, answer]); |
34 | var vts_validation_result = JSON.stringify([starttime, ip_target, challenge, answer, challenge_integrity]); |
34 | callback(params, vts_validation_result); |
35 | callback(params, vts_validation_result); |
35 | break; |
36 | break; |
36 | } |
37 | } |
37 | } |
38 | } |
38 | }, |
39 | }, |
39 | error: error_cb |
40 | error: error_cb |
40 | }); |
41 | }); |
41 | } |
42 | } |
42 | 43 |