Mbed TLS is now part of TrustedFirmware.org.

mbedTLS on older ARM processors

Jul 25, 2016 12:14
Marian Kechlibar

I am currently trying to get mbedTLS running on older Symbian devices like Nokia E52.

--------- Long explanation why I do that - feel free to skip it if not interested ---------

That is an ancient platform by the standards of the contemporary mobile world (released 2009), but it still has some popularity among older managers etc., who value the Symbian platform for reliability, long battery life, lack of viruses etc. So even now clones of E52 and similar phones are being produced in China, even though Nokia itself has abandoned the platform. I am currently taking care of a few hundred people who still use Symbians.

Now one of the problems is that Symbian OS supports TLS 1.0 only and does not support certificates with SHA-256. The latter problem is partially solved by installation of networking_improvements.sis, which had been published by Nokia before it abandoned the platform entirely. It works only partially and only on some devices, though. The former problem (lack of support for TLS 1.1 and newer) was never addressed by Nokia, Symbian Foundation etc.

Hence, mbedTLS to the rescue.

--------- End of the long explanation --------

I was able to get the library up and running on those devices. The modifications were insignificant, practically none. But the problem is - the handshake is really slow. It takes several seconds to perform all the necessary bigint operations. For comparison, the native Symbian libraries take about 0.5 to 0.7 seconds per handshake on the same connections.

The devices that I am interested in have ARM11 processor at 600 MHz, single core. With correct ASM code, the handshake should really be quicker. I compile the code with the ARM compiler of version 2.2 (because later versions cannot be used with Series 60 SDKs) and, unfortunately, the preprocessor macros in bn_mul.h won't recognize this environment as ARM.

Could you help me in this regard? Is the ARM-specific ASM code usable on ARM11 processors? How should I change the preprocessor macros in bn_mul.h in order to try it?

Aug 3, 2016 10:27
Paul Bakker

To start you could just remove all non-relevant pre-processor code from bn_mul.h and just have the ARM assembly definitions there.

Aug 8, 2016 09:59
Marian Kechlibar

OK, I will try, but which of the blocks of ASM code is the correct one for the indicated platform?

Aug 8, 2016 11:50
Paul Bakker

You'll have to check, but I'd assume this one could work:

#define MULADDC_INIT                            \
    asm( "ldr    r0, %0         " :: "m" (s));  \
    asm( "ldr    r1, %0         " :: "m" (d));  \
    asm( "ldr    r2, %0         " :: "m" (c));  \
    asm( "ldr    r3, %0         " :: "m" (b));

#define MULADDC_CORE                            \
    asm( "ldr    r4, [r0], #4   " );            \
    asm( "mov    r5, #0         " );            \
    asm( "ldr    r6, [r1]       " );            \
    asm( "umlal  r2, r5, r3, r4 " );            \
    asm( "adds   r7, r6, r2     " );            \
    asm( "adc    r2, r5, #0     " );            \
    asm( "str    r7, [r1], #4   " );

#define MULADDC_STOP                            \
    asm( "str    r2, %0         " : "=m" (c));  \
    asm( "str    r1, %0         " : "=m" (d));  \
    asm( "str    r0, %0         " : "=m" (s) :: \
    "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7" );