Omnimaga
Calculator Community => TI Calculators => General Calculator Help => Topic started by: SirCmpwn on December 31, 2010, 08:56:52 pm
-
Hello,
How would I programmatically sign an app or OS?
-
Programmatically? What exactly do you mean? There is RabbitSign (http://www.ticalc.org/archives/files/fileinfo/420/42035.html) if you need a program.
-
Moved to calc help since this isn't exclusively KOS-related
-
How does RabbitSign work, I mean.
-
It takes an unsigned .8xu and signs it. For an idea of how it works (and what other tools you need), you can look at my build script here (http://partesos.googlecode.com/svn-history/r12/trunk/build.bat)
Relevant lines:
..\tools\ostools-0.1\multihex 00 "Page $00.hex" 1D "Page $1D.hex" > os.hex
..\tools\ostools-0.1\packxxu os.hex -o os84.8xu -t 83p -q 0A -v 0.01 -h 255
..\tools\rabbitsign\rabbitsign -t 8xu -k ..\tools\keys\0A.key -K 0A -g -p -r os84.8xu
multihex (part of OS Tools (http://www.ticalc.org/archives/files/fileinfo/413/41336.html)) takes alternating page numbers and hex files for each page and generates a hex file for the whole OS.
packxxu, also from OS Tools, takes the unsigned hex file, a key ID, and a couple other things and generates an unsigned .8xu
rabbitsign, linked above, takes the key and the unsigned .8xu file and produces a signed one.
-
That's what it *does,* I want to know how it does it.
-
As in, to write a tool yourself? Rabbitsign is opensource (written in C), so you could look at the source. I don't know the details, sorry :/
-
That's what I'm planning, for tiDE. Thanks for the help :)
-
I think it uses the rabin Algorithm, yes?
-
Where is that algorithm documented?
-
From BrandonW on IRC
[23:14:25] <+BrandonW> A signature is an RSA-encrypted MD5 hash of the data you're wanting to sign.
[23:14:54] <+BrandonW> So you just MD5 hash the contents, and then encrypt it with 512-bit RSA using the private key associated with the ID you're wanting to sign with.
[23:15:15] <+BrandonW> So for example, to sign an OS with the 04 key, you take the 04 private key and use it to encrypt the MD5 hash of the OS.
-
Oh, okay. And where does the signature data go?
-
At the en of the file, iirc. I believe you can use rabbitsign to see if the hash is correct. Md5 hashes are implemented in most popular languages.
-
That's a pretty loaded question and would take a while to answer. At the risk of sounding rude, I would recommend reading the source to see where it puts the signature after it calculates it ("MD5" and "Rabin"/"RSA" are things to look for to find where it calculates the signature and then does something with it).
-
Thanks, will do.
-
To be clear: RabbitSign implements both application and OS signing, which work somewhat differently, both in terms of the file formats, and in terms of the algorithms used (Rabin for Z80 applications; RSA for 68k apps and both Z80 and 68k OSes.) Are you interested in signing apps, or OSes, or both?
You may want to read up on the Rabin (http://en.wikipedia.org/wiki/Rabin_cryptosystem) and RSA (http://en.wikipedia.org/wiki/RSA) algorithms before trying to understand how TI's system works.
-
He's probably interested in signing OSes, for KOS.
EDIT: or this is for tiDE, in which case, both.
-
Well, to compute an OS signature, you take the MD5 hash of the complete OS (the OS header followed by each of the pages, in the order they're listed in the 8xu file), and sign that number using RSA, with a validation exponent of 17 decimal (if x is the MD5 hash, you want to find s such that s17 ≡ x mod n.)
The signature, then, consists of the bytes 02 0D, followed by the length of s (in bytes), followed by the bytes of s in little-endian order (least significant first.) Look at the OS files from TI to see how it's stored in the 8xu file.
-
Well, to compute an OS signature, you take the MD5 hash of the complete OS (the OS header followed by each of the pages, in the order they're listed in the 8xu file), and sign that number using RSA, with a validation exponent of 17 decimal (if x is the MD5 hash, you want to find s such that s17 ≡ x mod n.)
The signature, then, consists of the bytes 02 0D, followed by the length of s (in bytes), followed by the bytes of s in little-endian order (least significant first.) Look at the OS files from TI to see how it's stored in the 8xu file.
the "=" in "s17 ≡ x mod n" is supposed to be congruence, correct?
-
That's right.