@@ -77,7 +77,12 @@ groups() ->
7777 ]},
7878
7979 {ssh_renegotiate_SUITE , [parallel ], [rekey ,
80- rekey_limit ,
80+ rekey_limit_client ,
81+ rekey_limit_daemon ,
82+ rekey_time_limit_client ,
83+ rekey_time_limit_daemon ,
84+ norekey_limit_client ,
85+ norekey_limit_daemon ,
8186 renegotiate1 ,
8287 renegotiate2 ]},
8388
@@ -1349,17 +1354,17 @@ rekey(Config) ->
13491354
13501355% %% Test rekeying by data volume
13511356
1352- rekey_limit () -> [{timetrap ,{seconds ,400 }}].
1353-
1354- rekey_limit ( Config ) ->
1357+ rekey_limit_client () -> [{timetrap ,{seconds ,400 }}].
1358+ rekey_limit_client ( Config ) ->
1359+ Limit = 6000 ,
13551360 UserDir = proplists :get_value (priv_dir , Config ),
13561361 DataFile = filename :join (UserDir , " rekey.data" ),
13571362
13581363 Algs = proplists :get_value (preferred_algorithms , Config ),
13591364 {Pid , Host , Port } = ssh_test_lib :std_daemon (Config ,[{max_random_length_padding ,0 },
13601365 {preferred_algorithms ,Algs }]),
13611366
1362- ConnectionRef = ssh_test_lib :std_connect (Config , Host , Port , [{rekey_limit , 6000 },
1367+ ConnectionRef = ssh_test_lib :std_connect (Config , Host , Port , [{rekey_limit , Limit },
13631368 {max_random_length_padding ,0 }]),
13641369 {ok , SftpPid } = ssh_sftp :start_channel (ConnectionRef ),
13651370
@@ -1368,7 +1373,7 @@ rekey_limit(Config) ->
13681373 timer :sleep (? REKEY_DATA_TMO ),
13691374 Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
13701375
1371- Data = lists :duplicate (159000 ,1 ),
1376+ Data = lists :duplicate (Limit + 10 ,1 ),
13721377 ok = ssh_sftp :write_file (SftpPid , DataFile , Data ),
13731378
13741379 timer :sleep (? REKEY_DATA_TMO ),
@@ -1393,6 +1398,150 @@ rekey_limit(Config) ->
13931398 ssh :close (ConnectionRef ),
13941399 ssh :stop_daemon (Pid ).
13951400
1401+
1402+
1403+ rekey_limit_daemon () -> [{timetrap ,{seconds ,400 }}].
1404+ rekey_limit_daemon (Config ) ->
1405+ Limit = 6000 ,
1406+ UserDir = proplists :get_value (priv_dir , Config ),
1407+ DataFile1 = filename :join (UserDir , " rekey1.data" ),
1408+ DataFile2 = filename :join (UserDir , " rekey2.data" ),
1409+ file :write_file (DataFile1 , lists :duplicate (Limit + 10 ,1 )),
1410+ file :write_file (DataFile2 , " hi\n " ),
1411+
1412+ Algs = proplists :get_value (preferred_algorithms , Config ),
1413+ {Pid , Host , Port } = ssh_test_lib :std_daemon (Config ,[{rekey_limit , Limit },
1414+ {max_random_length_padding ,0 },
1415+ {preferred_algorithms ,Algs }]),
1416+ ConnectionRef = ssh_test_lib :std_connect (Config , Host , Port , [{max_random_length_padding ,0 }]),
1417+ {ok , SftpPid } = ssh_sftp :start_channel (ConnectionRef ),
1418+
1419+ Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
1420+ timer :sleep (? REKEY_DATA_TMO ),
1421+ Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
1422+
1423+ {ok ,_ } = ssh_sftp :read_file (SftpPid , DataFile1 ),
1424+
1425+ timer :sleep (? REKEY_DATA_TMO ),
1426+ Kex2 = ssh_test_lib :get_kex_init (ConnectionRef ),
1427+ false = (Kex2 == Kex1 ),
1428+
1429+ timer :sleep (? REKEY_DATA_TMO ),
1430+ Kex2 = ssh_test_lib :get_kex_init (ConnectionRef ),
1431+
1432+ {ok ,_ } = ssh_sftp :read_file (SftpPid , DataFile2 ),
1433+
1434+ timer :sleep (? REKEY_DATA_TMO ),
1435+ Kex2 = ssh_test_lib :get_kex_init (ConnectionRef ),
1436+
1437+ timer :sleep (? REKEY_DATA_TMO ),
1438+ Kex2 = ssh_test_lib :get_kex_init (ConnectionRef ),
1439+
1440+ ssh_sftp :stop_channel (SftpPid ),
1441+ ssh :close (ConnectionRef ),
1442+ ssh :stop_daemon (Pid ).
1443+
1444+
1445+ % % Check that datatransfer in the other direction does not trigger re-keying
1446+ norekey_limit_client () -> [{timetrap ,{seconds ,400 }}].
1447+ norekey_limit_client (Config ) ->
1448+ Limit = 6000 ,
1449+ UserDir = proplists :get_value (priv_dir , Config ),
1450+ DataFile = filename :join (UserDir , " rekey3.data" ),
1451+ file :write_file (DataFile , lists :duplicate (Limit + 10 ,1 )),
1452+
1453+ Algs = proplists :get_value (preferred_algorithms , Config ),
1454+ {Pid , Host , Port } = ssh_test_lib :std_daemon (Config ,[{max_random_length_padding ,0 },
1455+ {preferred_algorithms ,Algs }]),
1456+
1457+ ConnectionRef = ssh_test_lib :std_connect (Config , Host , Port , [{rekey_limit , Limit },
1458+ {max_random_length_padding ,0 }]),
1459+ {ok , SftpPid } = ssh_sftp :start_channel (ConnectionRef ),
1460+
1461+ Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
1462+ timer :sleep (? REKEY_DATA_TMO ),
1463+ Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
1464+
1465+ {ok ,_ } = ssh_sftp :read_file (SftpPid , DataFile ),
1466+ timer :sleep (? REKEY_DATA_TMO ),
1467+ Kex2 = ssh_test_lib :get_kex_init (ConnectionRef ),
1468+
1469+ Kex1 = Kex2 ,
1470+ ssh_sftp :stop_channel (SftpPid ),
1471+ ssh :close (ConnectionRef ),
1472+ ssh :stop_daemon (Pid ).
1473+
1474+ % % Check that datatransfer in the other direction does not trigger re-keying
1475+ norekey_limit_daemon () -> [{timetrap ,{seconds ,400 }}].
1476+ norekey_limit_daemon (Config ) ->
1477+ Limit = 6000 ,
1478+ UserDir = proplists :get_value (priv_dir , Config ),
1479+ DataFile = filename :join (UserDir , " rekey4.data" ),
1480+
1481+ Algs = proplists :get_value (preferred_algorithms , Config ),
1482+ {Pid , Host , Port } = ssh_test_lib :std_daemon (Config ,[{rekey_limit , Limit },
1483+ {max_random_length_padding ,0 },
1484+ {preferred_algorithms ,Algs }]),
1485+
1486+ ConnectionRef = ssh_test_lib :std_connect (Config , Host , Port , [{max_random_length_padding ,0 }]),
1487+ {ok , SftpPid } = ssh_sftp :start_channel (ConnectionRef ),
1488+
1489+ Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
1490+ timer :sleep (? REKEY_DATA_TMO ),
1491+ Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
1492+
1493+ ok = ssh_sftp :write_file (SftpPid , DataFile , lists :duplicate (Limit + 10 ,1 )),
1494+ timer :sleep (? REKEY_DATA_TMO ),
1495+ Kex2 = ssh_test_lib :get_kex_init (ConnectionRef ),
1496+
1497+ Kex1 = Kex2 ,
1498+ ssh_sftp :stop_channel (SftpPid ),
1499+ ssh :close (ConnectionRef ),
1500+ ssh :stop_daemon (Pid ).
1501+
1502+ % %--------------------------------------------------------------------
1503+ % %% Test rekeying by time
1504+
1505+ rekey_time_limit_client () -> [{timetrap ,{seconds ,400 }}].
1506+ rekey_time_limit_client (Config ) ->
1507+ Minutes = 1 ,
1508+ GB = 1024 * 1000 * 1000 ,
1509+ Algs = proplists :get_value (preferred_algorithms , Config ),
1510+ {Pid , Host , Port } = ssh_test_lib :std_daemon (Config ,[{max_random_length_padding ,0 },
1511+ {preferred_algorithms ,Algs }]),
1512+ ConnectionRef = ssh_test_lib :std_connect (Config , Host , Port , [{rekey_limit , {Minutes , GB }},
1513+ {max_random_length_padding ,0 }]),
1514+ {ok , SftpPid } = ssh_sftp :start_channel (ConnectionRef ),
1515+ rekey_time_limit (Pid , Minutes , ConnectionRef , SftpPid ).
1516+
1517+ rekey_time_limit_daemon () -> [{timetrap ,{seconds ,400 }}].
1518+ rekey_time_limit_daemon (Config ) ->
1519+ Minutes = 1 ,
1520+ GB = 1024 * 1000 * 1000 ,
1521+ Algs = proplists :get_value (preferred_algorithms , Config ),
1522+ {Pid , Host , Port } = ssh_test_lib :std_daemon (Config ,[{rekey_limit , {Minutes , GB }},
1523+ {max_random_length_padding ,0 },
1524+ {preferred_algorithms ,Algs }]),
1525+ ConnectionRef = ssh_test_lib :std_connect (Config , Host , Port , [{max_random_length_padding ,0 }]),
1526+ {ok , SftpPid } = ssh_sftp :start_channel (ConnectionRef ),
1527+ rekey_time_limit (Pid , Minutes , ConnectionRef , SftpPid ).
1528+
1529+
1530+ rekey_time_limit (Pid , Minutes , ConnectionRef , SftpPid ) ->
1531+ Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
1532+
1533+ timer :sleep (5000 ),
1534+ Kex1 = ssh_test_lib :get_kex_init (ConnectionRef ),
1535+
1536+ timer :sleep ((Minutes * 60 + 30 ) * 1000 ),
1537+ Kex2 = ssh_test_lib :get_kex_init (ConnectionRef ),
1538+
1539+ false = (Kex2 == Kex1 ),
1540+
1541+ ssh_sftp :stop_channel (SftpPid ),
1542+ ssh :close (ConnectionRef ),
1543+ ssh :stop_daemon (Pid ).
1544+
13961545% %--------------------------------------------------------------------
13971546
13981547% %% Test rekeying with simulataneous send request
0 commit comments