aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-10-23 15:45:01 +0200
committerTeddy Wing2018-10-23 15:45:01 +0200
commiteb970dc9f199acaa003abd517fbdc736563021e8 (patch)
tree458f5e79b4a7ce07ff75c68d4e7f9bb1589f5eff
parentc7a4a028cbeda1eb50e71b92b0c725d1d0cb02c9 (diff)
downloaddome-key-map-eb970dc9f199acaa003abd517fbdc736563021e8.tar.bz2
decode_datetime(): Fix incorrect encoded & IV string splitting
I was using `rsplitn` to split the encoded value into an encrypted timestamp and initialisation vector. Originally, I had used `splitn`, but upon discovering `rsplitn` decided to use that instead to ensure we captured the initialisation vector first, and that anything else would be captured to a single string. Didn't realise, though, that `rsplitn` orders element in reverse order compared to `splitn`. Correct the capture order.
-rw-r--r--src/trial.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/trial.rs b/src/trial.rs
index 38c8a82..0d94108 100644
--- a/src/trial.rs
+++ b/src/trial.rs
@@ -150,8 +150,8 @@ fn decode_datetime(
s: &str
) -> result::Result<DateTime<FixedOffset>, DateCryptError> {
let encrypted: Vec<_> = s.rsplitn(2, "//").collect();
- let timestamp = encrypted[0];
- let iv = encrypted[1];
+ let timestamp = encrypted[1];
+ let iv = encrypted[0];
let mut mc = MagicCrypt::new(KEY, magic_crypt::SecureBit::Bit64, Some(&iv));