C Spot Run Digital Rights Management

The master for this site is at csrdrm.sourceforge.net and the backup is at durendal.org/csrdrm/. The master site will usually be more current.

Project hosted by SourceForge Logo


The DRM option for C Spot Run is an external library with decompression and decryption. If you were refered here by C Spot Run then you are missing a module of the form csrdrmXX.prc where the XX is some number and letter combination.

csrdrm00.prc is hosted here and has just zlib decompression in it. Zip file tgz file

csrdrm01.prc is hosted here and is just a demonstration encryption. You probably shouldn't run into it. Zip file tgz file

csrdrm02.prc is from Embiid Publishing. They use it for both a personalized book and a universal book. Their web site is www.embiid.net.

If you want to build books with zlib compression a modified txt2pdbdoc has support for writing doc files with zlib compression. A windows executable is hosted here. If you want to use it on Linux build from the sources.

If you are here because you are a publisher and want to make your own DRM library for C Spot Run I'll explain it a little. Don't forget to email me to assign you a number. The source for csrdrm00 and 01 is here and will be referenced during this explanation.

When you untar the csrdrm sources you will find a zlib tar file. This is the non-modified standard zlib 1.1.4 distribution. The standard zlib distribution is at www.gzip.org/zlib and the Palm version is at palmzlib.sourceforge.net. The zlib source directory used to build the library is slightly modified from the standard Palm version updated to 1.1.4.

The defs directory has the csrdrmlib.h file which defines the interface between C Spot Run and the libraries. The interface is a fairly standard Palm shared library. There are 7 entry points into the library. The standard open, close, sleep and wake plus three more. Since we don't care about sleep and wake the library just returns 0 and the header file doesn't define them. The main entry points of interest are csr_drm_lib_get_int_version, csr_drm_lib_get_decrypt and csr_drm_lib_decrypt.

csr_drm_lib_get_int_version is used to version the interface to the library. C Spot Run will pass in the interface version it wants to use, and the library will pass back the interface version it supports. The version number is 16 bits in size and is broken up into two bytes. The major version number is the high order byte and the minor version number is the low order byte. If the major version numbers don't match C Spot Run will not use the library.

csr_drm_lib_get_decrypt will return the address of the decrypt routine in the library. The decrypt routine is called directly, not through a trap. The etext and btext addresses of C Spot Run are also passed in. You can use this to perform your favorite encryption hash on the C Spot Run code to make sure it is a version of the reader you want to work with.

csr_drm_lib_decrypt is where the decryption and uncompression occur. The destination buffer in C Spot Run must have displayable text after this call. C Spot Run will always ask for a complete database record to be decompressed.

The database records will always have the uncompressed size in the first two bytes and the record data in the rest of the area. This size field does not get compressed or encrypted. C Spot Run may ask for records in a random order. It will not start at the begining and read through all of the records. The encryption/compression for each record should be independent of all other records.

When you make your customized library you will need to change the name in the csrdrm.c file. At the bottom of the assembly glue code is a line with the library name.

.asciz \"CSRDRM00\"

You will also have to change the name and creator id in the cdrdrm00.def file as well as rename the file.

syslib { "CSRDRM00" 'CS\xf3\x00' }

The last byte of the creator id changes to match the last part of the name.

The makefile also has the name of the library in it.

csrdrm01 has an example decrypt that just adds and subtracts 13 from each byte. You will want to replace this with your favorite encyption.

A modified txt2pdbdoc is the doc writer that has support for zlib compression and has the hooks for encryption. You will need to modify it with your favorite encyption. txt2pdbdoc is GPLed code also. If you modify the source and distribute an executable version of it you will need to distribute the source code changes as well.



© 2002 greg@durendal.org
This page was last changed on Wed Mar 20 20:35:01 CST 2002

Valid HTML 3.2!