From c0ed47f02dddd436fe458361e85da82d324ab1aa Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Wed, 20 Feb 2019 02:39:06 +0000 Subject: support winter time --- decode.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/decode.pl b/decode.pl index 4a7ab27..0bc1151 100755 --- a/decode.pl +++ b/decode.pl @@ -74,9 +74,10 @@ sub le_bcd_to_int($) { # extract ciphertext and key from three consecutive bit strings sub extract($$$) { my ( $d0, $d1, $d2 ) = @_; - + my $data = ""; my $key = ""; + my $cest = ""; $data .= substr( $d0, 2, 6 ); $data .= substr( $d0, 9, 6 ); @@ -90,7 +91,9 @@ sub extract($$$) { $key .= substr( $d1, 42, 3 ); # day of week $key .= substr( $d1, 50, 8 ); # year - return ( $data, $key ); + $cest = substr( $d1, 17, 1 ); # cest + + return ( $data, $key, $cest ); } ######################################################### CRYPTO @@ -98,7 +101,7 @@ sub extract($$$) { # So this is almost DES with the following changes: # # 1) There's no initial or final permutation -# 2) the block size is 40 bits, half blocks are 32bits +# 2) the block size is 40 bits, half blocks are 20 bits # 3) There's no permuted choice 1, permuted choice 2 is different. # 4) Rounds 8,7 and 3 have a double rotation for the key # 5) The expansion permutation is replaced with a choice followed by catenation. @@ -437,7 +440,7 @@ my @heavy_lut = ( 'gusts in nighttime', 'freezing rain during morning', 'freezing rain during afternoon', - 'freezing rain during night', + 'freezing rain during night', 'dust', 'ozone', @@ -711,7 +714,7 @@ while () { } for ( my $i = 0 ; $i < ( $n - 2 ) ; ++$i ) { - my ( $data_bits, $key_bits ) = + my ( $data_bits, $key_bits,$cest ) = extract( $d->[$i], $d->[ $i + 1 ], $d->[ $i + 2 ] ); my $min = le_bcd_to_int( substr( $key_bits, 0, 8 ) ); @@ -725,6 +728,12 @@ for ( my $i = 0 ; $i < ( $n - 2 ) ; ++$i ) { next unless ( $mins_since_midnight % 3 ) == 2; + $mins_since_midnight+=60 if $cest == "0"; + + $mins_since_midnight-=1440 while $mins_since_midnight>1440; + + + my $plain = decrypt( $data_bits, $key_bits ); next unless defined $plain; -- cgit v1.2.3