CAUTION: This cryptographic algorithm is not in any standard and its security is not yet verified.
RichadoWonosas's Symmetric Encryption Version 2 (RWSE2) is an encryption algorithm designed by RichadoWonosas. Despite version 2, it is the first published version. The design is deeply affected by Rijndael.
RWSE2 is based on the design principle of Substitution-Permutation Network (SPN). RWSE2 is a block cipher with a fixed block size of 256 bits and a key size of 256, 384 or 512 bits.
Bigger key size requires more rounds of operations to achieve stronger security, and the amount of rounds are as follows:
- 12 rounds for 256-bit keys.
- 15 rounds for 384-bit keys.
- 18 rounds for 512-bit keys.
Each round consists of several sub-operations, that includes:
-
Add Round Key (
$RK$ ): Adding the key of the corresponding round to the block. -
Substitute Bytes (
$SB$ ): Use a substitution box (S-box) per byte to make changes to the block. -
RW's Shuffle (
$SH$ ): A self-invertible linear transformation, that is, executing$SH$ operation twice in a row to a block results in the original block and equals to nothing happened.
Besides, an Expand Key operation is introduced for generating round keys from the original key.
Section 2 introduces notations of the block of the algorithm. RWSE2's structure is depicted in Section 3. Section 4 focuses on Add Round Key operation. In Section 5, we describe the construction about S-box and
RWSE2 has a 256-bit block for encryption or decryption. We use
Each quad-word has 8 bytes:
In other words,
Say the value of
In S-box, a byte
The whole RWSE2 algorithm has a special 0th round with other rounds:
stateDiagram
M: Plaintext
C: Ciphertext
RK0: Add Round Key
SH0: RW's Shuffle
SBn: Substitute Bytes
SHn: RW's Shuffle
RKn: Add Round Key
R0: Round 0
R+: Round = Round + 1
Rn: Round n
state if <<choice>>
M-->R0
R0-->R+
R+-->Rn
Rn-->if
if-->C: Final Round
if-->R+: Other\nRound
state R0 {
[*]-->RK0
RK0-->SH0
SH0-->[*]
}
state Rn {
[*]-->SBn
SBn-->SHn
SHn-->RKn
RKn-->[*]
}
Encryption and decryption shares the same structure, but decryption uses S-Box Inverse instead of S-Box itself, and some extra operations to the round key will be done. More details are in Section 7.2.
Every round uses 4 quad-words of round key to add round key to the block. Say
So the Add Round Key operation in
where operation
A substitution box (S-box) is used to perform the byte-wise substitution. The formula of S-box is
where the power operation defines on Galois Field
Specially, define
and the multiplication
The full S-Box and its inverse can be found in Appendix A.
A quad-word consists of 8 bytes. For quad-word
A block consists of 4 quad-words. For the block
RW's Shuffle is a sequence of three basic operations:
- Shuffle
$S$ : A permutation that only applies inside quad-words. - Mix Column
$M$ : A matrix multiplication with elements on$\text{GF}(2^8)$ , in which the matrix used is self-invertible. - Reshuffle
$S^{-1}$ : The inverse of Shuffle$S$ .
So the RW's Shuffle is defined as
The following chart shows the structure of RW's Shuffle.
flowchart LR
A[Original\nBlock]:::word
B[Shuffle]:::op
C[Mix\nColumn]:::op
D[Inverse\nShuffle]:::op
E[Shuffled\nBlock]:::word
classDef word fill:#edf,stroke:#96c,color:#639
classDef op fill:#def,stroke:#69c,color:#369
subgraph RW's Shuffle
direction LR
B-->C
C-->D
end
A-->B
D-->E
Two constants used for shuffle operation: Upper Mask
-
$u \oplus l = \text{0xffffffffffffffff} = (\underbrace{111 \dots 11}_{64})_2$ . -
$u \lll 8 = u$ ,$u \ggg 8 = u$ ,$l \lll 8 = l$ ,$l \ggg 8 = l$ , where$\lll$ and$\ggg$ represents cyclic left and right shift of quad-word.
The single shuffle operation
where
The single reshuffle operation, the inverse of the single shuffle operation, is defined as follows:
The following charts show the procedure of a single shuffle operation:
flowchart LR
subgraph Single Reshuffle
direction LR
A1[Original\nQ-word]
B1[Original\nUpper]
C1[Lower\nHalf]
D1[Upper\nHalf]
E1[Shifted\nQ-word]
F1[Shuffled\nQ-word]
F1--Cyclic\nLeft Shift-->E1
E1--Upper\nMask-->D1
D1--Cyclic\nRight Shift--->B1
E1--Lower\nMask-->C1
B1--Merge-->A1
C1--Merge--->A1
end
subgraph Single Shuffle
direction LR
A[Original\nQ-word]
B[Upper\nHalf]
C[Lower\nHalf]
D[Shifted\nUpper]
E[Merged\nQ-word]
F[Shuffled\nQ-word]
A--Upper\nMask-->B
A--Lower\nMask-->C
B--Cyclic\nLeft Shift--->D
D--Merge-->E
C--Merge--->E
E--Cyclic\nRight Shift-->F
end
Shuffle operation is defined as
with Reshuffle operation defined as
The Mix Column operation
Each byte represents an element on
The matrix
is a self-invertible matrix, that is,
So the Mix Column operation satisfies that
that is, the Mix Column operation is self-invertible.
RW's Shuffle
The Expand Key operation is to expand the inputted key into round keys. Notations of round keys are in Section 4.
For key length of 256/384/512 bits, say the key constant
and the amount of rounds
To protect the inputted key, a sequence of round constants is defined in bytes (
$$ \begin{align*} rc_i &= (02){16}^{i} \text{ in GF} (2^8), \ rcon_i &= \left[ \begin{matrix} rc{8i} & rc_{8i + 1} & rc_{8i + 2} & rc_{8i + 3} & rc_{8i + 4} & rc_{8i + 5} & rc_{8i + 6} & rc_{8i + 7} \ \end{matrix} \right]. \end{align*} $$
Let
In which
If the decryption structure is the same as the encryption structure depicted in Section 3, then the order of
Because
Because
S-Box:
_0 | _1 | _2 | _3 | _4 | _5 | _6 | _7 | _8 | _9 | _a | _b | _c | _d | _e | _f | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0_ | 28 | 50 | a7 | 91 | 08 | 8f | 2c | 61 | d6 | a3 | a0 | 79 | bd | 84 | 97 | 47 |
1_ | 46 | e1 | 9d | 5b | 1c | b7 | 98 | cd | 11 | 43 | 77 | 90 | af | f3 | ea | 26 |
2_ | 7d | 8c | f5 | a5 | ef | b0 | 70 | 78 | 1a | f8 | 51 | 00 | ed | ce | c8 | 87 |
3_ | 4e | 83 | 7f | f2 | 4d | 5a | bb | cb | 5e | 8a | ba | 6c | 22 | 4c | fd | c7 |
4_ | 0d | 19 | 21 | 95 | 39 | fe | 1e | c9 | 20 | 32 | 45 | 38 | 59 | 62 | 0f | 67 |
5_ | 99 | 6a | 6d | 85 | 30 | 3b | 80 | a6 | 36 | 74 | 49 | 6b | ca | f9 | f6 | 7c |
6_ | 2b | 89 | 63 | a8 | 1b | 5f | 2d | c6 | aa | 65 | e7 | d2 | 92 | d1 | 4b | 15 |
7_ | 72 | 06 | a2 | 07 | 05 | 7b | c3 | 3c | 68 | 13 | 3d | cf | 6f | fb | 88 | c4 |
8_ | d4 | dd | 18 | 86 | e9 | ff | b9 | b5 | e6 | 75 | ee | 17 | 0c | be | 5d | 53 |
9_ | 7e | 55 | 31 | 9c | fc | 60 | 71 | df | 66 | 3e | 16 | ab | c2 | 9b | 14 | d5 |
a_ | 7a | 64 | 40 | ae | 54 | 96 | e0 | 3a | 27 | da | f0 | 33 | e2 | 44 | 9f | 25 |
b_ | a4 | 48 | cc | b6 | 3f | b1 | d7 | 04 | dc | bf | fa | 2f | b8 | 12 | 9a | b3 |
c_ | a9 | bc | 23 | eb | 81 | 01 | 4a | b2 | 0e | c0 | e5 | ac | 2a | 2e | 1f | 6e |
d_ | 5c | f4 | 02 | 93 | 76 | 37 | d3 | 35 | ad | 8d | 52 | d9 | 29 | f7 | db | 57 |
e_ | 4f | 24 | 03 | 34 | 0a | f1 | 94 | 9e | 82 | d8 | 8e | 8b | 1d | 10 | e4 | 0b |
f_ | 56 | e8 | 58 | c5 | 73 | a1 | de | c1 | 42 | d0 | ec | 69 | b4 | 41 | 09 | e3 |
S-Box Inverse:
_0 | _1 | _2 | _3 | _4 | _5 | _6 | _7 | _8 | _9 | _a | _b | _c | _d | _e | _f | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0_ | 2b | c5 | d2 | e2 | b7 | 74 | 71 | 73 | 04 | fe | e4 | ef | 8c | 40 | c8 | 4e |
1_ | ed | 18 | bd | 79 | 9e | 6f | 9a | 8b | 82 | 41 | 28 | 64 | 14 | ec | 46 | ce |
2_ | 48 | 42 | 3c | c2 | e1 | af | 1f | a8 | 00 | dc | cc | 60 | 06 | 66 | cd | bb |
3_ | 54 | 92 | 49 | ab | e3 | d7 | 58 | d5 | 4b | 44 | a7 | 55 | 77 | 7a | 99 | b4 |
4_ | a2 | fd | f8 | 19 | ad | 4a | 10 | 0f | b1 | 5a | c6 | 6e | 3d | 34 | 30 | e0 |
5_ | 01 | 2a | da | 8f | a4 | 91 | f0 | df | f2 | 4c | 35 | 13 | d0 | 8e | 38 | 65 |
6_ | 95 | 07 | 4d | 62 | a1 | 69 | 98 | 4f | 78 | fb | 51 | 5b | 3b | 52 | cf | 7c |
7_ | 26 | 96 | 70 | f4 | 59 | 89 | d4 | 1a | 27 | 0b | a0 | 75 | 5f | 20 | 90 | 32 |
8_ | 56 | c4 | e8 | 31 | 0d | 53 | 83 | 2f | 7e | 61 | 39 | eb | 21 | d9 | ea | 05 |
9_ | 1b | 03 | 6c | d3 | e6 | 43 | a5 | 0e | 16 | 50 | be | 9d | 93 | 12 | e7 | ae |
a_ | 0a | f5 | 72 | 09 | b0 | 23 | 57 | 02 | 63 | c0 | 68 | 9b | cb | d8 | a3 | 1c |
b_ | 25 | b5 | c7 | bf | fc | 87 | b3 | 15 | bc | 86 | 3a | 36 | c1 | 0c | 8d | b9 |
c_ | c9 | f7 | 9c | 76 | 7f | f3 | 67 | 3f | 2e | 47 | 5c | 37 | b2 | 17 | 2d | 7b |
d_ | f9 | 6d | 6b | d6 | 80 | 9f | 08 | b6 | e9 | db | a9 | de | b8 | 81 | f6 | 97 |
e_ | a6 | 11 | ac | ff | ee | ca | 88 | 6a | f1 | 84 | 1e | c3 | fa | 2c | 8a | 24 |
f_ | aa | e5 | 33 | 1d | d1 | 22 | 5e | dd | 29 | 5d | ba | 7d | 94 | 3e | 45 | 85 |
-
The matrix
$A$ used in Section 5.1 is a circulant matrix generated from value 0xd3, which is the product of 'R' (0x52) and 'W' (0x57) on Galois Field$\text{GF}(2^8)$ . -
The constant value 0xa4 used in Section 5.1 represents the sum of hex value of string "RichadoWonosas", which is exactly 0x5a4.
-
Another constant value 0xe3 used in Section 5.1 is chosen to make the S-Box a cyclic permutation.
-
The Upper Mask
$u$ used in Section 6.1 is inspired from a certain rhythm type. -
The four digits-to-shifts set in Section 6.2 (5, 23, 41, 59) form an arithmetic progression with all elements are prime number, and the average of them is 32, half of the bit amount of quad-word.
-
The matrix
$X$ used in Section 6.3 is the 27th candidate of all small-index self-invertible matrices generated by ascending exhaustive search.