Shop OBEX P1 Docs P2 Docs Learn Events
Securing IP (Again...) — Parallax Forums

Securing IP (Again...)

Chad GeorgeChad George Posts: 138
edited 2007-08-07 04:30 in Propeller 1
I know the issue of securing IP in the propeller has come up before, but I don't know if a definitive answer was ever given as to how to do this under the current limitations of the propeller.

After doing some thinking and research, here is the scheme that I've come up with. Of course there is some (temporary) security in just coming up with an obscure mechanism and sitting on it, but I believe a truly secure mechanism should be open to public scrutiny so I'm very interested in opinions and potential weaknesses. I realize that nothing is 100% secure, but it just seems like it should be possible to have something reasonably secure using the currently available propeller (hopefully Prop2 will have something built in to help)

Just to be clear, my objective is to obtain a mechanism where secured (encrypted) IP code in the EEPROM can be loaded into the propeller.

I'm making the assumption that good cryptographic routines can be written for both the propeller and some external micro controller that does have some level of industry accepted IP protection (such as a PIC) I believe from other threads that a good random number generator has been developed which would be critical for the propeller side of things.

The algorithm is based on what I understand is possible using symmetric key encryption, but my crypto knowledge is fair from expert, so please correct me if I'm off track. I'll use a notation of KEY() to represent a function that encrypts with some key and the inverse function to represent decrypting with the key. I'm using two different forms of encryption: one where there is a private and public key as a set and one where there is just one key which can be used for both encryption or decryption.

I'm assuming the following basic hardware is in place. Of course just one EEPROM could be used for both EEPROM functions and certainly there are other options than a PIC but that is what I'll refer to.

Propeller <- Unsecured Boot EEPROM
Propeller <- Secured Micro (PIC) <- Encrypted EEPROM

I've attached a sequence diagram showing the basic flow of the proposed algorithm, but I'll discuss the main steps briefly to try to explain what I was thinking.

First a super secret key is used to encrypt the IP protected code stored in the EEPROM. This key is only stored in the PIC and it never exists outside of the PIC.

- At bootup or reset an unsecured bootstrap program is loaded into a cog. To prevent certain attacks I believe this must be an assembly routine so that it isn't using any Shared Memory.

- the bootstrap sends a start command to the PIC, which replies with a randomly generated public/private key (K0)

- the propeller uses K0 to encrypt its own randomly generated key K1 which is sent encrypted using K0 to the PIC


Now we should have a secret key known only to the Propeller and PIC that was never sent in plain text and also should never be the same twice. In order to try to prevent an emulation attack (either external or in circuit), the next phase uses the propeller like a "security dongle" by dynamically creating some a random validation program into the RAM of the currently running cog.

The validation program is sent in encrypted chunks and should be able to establish itself arbitrarily covertly by overwriting instructions, destination and source addresses directly in the RAM of the COG. This validation program can be as complicated as the designer deems necessary, but should definitely:
- manage to stop any other running cogs (so that some clever hacker doesn't snoop on Shared Memory)
- verify within reason that its actually a real propeller being run (not some emulation) probably by using timing routines
- the original unsecured bootstrap should be entirely wiped out so that only trusted code is being run. Alternatively a hash on the boot eeprom might be sufficient for some applications, but its seems possible that a "swap" could be made to trick the PIC so its probably best to make the check in software while running the trusted "random" validation program
- establish a new private key (K2) after we know that its only our secure code that is running (the original bootstrap has been completely wiped out)
- establish a random inital state variable (S0) which can be the seed of a deterministic pseudo random sequence


Now we can trust the code running in the propeller and we have secret keys to transfer the actual IP code securely

- The PIC reads a random block of the encrypted code from the secured EEPROM and decrypts it internally using its stored secret key. Which block to transfer is determined by the current pseudo-random state variable.

- The PIC re-encrypts the block code using the K2 key and sends it to the Propeller

- The propeller uses the K2 key to decrypt the code block and its state variable S0 to decide where to put it

- Both the PIC and Propeller generate the next pseudo-random state and the processes is repeated until the entire program is loaded into RAM.
2201 x 1701 - 57K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-02 05:18
    I see a big problem in the initial random number generation. What's to prevent a spoof of the initial generation of K1 so it's in fact a number designed to help break the public/private key generation in the PIC. The validation program could also be intercepted and monitored. In fact, since the Propeller was originally designed using a set of FPLAs, a Propeller could be simulated with complete monitoring.

    The issue that comes up over and over again is that any scheme is breakable given adequate resources (and incentive). It's possible to remove the potting compound from the PIC and monitor some of the signals in real time using an electron beam scanner if the need is great enough.

    The trick is coming up with a scheme that's cheap and easy enough to use without pricing your own product out of the market or rendering it too unreliable or slow, yet is expensive enough to break that nobody will bother trying until your product has been out on the market long enough for you to finish your own upgrade cycle and put out a cost-effect improved version that your thief will just have to break again.
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-08-02 05:50
    Why not just have your entire security in the securePic? And move some part of the system's high level details into the pic so that the user needs the pic.
    As for prop code security, Moore's dictum of misnamed objects may quite enough.
  • GadgetmanGadgetman Posts: 2,436
    edited 2007-08-02 07:39
    The problem as I see it is that the Bootstrap code isn't encrypted.
    This means it can be disassembled, understood and modified.

    When the second phase begins, and it begins loading the chunks of 'secure' loader, there's nothing to stop a hacked bootloader from passing the 'secure' program on through a serial link.
    The 'secure' program being in chunks just means the disassembly takes a bit longer.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • BaggersBaggers Posts: 3,019
    edited 2007-08-02 08:02
    Why not just get a PIC that has >64K ( or <32K if prog size isn't full 32K ) then put ALL the data for the prop code into the pic, to program the prop on startup [noparse]:)[/noparse] jobs a goodun.
  • mirrormirror Posts: 322
    edited 2007-08-02 09:19
    Baggers said...
    Why not just get a PIC that has >64K ( or <32K if prog size isn't full 32K ) then put ALL the data for the prop code into the pic, to program the prop on startup [noparse]:)[/noparse] jobs a goodun.
    Yeh, and then all you'd need is·a thing that behaves like a propeller to test it!
  • Chad GeorgeChad George Posts: 138
    edited 2007-08-02 13:00
    Mike said...
    What's to prevent a spoof of the initial generation of K1 so it's in fact a number designed to help break the public/private key generation in the PIC.

    Of course you could easily spoof the K1, but that will not directly help get to the secret key in the PIC that the EEPROM is encrypted with. The initial K0 key is a randomly generated public/private key created each time phase 1 is initiated. It is only used to encrypt the K1 key during transmission between the Propeller and the Prop, after that it is never used again. All of Phase 1 could be spoofed and I assumed that it would be, but it does setup an environment where you are forced to emulate the prop to get into Phase 2.
    Mike said...
    The validation program could also be intercepted and monitored.

    Yes, this is probably the weakest link, but the process can be as convoluted as the designer wants it to be. I intended on the validation program to build itself while running pieces of itself. All the while using periodic challenge/response phases that try to ensure the "real" program is running before sending anymore of the validation program. Also the validation program itself could change which challenges it creates every time it runs.
    Mike said...
    In fact, since the Propeller was originally designed using a set of FPLAs, a Propeller could be simulated with complete monitoring.

    Again I agree, but this seems like it would take an immense effort. Especially if the validation program used known characteristics of both SPIN, assembly and the propeller architecture. If timing between challenges was utilized it would pretty much rule out a software emulator. So any hardware emulation would have to first break all of the secured IP that parallax has in their product. I don't have much experience in this level hacking and maybe someone who does this all the time will correct me and say this is a trivial thing to solve, but unless it is much much easier than methods required to crack other "secured" microcontrollers it seems like this still might be a competitively secure scheme.

    Gadgetman said...
    The problem as I see it is that the Bootstrap code isn't encrypted.
    This means it can be disassembled, understood and modified.

    In order for this to actually be secure we have to go one step further and release the source for the bootstrap. The entire Phase 1 process should be completely open both on the secured PIC side and the Propeller. A potential hacker has to get through the obfuscation tricks in Phase 2 in order to see any of the secured code in the EEPROM and would have to break the PIC's IP protection scheme to get at the PIC side Phase 2 algorithm.
    Gadgetman said...
    When the second phase begins, and it begins loading the chunks of 'secure' loader, there's nothing to stop a hacked bootloader from passing the 'secure' program on through a serial link.
    The 'secure' program being in chunks just means the disassembly takes a bit longer.

    I agree but once Phase 2 does a little verification that its not dealing with an emulator (which could be a little different every time), the validation programs will completely stop the original bootloader (and any other cogs for that matter) so by the end of phase 2 its only secure code running.

    Unless someone sees an obvious way around it I think the only way to get through phase 2 is to "emulate" the propeller in hardware. And even if hardware emulation wasn't a problem there is still the issue of reversing all of the dynamic generated challenge/response scenarios.

    IMHO, if the only crack is breaking the IP protection used by "everyone else" or to somehow reverse all the "IP" that Parallax already has in the chip, then maybe this is good enough.
  • BaggersBaggers Posts: 3,019
    edited 2007-08-02 13:07
    mirror said...
    Baggers said...
    Why not just get a PIC that has >64K ( or <32K if prog size isn't full 32K ) then put ALL the data for the prop code into the pic, to program the prop on startup [noparse]:)[/noparse] jobs a goodun.

    Yeh, and then all you'd need is·a thing that behaves like a propeller to test it!
    ? the prop would behave like a propeller [noparse]:)[/noparse] not quite sure what you were on about?, the app is on the pic, which is downloaded to the prop, through rs232, like when PC is connected to prop, could remove i2c eeprom then too unless it was required [noparse]:)[/noparse]
  • evanhevanh Posts: 15,425
    edited 2007-08-02 14:36
    Is the built-in 32kB ROM of the Propeller not rewritable? Can't that be used?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-02 14:51
    The Propeller's 32kB of ROM is what is known as "masked ROM". Its contents are permanently defined by the masks used to make the chip and it cannot be changed. That's why it's known as Read-Only-Memory
  • evanhevanh Posts: 15,425
    edited 2007-08-02 15:13
    Ok, thanks. Just assumed it was something more. Not that many block memories are real masks now.
  • RoadsterRoadster Posts: 209
    edited 2007-08-02 17:23
    I had a thought of a different angle, why not have a pic emulate the programing the propeller from a PC to the propellers ram then the EEprom is not even needed
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-08-02 17:44
    The issue is that for it to be secure the stream has to be encrypted, otherwise one need only mimic the Propeller either trying to load the EEPROM or as a download target to receive the unencrypted contents. Some form of private key within the Propeller that is write-only is needed to appropriately secure the code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • evanhevanh Posts: 15,425
    edited 2007-08-03 11:11
    To be perfectly honest, since I have to fix this sort of stuff, I much prefer equipment with separate EPROM chips that can be copied in case of damage. Replacing the individual chips and burnt tracks on the PCB is way easier than trying to acquire the program from the manufacture that is usually long out of business.
  • BaggersBaggers Posts: 3,019
    edited 2007-08-03 11:33
    Roadster said...
    I had a thought of a different angle, why not have a pic emulate the programing the propeller from a PC to the propellers ram then the EEprom is not even needed

    Isn't that what·I said 4 posts prior?

    "the app is on the pic, which is downloaded to the prop, through rs232, like when PC is connected to prop, could remove i2c eeprom then too unless it was required [noparse]:)[/noparse]"

    But that could then be hacked, like Paul Baker·said, because they remove the pic, and emulate a prop reading it.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-08-07 04:30
    At one point, I was proposing an idea based on some fuses inside the Propeller that could only be read by the Propeller itself. The idea would be to have inside the Propeller ROM a decrypt function. When the Prop powers up, the ROM code checks the fuse for a decryption key and uses that to decrypt the ciphertext stored in the external EEPROM. The fuse would be user programmable. It must not be possible for a user program to read the fuse contents.

    One possible cipher/decipher pair could be a PRBG where the key is simply a seed that is common to the fuse in the Propeller and the PC.

    In the meantime, use epoxy glue. Fundamentally, anything the current Prop loads externally at boot up can be copied and studied.
    Frank
Sign In or Register to comment.