]>
git.zerfleddert.de Git - fhem-stuff/blob - HMLAN/hmlan-crypt-test.pl
3 # key can either be 32 HEX chars (HMLAN) or a password (wired gateway)
4 #my $key="00112233445566778899AABBCCDDEEFF";
7 my $key="00112233445566778899AABBCCDDEEFF";
10 my $hmlan="192.168.1.2";
14 push @INC, dirname
($0);
22 #This should be random...
23 my $my_iv = '00112233445566778899AABBCCDDEEFF';
26 my $sock = IO
::Socket
::INET
->new(
32 my $read_set = new IO
::Select
();
33 $read_set->add($sock);
35 $read_set->can_read();
37 chomp(my $iv = <$sock>);
43 if ($iv =~ /^V(................................)\r$/) {
45 print $sock "V${my_iv}\r\n";
46 } elsif ($iv =~ /^V(..),(................................)\r$/) {
48 print $sock "V01,${my_iv}\r\n";
50 print STDERR
"Unknown IV received: ${iv}\n";
54 if (length($key) < 32) {
55 $key = Digest
::MD5
::md5
($key);
57 $key = pack("H*", $key);
60 my $cipher_hmlan=HMLAN_CRYPT
->new($key, pack("H*", $my_iv));
61 my $cipher_pc=HMLAN_CRYPT
->new($key, pack("H*", $hmlan_iv));
63 $read_set->add(\
*STDIN
);
66 my @ready = $read_set->can_read();
67 foreach my $r (@ready) {
70 print $cipher_hmlan->decrypt($buf);
76 print $sock $cipher_pc->encrypt($buf);