Design Article
Deciphering phone and embedded security - Part 2: What really happens during an unlock operation
Mohit Arora, Sr. Systems Engineer & Security Architect, Freescale Semiconductor
7/9/2012 8:30 AM EDT
Flashing erases and writes the MCU and PPM portion of the Flash and depending on the flashing method may or may not touch the CNT area but EEPROM is normally not updated. EEPROM also contains the phone's IMEI (International Mobile Equipment Identity) number that is unique to every phone. The IMEI is also contained in OTP memory that is part of application processor, where it is put at the factory and cannot be deleted or changed later, other than replacing the chip that contains it.
Apart from the IMEI number, EEPROM also includes "Lock Data" which is also unique. If someone during the Flashing process erases the IMEI number, the phone will be locked as this parameter is checked and matched with the IMEI number stored in the phone's OTP memory during boot.
Security is further enhanced by some of the Flash ID (FAID as called by some manufacturers) in EEPROM that is tied to the phone's IMEI number, firmware checksum, serial number of Flash chip and could include other parameters. Without matching FAID, the phone will not see the network, reboot every few seconds, and get all locks activated (process may slightly vary based on phone manufacturer). What that really means is even if you swap flash chips between two perfectly good smart phones, neither will work due to FAID mismatch.
One way to make the phone completely immune to unlocking is to store the "lock data"(a.k.a. Flash ID) in OTP memory instead of external EEPROM since data written in OTP memory cannot be changed. However this is not really desirable.
In most countries including the USA, operators like AT&T and Verizon offer phones at subsidized rates (or even free) if the customer purchases a long-term plan with a phone locked to the operator. On the expiry of the term, the customer can get the "unlock code" from the operator if one wishes to switch to a different operator.
In the first few generations of mobile phones, one could easily illegally do this by desoldering the Flash chip and reading it using external flash programmer hardware. Then the hacker could look at the resulting file to retrieve the code. Not anymore. Almost all phones today have at least some portion of the code encrypted, this includes the "unlock code", thus it is not directly readable (this is covered in detail in PART III).
Bypassing Internal bootloader
There are, in most phones, two bootloaders. One is in a small ROM area within the CPU chip. This is the first to start. Some phones don't have it. The other is in the beginning of flash address space. If you kill the flash bootloader, the ROM bootloader can still connect to the PC and let you flash the phone.
If there is no ROM bootloader and you kill the flash bootloader, the only way is to remove the flash chip and program it on an external programmer device. Phones without ROM bootloader usually have on-board contact points for JTAG interface, which allows direct access to flash and CPU busses.

On Power-up, Internal bootloader (as shown Figure 2) is initialized first. It checks if the Flash bootloader is present in the external Flash memory. If there is no Flash bootloader, it attempts to connect and load an external bootloader from system interface (usually without security checks).
When flash bootloader starts, it looks at the system interface again, to check for any attempts to load an external program. Unless the phone is in Factory mode, it will ask for some sort of valid key before it can load the external bootloader. The phone will still boot without a "valid key" but will not provide access to EEPROM (cannot be read or written). The same holds true for Flash ESN (Electronic Serial number) that is not readable in customer mode.
To get access to the complete phone (with no restrictions) it is necessary to enter this "valid key" which is selected randomly by the manufacture at production and encrypted in EEPROM. There could be other similar keys to, for example, to bypass the internal bootloader.
One way to fool or trick the phone is to make the ROM bootloader think that it has an empty flash bootloader (by cutting a PCB track or short-circuiting flash power to ground - via Testpoint). This temporarily disrupts power to the flash chip, allowing ROM bootloader to run an external bootloader on the phone. This bypasses any security checks allowing complete visibility of almost everything including ESN and IMEI, as well as EEPROM and any valid keys. Now you have all you need. One can read and write the entire phone memory, replace security blocks and do pretty much anything, including removing the service provider lock.
The reason one needs the testpoint is that the flash bootloader won't let you download and run anything without a proper digital signature (and this signing uses complex encryption which is not easy to crack). So, it's easier to disable the bootloader than to try and forge the signature for an external bootloader. Unlike older generation phones, the latest phones have this protection and thus need a testpoint to be able to bypass this security. Part III of the series will focus on signed and locked bootloaders.
Next: Unlock Code


Jeske
7/10/2012 7:05 AM EDT
It sounds weird to me an freescale specialist, giving away hints about ways to unlock smartphones...If I was a smatphone manufacturer, I'm not sure if I would be happy reading such articles.. for sure not the ones coming from the guins wo will be probably supporting new devs...
Sign in to Reply
Steve_B
7/10/2012 9:25 AM EDT
Look at the titles of Part III and IV. It's clear that if you use the lousy "security" approaches he's describing, your products are easily cracked. Want to bet me that future parts will describe something better? Something made by Freescale? ;-)
I used to work in this area. Cellphone security is complicated, and many chip and phone manufacturers are still on the steep part of the learning curve of how to do it. Phone hackers are extremely clever, and any half-hearted "security" system is going to be hacked - count on it.
Sign in to Reply
Steve_B
7/10/2012 9:31 AM EDT
Let me clarify. By "if you use the lousy "security" approaches he's describing", I meant in part 2. Part 3 looks like he's going to describe a trusted boot sequence. Pay close attention, it's table-stakes if you want to play this game ;-).
Sign in to Reply
Mohit.arora
7/17/2012 6:31 AM EDT
Thanks Steve, you are correct. Part 3 is going to cover all sort of secure bootloader options while Part 4 is going to extend it further covering ideal security platform that leverages the concepts from mobile world and apply on embedded/Industrial devices that need best in class security.
Sign in to Reply
Mohit.arora
7/17/2012 6:29 AM EDT
The whole idea was to take Smarphone as this as example so people could relate it better to the applications they know and then apply the concepts to embedded world.
Part 3 will include more details on secure bootloaders while Part 4 will extend it to cover idea security platform inherits capabilities from the mobile world and can be incorporated in future embedded devices.
Would be happy to receive any further feedback.
Sign in to Reply
gayatrikumar_1
7/10/2012 9:12 AM EDT
Ok, now, People know the secret.
Smart Phone Manufacturers will become smarter :)
Sign in to Reply
JustinTALA
7/10/2012 10:25 AM EDT
excellent article guyz.
@author
can you propose further reading please ?
I'm super interested.
Sign in to Reply
Mohit.arora
7/17/2012 6:32 AM EDT
Justin, Thanks. Next part should be up in next 2 weeks (I hope) or earlier :-)
Sign in to Reply
jzwatches
10/18/2012 12:29 AM EDT
Well, as a smartphone user, I'm not quite sure whether this article is supposed to benefit me as a consumer or is targetting phone manufacturers. I have a friend who used to own an iPhone. He found an article online that provided a method to "unlock" it and he was able to customize his iPhone with personalized tones and wallpapers. Thus, from his point of view as a consumer, such articles have benefited him in a way that he is able to use his phone the way he wants the phone to work, and not be restricted to only the default phone features. However, if this article is about ensuring that your phone is safe enough from hackers who wish to invade your privacy, then I'm definitely looking forward to the upcoming subsequent articles to tell me how to be on my guards.
- http://www.jzandf.com
Sign in to Reply