View Single Post
Old 08-30-2009, 10:34 PM   #98
gatorfan
Member
gatorfan began at the beginning.
 
gatorfan's Avatar
 
Posts: 20
Karma: 28
Join Date: Aug 2009
Location: Arizona
Device: Kindle, Jetbook
Quote:
Originally Posted by Dowland View Post
Here comes a lengthy post to summarize the problem and give an actual solution. Please don't hesitate to reproduce this elsewhere. And also, please don't bury this post in the thread, because then nobody will ever find it ... :-)
*

Background info. A MobiPocket PID is 10 characters: 8 characters are the actual key, and 2 characters are the checksum.

Now, before doing its deed, MobileDRM looks at the PID you gave: it controls whether the checksum and the key actually correspond. If they dont, then it gives the error message we all know ("Error: invalid PID checksum"). If they do, then it cuts away the last 2 characters of the PID, and keeps only the key for the remainder of its operation.

Problem. The issue, at least in mobiledrm005.py, is that it accidentally repeats this operation twice (probably whoever wrote this did an unwitting double copy-paste). So scenario 1: your PID is incorrect, and it gets rejected on the first check. And scenario 2: your PID is correct, it passes the first check, gets shortened to its key component, and then flunks the second check.

Solution. Remove the first block from the initialization the code (as this is Python code, you have to be very careful with the indentation), i.e. change:
Code:
	def __init__(self, data_file, pid):

		if checksumPid(pid[0:-2]) != pid:
			raise DrmException("invalid PID checksum")
		pid = pid[0:-2]

		if checksumPid(pid[0:-2]) != pid:
			raise DrmException("invalid PID checksum")
		pid = pid[0:-2]
to:
Code:
	def __init__(self, data_file, pid):

		if checksumPid(pid[0:-2]) != pid:
			raise DrmException("invalid PID checksum")
		pid = pid[0:-2]
That line that appears twice "pid = pid[0:-2]", is what shortens the PID (it means "take all but the last two characters of this string and replace the original").

Outro. It may very well be that your PID is actually incorrect, and you should browse this thread for ways to find out.

Also: opening the book after buying it unnecessary (except if your vendor does some non-standard thing I've never heard about). If this seems like it works, than a possible explanation is that opening the book actually removes the DRM (and then running MobileDRM on it gives the appearance that it actually worked ...).

Finally: no, I've never seen (valid) MobiPocket PIDs with anything but uppercase alphanumerical characters...
After a week of trying to figure out exactly what I was doing wrong, including searching different internet sites, the above post solved my problem.

I thank you and my blood pressure thanks you!
gatorfan is offline   Reply With Quote