summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2019-02-20 02:39:06 +0000
committerfishsoupisgood <github@madingley.org>2019-02-20 02:39:06 +0000
commitc0ed47f02dddd436fe458361e85da82d324ab1aa (patch)
treef8a7c295303adc3b6735c3c9cfabf65f7899e990
parentb08e6a83c05bc81bf6a7acb171eae596feceb77a (diff)
downloadmeteotime-c0ed47f02dddd436fe458361e85da82d324ab1aa.tar.gz
meteotime-c0ed47f02dddd436fe458361e85da82d324ab1aa.tar.bz2
meteotime-c0ed47f02dddd436fe458361e85da82d324ab1aa.zip
support winter timeHEADmaster
-rwxr-xr-xdecode.pl19
1 files 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 (<DATA>) {
}
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;