freemyipod r722 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r721‎ | r722 | r723 >
Date:23:40, 4 July 2011
Author:theseven
Status:new
Tags:
Comment:
ipodcrypt: Implement s5l8720-genpwnage
Modified paths:
  • /emcore/trunk/tools/ipodcrypt.py (modified) (history)
  • /emcore/trunk/tools/libipodcrypto.py (modified) (history)

Diff [purge]

Index: emcore/trunk/tools/ipodcrypt.py
@@ -38,6 +38,7 @@
3939 print " s5l8702-cryptnor <infile> <outfile>"
4040 print " s5l8702-decryptnor <infile> <outfile>"
4141 print " s5l8702-genpwnage <infile> <outfile>"
 42+ print " s5l8720-genpwnage <infile> <outfile>"
4243 exit(2)
4344
4445
@@ -65,6 +66,9 @@
6667 elif argv[1] == "s5l8702-genpwnage":
6768 libipodcrypto.s5l8702genpwnagefile(argv[2], argv[3])
6869
 70+ elif argv[1] == "s5l8720-genpwnage":
 71+ libipodcrypto.s5l8720genpwnagefile(argv[2], argv[3])
 72+
6973 else: usage()
7074
7175
Index: emcore/trunk/tools/libipodcrypto.py
@@ -119,6 +119,19 @@
120120 return data
121121
122122
 123+def s5l8720genpwnage(data):
 124+ cert = open(os.path.dirname(__file__) + "/libipodcrypto/s5l8720pwnage.cer", "rb").read()
 125+ data = data.ljust(max(0x640, (len(data) + 0xf) & ~0xf), "\0")
 126+ header = ("87202.0\x03\0\0\0\0" + struct.pack("<IIII", len(data) - 0x630, len(data) - 0x2f2, len(data) - 0x5b0, 0x2be)).ljust(0x40, "\0")
 127+ emcore = libemcore.Emcore()
 128+ addr = emcore.memalign(0x10, len(data))
 129+ emcore.write(addr, header + hashlib.sha1(header).digest()[:0x10])
 130+ emcore.aesencrypt(addr + 0x40, 0x10, 1)
 131+ data = emcore.read(addr, 0x50) + data + cert.ljust((len(cert) + 0xf) & ~0xf, "\0")
 132+ emcore.free(addr)
 133+ return data
 134+
 135+
123136 def s5l8701cryptdfufile(infile, outfile):
124137 infile = open(infile, "rb")
125138 outfile = open(outfile, "wb")
@@ -173,3 +186,11 @@
174187 outfile.write(s5l8702genpwnage(infile.read()))
175188 infile.close()
176189 outfile.close()
 190+
 191+
 192+def s5l8720genpwnagefile(infile, outfile):
 193+ infile = open(infile, "rb")
 194+ outfile = open(outfile, "wb")
 195+ outfile.write(s5l8720genpwnage(infile.read()))
 196+ infile.close()
 197+ outfile.close()

Follow-up revisions

RevisionCommit summaryAuthorDate
r724Fix bug from r722: Add missing filetheseven23:44, 4 July 2011