From 4426aa592e0795a4031f8905d8f1f968378ef37f Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Wed, 18 Mar 2009 17:23:37 +0000 Subject: [PATCH] Improve debugging. --- ykksm-decrypt.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ykksm-decrypt.php b/ykksm-decrypt.php index 9c5717e..01f0324 100644 --- a/ykksm-decrypt.php +++ b/ykksm-decrypt.php @@ -79,19 +79,20 @@ $internalName = $row['internalName']; $ciphertext = modhex2hex($modhex_ciphertext); $plaintext = aes128ecb_decrypt($aesKey, $ciphertext); -syslog(LOG_INFO, "OTP $otp OUT $plaintext") - or die("ERR Log error\n"); - if (!crc_is_good($plaintext)) { - syslog(LOG_ERR, "CRC error: $otp"); + syslog(LOG_ERR, "CRC error: $otp: $plaintext"); die("ERR Corrupt OTP\n"); } -if (strcmp(substr($plaintext, 0, 12), $internalName) != 0) { - syslog(LOG_ERR, "Internal name mismatch: $otp"); +$uid = substr($plaintext, 0, 12); +if (strcmp($uid, $internalName) != 0) { + syslog(LOG_ERR, "UID error: $otp $plaintext: $uid vs $internalName"); die("ERR Corrupt OTP\n");; } +syslog(LOG_INFO, "OTP $otp OUT $plaintext") + or die("ERR Log error\n"); + # Mask out interesting fields $counter = substr($plaintext, 14, 2) . substr($plaintext, 12, 2);