"Fossies" - the Fresh Open Source Software Archive

Member "chrony-3.5/test/simulation/105-ntpauth" (10 May 2019, 2203 Bytes) of package /linux/misc/chrony-3.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "105-ntpauth": 3.4_vs_3.5.

    1 #!/bin/bash
    2 
    3 . ./test.common
    4 
    5 test_start "NTP authentication"
    6 
    7 server_conf="keyfile tmp/server.keys"
    8 client_conf="keyfile tmp/client.keys"
    9 
   10 cat > tmp/server.keys <<-EOF
   11 1 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
   12 2 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
   13 3 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
   14 4 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
   15 EOF
   16 
   17 cat > tmp/client.keys <<-EOF
   18 1 k]<j.Jtw^Oo;z5E>n\_0-x=)yP\f<)Z^
   19 2 ASCII:k]<j.Jtw^Oo;z5E>n\_0-x=)yP\f<)Z^
   20 3 MD5 ASCII:k]<j.Jtw^Oo;z5E>n\_0-x=)yP\f<)Z^
   21 4 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
   22 EOF
   23 
   24 keys=4
   25 
   26 if check_config_h 'FEAT_SECHASH 1'; then
   27     hashes="MD5 SHA1 SHA256 SHA384 SHA512"
   28 else
   29     hashes="MD5"
   30 fi
   31 
   32 for hash in $hashes; do
   33     keys=$[$keys + 1]
   34     key=$(echo $keys $hash HEX:$(tr -c -d '0-9A-F' < /dev/urandom 2> /dev/null | \
   35         head -c $[$RANDOM % 64 * 2 + 2]))
   36     echo "$key" >> tmp/server.keys
   37     echo "$key" >> tmp/client.keys
   38 done
   39 
   40 for version in 3 4; do
   41     for key in $(seq $keys); do
   42         client_server_options="version $version key $key"
   43         run_test || test_fail
   44         check_chronyd_exit || test_fail
   45         check_source_selection || test_fail
   46         check_packet_interval || test_fail
   47         check_sync || test_fail
   48     done
   49 done
   50 
   51 server_conf=""
   52 
   53 run_test || test_fail
   54 check_chronyd_exit || test_fail
   55 # This check must fail as the server doesn't know the key
   56 check_sync && test_fail
   57 check_packet_interval || test_fail
   58 
   59 server_conf="keyfile tmp/server.keys"
   60 client_conf=""
   61 
   62 run_test || test_fail
   63 check_chronyd_exit || test_fail
   64 # This check must fail as the client doesn't know the key
   65 check_sync && test_fail
   66 check_packet_interval || test_fail
   67 
   68 client_conf="keyfile tmp/client.keys"
   69 clients=2
   70 peers=2
   71 max_sync_time=500
   72 base_delay="$default_base_delay (* -1 (equal 0.1 from 3) (equal 0.1 to 1))"
   73 client_lpeer_options="key 1"
   74 client_rpeer_options="key 1"
   75 
   76 run_test || test_fail
   77 check_chronyd_exit || test_fail
   78 check_sync || test_fail
   79 
   80 client_rpeer_options="key 2"
   81 
   82 run_test || test_fail
   83 check_chronyd_exit || test_fail
   84 # This check must fail as the peers are using different keys"
   85 check_sync && test_fail
   86 
   87 test_pass