From 2d0e8a3188bfeccf8ad5d9642b21ba0a1fb74aa2 Mon Sep 17 00:00:00 2001 From: codestation Date: Sat, 23 Jul 2011 02:21:17 -0430 Subject: [PATCH] Fix sha1 generation for savedata. --- src/crypt/SavedataCypher.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/crypt/SavedataCypher.java b/src/crypt/SavedataCypher.java index 1630d09..2b5f522 100644 --- a/src/crypt/SavedataCypher.java +++ b/src/crypt/SavedataCypher.java @@ -110,15 +110,17 @@ public class SavedataCypher extends DecryptUtils implements SavedataKeys { } private void update_sha1(byte buf[]) { - int len = buf.length - 24; - len += savedata_sha1_key.length(); + byte replace[] = new byte[20]; + System.arraycopy(buf, buf.length - 36, replace, 0, 20); + System.arraycopy(savedata_sha1_key.getBytes(), 0, buf, buf.length - 36, 20); + int len = buf.length - 16; byte buffer[] = new byte[len]; - System.arraycopy(buf, 0, buffer, 0, len-savedata_sha1_key.length()); - System.arraycopy(savedata_sha1_key.getBytes(), 0, buffer, len-savedata_sha1_key.length(), savedata_sha1_key.length()); + System.arraycopy(buf, 0, buffer, 0, len); try { MessageDigest md = MessageDigest.getInstance("sha-1"); byte digest[] = md.digest(buffer); - System.arraycopy(digest, 0, buf, buf.length - 24, 0x10); + System.arraycopy(replace, 0, buf, buf.length - 36, 20); + System.arraycopy(digest, 0, buf, buf.length - 24, digest.length); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); }