Menu

#16 Extending Rijndael for Arduino

1.0
accepted
None
2015-04-14
2015-03-25
No

Rijndael's precomputed values needs to be stored in SRAM. This could be an issue in RAM constrained devices like ARDUINO.
Purposal is to shift pre-conputed values from SRAM to flash for arduino 2560.

Discussion

  • Olaf Bergmann

    Olaf Bergmann - 2015-03-25
    • status: open --> accepted
    • assigned_to: Olaf Bergmann
     
  • Olaf Bergmann

    Olaf Bergmann - 2015-03-25

    Yes, that's one thing on the TODO list from which not only the 2560 can benefit.

     
  • Randeep Singh

    Randeep Singh - 2015-03-25

    We have already created and tested the patch on Arduino Mega2560. I Could share it or i can contribute it to repo.

    Randeep Singh
    Samsung Electronics.

     

    Last edit: Randeep Singh 2015-03-25
  • Olaf Bergmann

    Olaf Bergmann - 2015-03-25

    Awesome! It would be great if you could provide a patch created with git format-patch.

     
  • Joerg Hubschneider

    To keep the source more readable, I would propose to use the preprocessor in a modified way (rijndael.c):

    ....
    #include "rijndael.h"
    
    #if defined(ARDUINO)
      #include <avr/pgmspace.h>
      #define _R  pgm_read_dword   // Static Const Read 32bit/DWORD!
    #else
      #define PROGMEM              // not applicable: nothing!
      #define _R *                 // results in: *(&XY) 
    #endif
    
    #undef FULL_UNROLL
    ...
    

    usage (e.g.):

    ...
    (_R(&Te4[(temp >> 16) & 0xff]) & 0xff000000) ^
    ...
    

    apropos: in my IDE I have to:

    #include <avr/pgmspace.h>
    
     

    Last edit: Joerg Hubschneider 2015-04-14
  • Olaf Bergmann

    Olaf Bergmann - 2015-04-09

    Thanks, this was one of the "minor tweaks needed" I was referring to in a related discussion.

     
  • Joerg Hubschneider

    additional very useful info about Mega2560:
    some old bootloader revisions does have a special feature:
    "!!!" or 0x212121 was a special bootloader command, ... waiting input!
    It was not possible to flush images containing that.
    http://forum.arduino.cc/index.php?topic=232014.0
    ... you can find this pattern in the AES tables!. These boards have to be flushed with as ISP-Programmer with a new bootloader revision and the world looks pretty well .

     
  • Olaf Bergmann

    Olaf Bergmann - 2015-04-14

    Uh, yes, good catch! In another project, I have spent hours debugging before I found that the bootloader caused the issue.

    While in theory, you could work around that, I tend to just document it as an open issue for now. What do you think?