I2C toy code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

53 regels
2.5 KiB

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