comparison libtomcrypt/notes/tech0003.txt @ 285:1b9e69c058d2

propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 20dccfc09627970a312d77fb41dc2970b62689c3) to branch 'au.asn.ucc.matt.dropbear' (head fdf4a7a3b97ae5046139915de7e40399cceb2c01)
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 13:23:58 +0000
parents
children 6dba84798cd5
comparison
equal deleted inserted replaced
281:997e6f7dc01e 285:1b9e69c058d2
1 Tech Note 0003
2 Minimizing Memory Usage
3 Tom St Denis
4
5 Introduction
6 ------------
7
8 For the most part the library can get by with around 20KB of stack and about 32KB of heap even if you use the
9 public key functions. If all you plan on using are the hashes and ciphers than only about 1KB of stack is required
10 and no heap.
11
12 To save space all of the symmetric key scheduled keys are stored in a union called "symmetric_key". This means the
13 size of a symmetric_key is the size of the largest scheduled key. By removing the ciphers you don't use from
14 the build you can minimize the size of this structure. For instance, by removing both Twofish and Blowfish the
15 size reduces to 768 bytes from the 4,256 bytes it would have been (on a 32-bit platform). Or if you remove
16 Blowfish and use Twofish with TWOFISH_SMALL defined its still 768 bytes. Even at its largest the structure is only
17 4KB which is normally not a problem for any platform.
18
19
20 Cipher Name | Size of scheduled key (bytes) |
21 ------------+-------------------------------|
22 Twofish | 4,256 |
23 Blowfish | 4,168 |
24 3DES | 768 |
25 SAFER+ | 532 |
26 Serpent | 528 |
27 Rijndael | 516 |
28 XTEA | 256 |
29 RC2 | 256 |
30 DES | 256 |
31 SAFER [#] | 217 |
32 RC5 | 204 |
33 Twofish [*] | 193 |
34 RC6 | 176 |
35 CAST5 | 132 |
36 Noekeon | 32 |
37 Skipjack | 10 |
38 ------------+-------------------------------/
39 Memory used per cipher on a 32-bit platform.
40
41 [*] For Twofish with TWOFISH_SMALL defined
42 [#] For all 64-bit SAFER ciphers.
43
44 Noekeon is a fairly fast cipher and uses very little memory. Ideally in low-ram platforms all other ciphers should be
45 left undefined and Noekeon should remain. While Noekeon is generally considered a secure block cipher (it is insecure
46 as a hash) CAST5 is perhaps a "runner-up" choice. CAST5 has been around longer (it is also known as CAST-128) and is
47 fairly fast as well.
48
49 You can easily accomplish this via the "config.pl" script. Simply answer "n" to all of the ciphers except the one you want
50 and then rebuild the library. [or you can hand edit mycrypt_custom.h]
51
52