]>
git.zerfleddert.de Git - fhem-stuff/blob - HMLAN/HMLAN_CRYPT.pm
7 my ($self, $ciphertext) = @_;
11 if($self->{'keystream'}) {
14 if (length($self->{'keystream'}) > length($ciphertext)) {
15 $len = length($ciphertext);
17 $len = length($self->{'keystream'});
20 my $cpart = substr($ciphertext, 0, $len);
21 my $kpart = substr($self->{'keystream'}, 0, $len);
23 $ciphertext = substr($ciphertext, $len);
24 $self->{'keystream'} = substr($self->{'keystream'}, $len);
26 $self->{'ciphertext'} .= $cpart;
28 $plaintext .= $cpart ^ $kpart;
30 $self->{'keystream'} = $self->{'cipher'}->encrypt($self->{'ciphertext'});
31 $self->{'ciphertext'}='';
40 my ($self, $plaintext) = @_;
44 if($self->{'keystream'}) {
47 if (length($self->{'keystream'}) > length($plaintext)) {
48 $len = length($plaintext);
50 $len = length($self->{'keystream'});
53 my $ppart = substr($plaintext, 0, $len);
54 my $kpart = substr($self->{'keystream'}, 0, $len);
56 $plaintext = substr($plaintext, $len);
57 $self->{'keystream'} = substr($self->{'keystream'}, $len);
59 $self->{'ciphertext'} .= $ppart ^ $kpart;
61 $ciphertext .= $ppart ^ $kpart;
63 $self->{'keystream'} = $self->{'cipher'}->encrypt($self->{'ciphertext'});
64 $self->{'ciphertext'}='';
78 cipher
=> Crypt
::Rijndael
->new($key, Crypt
::Rijndael
::MODE_ECB
()),