libtomcrypt on KEIL uVision

47 views
Skip to first unread message

Ehsan Ae

unread,
Dec 21, 2017, 12:14:26 PM12/21/17
to LibTom Projects
Hi

I am writing you to ask for advice about using libtomcrypt on KEIL uVision. 

I am running crypto algorithms on ARM processors to benchmark their performance and power consumption. This was somehow easier for block-ciphers. When is came to RSA, I got confused finding all the dependencies in libtommath and libtomcrypt to add them in my project. I didn't find a way to use your makefile in KEIL IDE.

I guess either my approach in adding library is not correct or I don't know a method to find all the required files in a timely manner. 

I appreciate your help in advance.

Kind Regards
Ehsan 

Steffen Jaeckel

unread,
Dec 21, 2017, 12:45:12 PM12/21/17
to lib...@googlegroups.com, Ehsan Ae
Hi Ehsan,

I guess building both libraries shouldn't be too much of a problem, even
with KEIL uVision.
I didn't use that for a long time, but some years ago it "worked for me"^TM

For ltm you can use pre_gen/mpi.c - the single-file version of ltm.
tommath_superclass.h should give you an idea of where to start when
trimming down ltm in functionality if required.

To build ltc you can take the src folder of the library and use this as
root for the project, set the include path to point to src/headers and
that should be it.

HTH,
Steffen
> --
> *** Please reply-to-all at all times ***
> *** (do not pretend to know who is subscribed and who is not) ***
> *** Please avoid top-posting. ***
> ---
> You received this message because you are subscribed to the Google
> Groups "LibTom Projects" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to libtom+un...@googlegroups.com
> <mailto:libtom+un...@googlegroups.com>.
> To post to this group, send email to lib...@googlegroups.com
> <mailto:lib...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/libtom.
> For more options, visit https://groups.google.com/d/optout.

--
Steffen Jaeckel - s_ja...@gmx.de
GnuPG fingerprint: C438 6A23 7ED4 3A47 5541 B942 7B2C D0DD 4BCF F59B
My OTR key has changed on 30. Sept. 2015!
jabber: jae...@jabber.ccc.de F052DE29 4FA9A02D 44A794E5 AE5AC0FB C5865C64

Ehsan Ae

unread,
Dec 23, 2017, 9:58:19 AM12/23/17
to LibTom Projects
Thanks Steffen. 

Good clue! It also worked for me too.
I built  ltc on KEIL. :)

Bests,

Ehsan Ae

unread,
Dec 25, 2017, 8:11:34 AM12/25/17
to LibTom Projects

This might be trivial question. 

I successfully built ltc library. I realized that (for example) in "pk\rsa"  folder there are some files which use some functions begin with "mp_"   - e.g mp_mul() and mp_read_unsigned_bin(). These files exist in ltm library and not in ltc "math" folder.  I wondered how ltc was successfully built without these files? 

Steffen Jaeckel

unread,
Dec 25, 2017, 8:58:06 AM12/25/17
to lib...@googlegroups.com, Ehsan Ae
Well I wouldn't call it trivial... :D it's one of the quirks of ltc...
you have to define LTC_SOURCE when building ltc, but don't define it
when building your application. This enables the macros in
headers/tomcrypt_math.h which resolve then to the MPI provider.
Remember that you also have to choose an MPI provider at compile-time of
ltc... but that's explained in the crypt.pdf... if it's unclear feel
free to mention what's missing!

Cheers,
Steffen
> <https://groups.google.com/group/libtom>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.

Ehsan Ae

unread,
Jan 7, 2018, 1:11:13 PM1/7/18
to LibTom Projects

Happy new year steffen! 

I successfully built the RSA key encryption sample (from crypto.pdf) on KEIL and in the meanwhile enjoyed the level of modularity you made using C (and not C++ :) ).

I fact, the program size is something around 500KB now, while my device has only 128KB ROM. I made an effort on the compiler to trim all unused functions ( specifically in mpi.c) automatically but still not sure how much compact ltc could be.

I was wondering if you had rough code size numbers from the times you have linked the library? I know the underlying CPU architecture can significantly affect the machine code size, but I can still figure out to buy another device or still continuing with code optimization. 

Thanks
Ehsan

Steffen Jaeckel

unread,
Jan 11, 2018, 8:33:32 AM1/11/18
to lib...@googlegroups.com
Hi Ehsan,

On 01/07/2018 07:11 PM, Ehsan Ae wrote:
>
> Happy new year steffen!

thanks! to you too.

> I successfully built the RSA key encryption sample (from crypto.pdf) on
> KEIL and in the meanwhile enjoyed the level of modularity you made using
> C (and not C++ :) ).

You have to thank Tom ;)

> I fact, the program size is something around 500KB now, while my device
> has only 128KB ROM. I made an effort on the compiler to trim all unused
> functions ( specifically in mpi.c) automatically but still not sure how
> much compact ltc could be.

Uhm, I luckily never had to squeeze it that much...

> I was wondering if you had rough code size numbers from the times you
> have linked the library? I know the underlying CPU architecture can
> significantly affect the machine code size, but I can still figure out
> to buy another device or still continuing with code optimization.

Sorry, I can't give you any real numbers.
But I'll be happy to see some :)

I've just built mpi.o and the comment regarding RSA-only compilation in
tommath_superclass.h should be revised...

I tried building:

x86_64: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5)
i386: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) with "-m32"
ARM: gcc-arm-none-eabi-5_4-2016q3 5.4.1

with "-O3":

x86_64 = 73KiB
i386 = 53KiB
ARM = 46KiB

with "-Os":

x86_64 = 31KiB
i386 = 23KiB
ARM = 21KiB



I only built mpi.o, didn't build an application from it neither test it,
but from these numbers I guess it should be possible to squeeze an RSA
test in 128KiB ROM... more ROM would as usual be better as it would ease
a lot of things...
FYI: I'm pretty sure you'll have to strip down ltc by hand to be able to
fit the tests in 128K. ltc is somewhat configurable, but not down to
that level.


Cheers,
Steffen
> > an email to libtom+un...@googlegroups.com <javascript:>
> > <mailto:libtom+un...@googlegroups.com <javascript:>>.
> > To post to this group, send email to lib...@googlegroups.com
> <javascript:>
> > <mailto:lib...@googlegroups.com <javascript:>>.
> Steffen Jaeckel - s_ja...@gmx.de <javascript:>
> GnuPG fingerprint:  C438 6A23 7ED4 3A47 5541 B942 7B2C D0DD 4BCF F59B
> My OTR key has changed on 30. Sept. 2015!
> jabber: jae...@jabber.ccc.de <javascript:> F052DE29 4FA9A02D
Reply all
Reply to author
Forward
0 new messages