(Ema_1, Unmasking/Decryption) – Reordering is the opposite of shuffling. The only difference is that the Reordering must start from the end of the masked byte block and the last index of the key.
Below is the reordering technique (unmasking) applied to the previous shuffling technique (masking) example.
KEY & DATA INDEX | KEY VALUES | DATA BEFORE Reordering | Reordering (UNMASKING) | DATA RESULT | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
000 | 006 | d | g | a | a | ||||||||||||||
001 | 007 | l | h | b | b | ||||||||||||||
002 | 015 | e | p | c | c | ||||||||||||||
003 | 000 | f | g | d | d | ||||||||||||||
004 | 002 | b | p | e | e | ||||||||||||||
005 | 009 | c | j | f | f | ||||||||||||||
006 | 013 | n | a | g | g | ||||||||||||||
007 | 008 | i | b | h | h | ||||||||||||||
008 | 004 | p | b | i | i | ||||||||||||||
009 | 010 | k | f | j | j | ||||||||||||||
010 | 003 | g | f | k | k | ||||||||||||||
011 | 012 | a | m | l | l | ||||||||||||||
012 | 014 | o | l | m | m | ||||||||||||||
013 | 011 | m | a | n | n | ||||||||||||||
014 | 001 | h | l | o | o | ||||||||||||||
015 | 005 | j | c | p | p | ||||||||||||||
015 | 014 | 013 | 012 | 011 | 010 | 009 | 008 | 007 | 006 | 005 | 004 | 003 | 002 | 001 | 000 |
Example of reordering in unmasking/decrypting stage
1. key(15)=5, j → data(5), c → data(15)
2. key(14)=1, h → data(1), l → data(14)
3. key(13)=11, m → data(11), a → data(13)
4. key(12)=14, o → data(14), l → data(12)
and so on.
As you can see from the example, at the end of the Reordering we can reconstruct the original order (the rightmost element for each row). Unlike the other techniques, in reordering we start from the end of the block and the end of the key.
From a computational point of view, all that is required is to overwrite the elements of an array, and the speed of execution is the same as for the shuffling technique.
Note
We have seen how, at a theoretical level, the masking and unmasking steps work to encrypt and decrypt a data source with Ema_0 and Ema_1, the techniques of replacement and substitution and shuffling and reordering are completely independent.
Ema_0 can be used for all types of data, especially for text files or data sources that are easily recognisable.
Ema_1 can be used for all types of data, but for plain text files, it should first be compressed or masked by Ema_0.
EMA uses both, Ema_0 and Ema_1 techniques at the same time.