Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | daniel-mar | 1 | /* |
2 | * php_clientchallenge |
||
3 | * Copyright 2021 Daniel Marschall, ViaThinkSoft |
||
4 | * |
||
5 | * Licensed under the Apache License, Version 2.0 (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 |
||
8 | * |
||
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
10 | * |
||
11 | * Unless required by applicable law or agreed to in writing, software |
||
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
14 | * See the License for the specific language governing permissions and |
||
15 | * limitations under the License. |
||
16 | */ |
||
17 | |||
18 | function vts_validated_call(getChallengeScript, callback, params, error_cb) { |
||
19 | $.ajax({ |
||
20 | type: "POST", |
||
21 | url: getChallengeScript, |
||
22 | data: { |
||
23 | }, |
||
24 | success: function(data) { |
||
25 | var starttime = data[0]; |
||
26 | var ip_target = data[1]; |
||
27 | var challenge = data[2]; |
||
28 | var min = data[3]; |
||
29 | var max = data[4]; |
||
4 | daniel-mar | 30 | var challenge_integrity = data[5]; |
2 | daniel-mar | 31 | for (i=min; i<=max; i++) { |
32 | if (challenge == sha3_512(starttime+"/"+ip_target+"/"+i)) { |
||
33 | var answer = i; |
||
4 | daniel-mar | 34 | var vts_validation_result = JSON.stringify([starttime, ip_target, challenge, answer, challenge_integrity]); |
2 | daniel-mar | 35 | callback(params, vts_validation_result); |
36 | break; |
||
37 | } |
||
38 | } |
||
39 | }, |
||
40 | error: error_cb |
||
41 | }); |
||
42 | } |