  @author        <  > [  ]
     2009  
%%% @doc        RTMP handshake tests. 
%%% @reference  See <a href="" target="_top"></a> for more information.
%%% @end
%%%
  This file is part of erlang - rtmp .
%%% 
%%% erlang-rtmp is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation , either version 3 of the License , or
%%% (at your option) any later version.
%%%
%%% erlang-rtmp is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%%% GNU General Public License for more details.
%%%
  You should have received a copy of the GNU General Public License
  along with erlang - rtmp .   If not , see < / > .
%%%
%%%---------------------------------------------------------------------------------------
-module(rtmp_handshake_tests).

-include("../include/rtmp.hrl").
-include("rtmp_private.hrl").
-include_lib("eunit/include/eunit.hrl").



client_version_test() ->
  ?assertEqual(version2, rtmp_handshake:client_scheme_version(example_c1_crypt())).
  

% dhKey_test() ->
    { _ , ClientKey , _ } = rtmp_handshake : dhKey(example_c1_crypt ( ) ,  ) ,
    ? assertEqual(example_client_key ( ) , ClientKey ) .
% 
% 
% key_generation_test() ->
    KeyIn = rtmp_handshake : rc4_key(example_shared ( ) , example_server_dh ( ) ) ,
     = rtmp_handshake : rc4_key(example_shared ( ) , example_client_dh ( ) ) ,
%   
    ? assertEqual(example_key_out ( ) ,  ) ,
    ? assertEqual(example_key_in ( ) , KeyIn ) ,
%   ok.
% 
% rtmpe_handshake_test() ->
    { crypted , _ ,  , _  } = rtmp_handshake : server(<<6 , ( example_c1_crypt())/binary > > ) ,
    ? assertEqual(example_rc4_key_in ( ) , KeyIn ) .
  

example_c1_crypt() ->
  <<0,173,33,73,128,0,3,2,66,167,50,61,131,201,66,31,
  14,176,131,83,250,115,48,103,15,240,179,5,141,41,
  189,141,62,102,76,184,26,87,98,87,190,9,220,168,
  119,18,18,251,75,131,215,222,6,17,132,164,144,18,
  242,84,149,121,10,204,117,51,110,153,188,208,191,
  88,51,241,220,99,64,193,221,45,132,83,140,32,234,
  51,65,99,168,180,166,254,52,251,148,177,145,24,33,
  109,5,218,228,53,255,112,162,62,25,127,173,168,86,
  180,105,18,254,175,25,35,191,99,245,103,184,236,69,
  141,87,247,161,11,36,151,185,194,8,114,133,85,93,
  164,152,110,162,181,111,214,107,18,196,49,217,195,
  185,18,145,187,224,104,58,206,183,49,55,43,4,174,
  18,218,4,182,51,157,183,204,246,73,168,198,242,202,
  58,62,200,176,135,226,200,16,15,219,67,143,190,7,
  155,239,144,106,171,159,139,248,59,6,62,162,73,227,
  25,249,37,124,23,0,4,208,48,222,52,224,228,154,253,
  192,204,162,47,12,21,75,187,173,89,170,17,42,12,
  208,152,238,4,65,117,252,242,240,198,244,174,190,
  254,116,243,93,201,157,203,15,183,152,247,181,243,
  62,214,170,77,101,38,51,196,60,30,254,44,220,93,
  215,208,228,97,73,236,2,3,116,246,248,86,209,169,
  179,49,72,12,110,120,75,87,59,232,147,24,255,59,40,
  127,57,165,239,80,152,71,189,142,198,213,158,196,
  163,198,145,6,226,1,241,222,88,253,4,54,168,49,95,
  208,36,17,20,58,125,61,243,83,241,155,9,158,190,5,
  169,32,136,181,89,51,91,32,126,122,40,157,163,43,
  181,50,61,115,203,127,84,29,125,102,113,130,209,
  217,222,121,64,135,73,55,242,52,96,153,173,244,51,
  177,119,96,125,79,25,86,216,14,117,63,205,238,66,
  147,217,19,156,209,95,155,157,142,20,216,158,131,
  241,66,40,82,236,180,85,139,229,6,6,119,135,218,34,
  187,205,2,246,123,130,167,217,225,91,2,233,33,94,
  235,71,88,31,42,26,76,97,83,127,214,209,100,95,143,
  199,67,97,73,31,117,36,131,23,188,53,232,150,30,80,
  171,91,228,200,124,1,236,136,154,237,53,69,66,65,
  168,232,168,144,208,21,42,177,96,131,24,244,47,186,
  11,161,59,14,141,3,25,224,197,92,122,80,59,173,184,
  4,84,84,139,85,73,116,242,196,26,114,236,4,158,15,
  42,47,32,61,194,29,101,240,62,245,3,173,199,59,90,
  88,238,155,185,181,65,140,158,141,248,119,168,56,
  21,73,33,223,209,235,185,243,77,147,244,240,198,
  127,22,127,61,217,30,165,48,177,107,22,85,172,53,
  65,0,90,224,112,94,107,118,152,71,183,232,123,227,
  233,253,11,33,120,143,14,41,206,232,70,223,187,215,
  185,253,134,77,93,159,10,122,232,196,182,140,50,
  227,154,213,202,109,151,175,250,182,86,217,235,230,
  106,189,5,2,13,102,220,107,98,135,54,120,139,120,
  36,156,26,164,58,94,188,79,207,124,100,158,154,28,
  141,181,252,183,150,213,171,3,86,25,30,86,88,183,
  78,100,77,12,121,34,156,156,199,179,169,214,85,79,
  65,26,115,119,137,242,198,37,235,173,78,99,39,114,
  36,104,238,138,6,139,31,35,121,245,226,25,228,254,
  56,252,25,154,220,122,52,187,251,50,187,30,133,147,
  70,103,10,169,184,164,144,214,10,247,72,22,108,72,
  95,3,116,216,204,117,238,110,97,64,105,93,18,62,76,
  103,104,191,192,209,134,231,34,35,9,176,181,41,74,
  124,11,105,195,5,197,247,198,245,111,68,173,217,88,
  162,102,80,96,182,73,23,79,196,138,232,65,251,134,
  113,152,107,104,207,12,3,243,17,131,181,59,2,73,
  155,176,186,142,54,216,142,37,47,2,250,24,79,221,
  178,253,129,175,79,180,157,124,143,254,171,87,47,
  96,251,215,175,215,149,49,46,124,170,176,108,84,14,
  79,224,56,31,30,165,122,176,117,198,108,88,191,158,
  242,183,12,198,108,222,255,145,95,124,22,125,218,
  124,244,235,213,97,159,156,209,254,216,2,106,108,
  68,250,156,126,193,108,251,229,84,236,18,88,26,135,
  122,34,32,218,3,248,149,25,147,4,238,24,18,170,212,
  202,206,109,1,121,135,118,13,54,63,164,178,117,94,
  151,24,221,109,68,175,219,28,157,118,109,226,233,
  223,60,12,184,165,218,237,254,189,35,211,135,78,
  112,143,151,32,166,176,247,81,126,209,63,159,206,
  18,122,149,61,78,246,48,216,171,90,160,14,92,88,
  175,17,122,97,115,145,87,66,103,34,73,12,153,143,
  25,28,174,120,237,18,128,41,212,159,56,82,212,0,
  153,90,89,217,82,158,77,120,210,207,49,228,42,63,
  68,151,232,151,206,182,157,72,78,55,171,40,112,197,
  75,115,24,39,20,214,141,178,225,13,236,54,123,16,3,
  179,17,222,235,232,4,107,164,152,245,132,126,65,
  252,253,34,215,209,96,68,148,11,76,9,226,139,20,57,
  52,1,1,230,80,92,110,220,102,111,173,194,71,30,76,
  106,244,39,108,153,42,17,53,116,226,137,154,134,
  177,10,168,38,76,20,138,177,121,140,94,94,175,161,
  242,86,216,150,243,186,163,135,232,167,41,209,98,
  94,247,220,236,202,221,32,47,40,152,166,114,176,
  196,117,112,226,93,163,38,39,179,51,161,163,174,64,
  174,85,223,132,184,223,232,254,69,27,60,66,252,136,
  1,206,203,119,170,126,61,40,91,34,217,144,32,175,
  210,206,235,206,28,9,210,105,91,250,23,37,141,238,
  8,239,22,131,232,22,234,18,244,103,9,4,203,81,249,
  41,57,61,164,199,188,37,193,168,209,157,21,63,140,
  165,60,174,90,253,125,244,98,20,79,255,142,242,164,
  70,172,229,184,140,1,52,176,43,9,75,96,76,158,246,
  214,243,118,187,171,240,208,67,221,186,3,163,216,
  161,198,16,136,161,227,17,82,22,189,108,67,5,154,
  151,119,46,185,156,98,239,192,237,106,66,25,241,
  220,145,24,126,32,240,200,50,126,91,111,124,26,55,
  245,144,143,130,44,220,241,174,121,176,228,14,68,
  69,148,167,116,213,56,85,14,53,241,245,50,252,17,
  70,226,82,242,72,174,253,146,54,0,155,129,220,10,
  35,159,244,195,92,45,52,108,125,32,116,122,124,197,
  119,235,200,74,168,248,143,188,21,79,219,251,242,
  161,53,244,182,154,171,160,218,137,239,3,127,113,
  38,109,35,134,181,104,102,95,53,254,60,68,169,145,
  105,11,138,167,89,242,214,156,71,75,252,140,146,
  140,80,130,201,183,179,62,21,137,236,204,231,151,
  145,111,145,170,170,234,13,94,242,48,150,37,234,59,
  149,42,2,151,82,133,245,169,77,222,64,33,106,157,
  191,225,134,196,92,148,91,62,210,107,44,177,140,
  100,11,103,146,63,213,210,5,100,210,78,92,165,233,
  226,102,199,223,34,226,65,243,26,193,138,165,197,
  12,123,190,123,5,76,15>>.  

 @doc        RTMP handshake tests. 
 @reference  See <a href="" target="_top"></a> for more information.
 @end

 
 erlang-rtmp is free software: you can redistribute it and/or modify
 (at your option) any later version.

 erlang-rtmp is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.


---------------------------------------------------------------------------------------
 dhKey_test() ->
 
 
 key_generation_test() ->
   
   ok.
 
 rtmpe_handshake_test() ->
  @author        <  > [  ]
     2009  
  This file is part of erlang - rtmp .
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation , either version 3 of the License , or
  You should have received a copy of the GNU General Public License
  along with erlang - rtmp .   If not , see < / > .
-module(rtmp_handshake_tests).

-include("../include/rtmp.hrl").
-include("rtmp_private.hrl").
-include_lib("eunit/include/eunit.hrl").



client_version_test() ->
  ?assertEqual(version2, rtmp_handshake:client_scheme_version(example_c1_crypt())).
  

    { _ , ClientKey , _ } = rtmp_handshake : dhKey(example_c1_crypt ( ) ,  ) ,
    ? assertEqual(example_client_key ( ) , ClientKey ) .
    KeyIn = rtmp_handshake : rc4_key(example_shared ( ) , example_server_dh ( ) ) ,
     = rtmp_handshake : rc4_key(example_shared ( ) , example_client_dh ( ) ) ,
    ? assertEqual(example_key_out ( ) ,  ) ,
    ? assertEqual(example_key_in ( ) , KeyIn ) ,
    { crypted , _ ,  , _  } = rtmp_handshake : server(<<6 , ( example_c1_crypt())/binary > > ) ,
    ? assertEqual(example_rc4_key_in ( ) , KeyIn ) .
  

example_c1_crypt() ->
  <<0,173,33,73,128,0,3,2,66,167,50,61,131,201,66,31,
  14,176,131,83,250,115,48,103,15,240,179,5,141,41,
  189,141,62,102,76,184,26,87,98,87,190,9,220,168,
  119,18,18,251,75,131,215,222,6,17,132,164,144,18,
  242,84,149,121,10,204,117,51,110,153,188,208,191,
  88,51,241,220,99,64,193,221,45,132,83,140,32,234,
  51,65,99,168,180,166,254,52,251,148,177,145,24,33,
  109,5,218,228,53,255,112,162,62,25,127,173,168,86,
  180,105,18,254,175,25,35,191,99,245,103,184,236,69,
  141,87,247,161,11,36,151,185,194,8,114,133,85,93,
  164,152,110,162,181,111,214,107,18,196,49,217,195,
  185,18,145,187,224,104,58,206,183,49,55,43,4,174,
  18,218,4,182,51,157,183,204,246,73,168,198,242,202,
  58,62,200,176,135,226,200,16,15,219,67,143,190,7,
  155,239,144,106,171,159,139,248,59,6,62,162,73,227,
  25,249,37,124,23,0,4,208,48,222,52,224,228,154,253,
  192,204,162,47,12,21,75,187,173,89,170,17,42,12,
  208,152,238,4,65,117,252,242,240,198,244,174,190,
  254,116,243,93,201,157,203,15,183,152,247,181,243,
  62,214,170,77,101,38,51,196,60,30,254,44,220,93,
  215,208,228,97,73,236,2,3,116,246,248,86,209,169,
  179,49,72,12,110,120,75,87,59,232,147,24,255,59,40,
  127,57,165,239,80,152,71,189,142,198,213,158,196,
  163,198,145,6,226,1,241,222,88,253,4,54,168,49,95,
  208,36,17,20,58,125,61,243,83,241,155,9,158,190,5,
  169,32,136,181,89,51,91,32,126,122,40,157,163,43,
  181,50,61,115,203,127,84,29,125,102,113,130,209,
  217,222,121,64,135,73,55,242,52,96,153,173,244,51,
  177,119,96,125,79,25,86,216,14,117,63,205,238,66,
  147,217,19,156,209,95,155,157,142,20,216,158,131,
  241,66,40,82,236,180,85,139,229,6,6,119,135,218,34,
  187,205,2,246,123,130,167,217,225,91,2,233,33,94,
  235,71,88,31,42,26,76,97,83,127,214,209,100,95,143,
  199,67,97,73,31,117,36,131,23,188,53,232,150,30,80,
  171,91,228,200,124,1,236,136,154,237,53,69,66,65,
  168,232,168,144,208,21,42,177,96,131,24,244,47,186,
  11,161,59,14,141,3,25,224,197,92,122,80,59,173,184,
  4,84,84,139,85,73,116,242,196,26,114,236,4,158,15,
  42,47,32,61,194,29,101,240,62,245,3,173,199,59,90,
  88,238,155,185,181,65,140,158,141,248,119,168,56,
  21,73,33,223,209,235,185,243,77,147,244,240,198,
  127,22,127,61,217,30,165,48,177,107,22,85,172,53,
  65,0,90,224,112,94,107,118,152,71,183,232,123,227,
  233,253,11,33,120,143,14,41,206,232,70,223,187,215,
  185,253,134,77,93,159,10,122,232,196,182,140,50,
  227,154,213,202,109,151,175,250,182,86,217,235,230,
  106,189,5,2,13,102,220,107,98,135,54,120,139,120,
  36,156,26,164,58,94,188,79,207,124,100,158,154,28,
  141,181,252,183,150,213,171,3,86,25,30,86,88,183,
  78,100,77,12,121,34,156,156,199,179,169,214,85,79,
  65,26,115,119,137,242,198,37,235,173,78,99,39,114,
  36,104,238,138,6,139,31,35,121,245,226,25,228,254,
  56,252,25,154,220,122,52,187,251,50,187,30,133,147,
  70,103,10,169,184,164,144,214,10,247,72,22,108,72,
  95,3,116,216,204,117,238,110,97,64,105,93,18,62,76,
  103,104,191,192,209,134,231,34,35,9,176,181,41,74,
  124,11,105,195,5,197,247,198,245,111,68,173,217,88,
  162,102,80,96,182,73,23,79,196,138,232,65,251,134,
  113,152,107,104,207,12,3,243,17,131,181,59,2,73,
  155,176,186,142,54,216,142,37,47,2,250,24,79,221,
  178,253,129,175,79,180,157,124,143,254,171,87,47,
  96,251,215,175,215,149,49,46,124,170,176,108,84,14,
  79,224,56,31,30,165,122,176,117,198,108,88,191,158,
  242,183,12,198,108,222,255,145,95,124,22,125,218,
  124,244,235,213,97,159,156,209,254,216,2,106,108,
  68,250,156,126,193,108,251,229,84,236,18,88,26,135,
  122,34,32,218,3,248,149,25,147,4,238,24,18,170,212,
  202,206,109,1,121,135,118,13,54,63,164,178,117,94,
  151,24,221,109,68,175,219,28,157,118,109,226,233,
  223,60,12,184,165,218,237,254,189,35,211,135,78,
  112,143,151,32,166,176,247,81,126,209,63,159,206,
  18,122,149,61,78,246,48,216,171,90,160,14,92,88,
  175,17,122,97,115,145,87,66,103,34,73,12,153,143,
  25,28,174,120,237,18,128,41,212,159,56,82,212,0,
  153,90,89,217,82,158,77,120,210,207,49,228,42,63,
  68,151,232,151,206,182,157,72,78,55,171,40,112,197,
  75,115,24,39,20,214,141,178,225,13,236,54,123,16,3,
  179,17,222,235,232,4,107,164,152,245,132,126,65,
  252,253,34,215,209,96,68,148,11,76,9,226,139,20,57,
  52,1,1,230,80,92,110,220,102,111,173,194,71,30,76,
  106,244,39,108,153,42,17,53,116,226,137,154,134,
  177,10,168,38,76,20,138,177,121,140,94,94,175,161,
  242,86,216,150,243,186,163,135,232,167,41,209,98,
  94,247,220,236,202,221,32,47,40,152,166,114,176,
  196,117,112,226,93,163,38,39,179,51,161,163,174,64,
  174,85,223,132,184,223,232,254,69,27,60,66,252,136,
  1,206,203,119,170,126,61,40,91,34,217,144,32,175,
  210,206,235,206,28,9,210,105,91,250,23,37,141,238,
  8,239,22,131,232,22,234,18,244,103,9,4,203,81,249,
  41,57,61,164,199,188,37,193,168,209,157,21,63,140,
  165,60,174,90,253,125,244,98,20,79,255,142,242,164,
  70,172,229,184,140,1,52,176,43,9,75,96,76,158,246,
  214,243,118,187,171,240,208,67,221,186,3,163,216,
  161,198,16,136,161,227,17,82,22,189,108,67,5,154,
  151,119,46,185,156,98,239,192,237,106,66,25,241,
  220,145,24,126,32,240,200,50,126,91,111,124,26,55,
  245,144,143,130,44,220,241,174,121,176,228,14,68,
  69,148,167,116,213,56,85,14,53,241,245,50,252,17,
  70,226,82,242,72,174,253,146,54,0,155,129,220,10,
  35,159,244,195,92,45,52,108,125,32,116,122,124,197,
  119,235,200,74,168,248,143,188,21,79,219,251,242,
  161,53,244,182,154,171,160,218,137,239,3,127,113,
  38,109,35,134,181,104,102,95,53,254,60,68,169,145,
  105,11,138,167,89,242,214,156,71,75,252,140,146,
  140,80,130,201,183,179,62,21,137,236,204,231,151,
  145,111,145,170,170,234,13,94,242,48,150,37,234,59,
  149,42,2,151,82,133,245,169,77,222,64,33,106,157,
  191,225,134,196,92,148,91,62,210,107,44,177,140,
  100,11,103,146,63,213,210,5,100,210,78,92,165,233,
  226,102,199,223,34,226,65,243,26,193,138,165,197,
  12,123,190,123,5,76,15>>.  
