# SC-SA: Byte-Oriented Lightweight Stream Ciphers Based on S-Box Substitution
## 2 SC-SA Cipher  
For real-time applications and resource-constrained IoT devices, choosing a lower value for K is preferable while ensuring security requirements. As shown in Figure 2, the j-th ciphertext block \(C_{j}\) is obtained by mixing the j-th plaintext block \(\mathrm{M_{j}}\) with the j-th generated key stream block (State Data Grouping) \(V_{j}\). Please refer to Equation (1) for a detailed explanation of this process. \[C_{j}=E_{K}\big{(}m_{j}\big{)}=m_{j}\oplus V_{j},j=1,2,\ldots,n, \tag{1}\]  
Figure 1: Diagram of the initial key padding process. The generated key stream (State Data Group V) iteratively updates, with the i-th group vector updated by the (I + 1)-th group vector. The proposed stream cipher consists of two sub-functions:  
1. Round Function (RF): when the key is filled in, the cryptographic algorithm enters an iterative operation so that the values stored in the array can be randomized;
2. Update Vector Function (UVF): a vector update is performed for every output of the State Data Group. This section describes the initialization of the cryptographic key and the key confusion process before generating the key stream. The key confusion process in this paper is referred to as the Round Function (RF), and one round of processing is illustrated in Figure 2 above. In the cryptographic scheme proposed in this paper, the RF needs to iterate 80 times during the key confusion phase to meet the designed cryptographic security strength. In the key stream output phase, described as the Update Vector Function (UVF) in this paper, the processing is depicted in Figure 3.  
Round Function (RF): During the initial key padding phase, the 80-bit initial key K is divided into 64 bits, 8 bits, and 8 bits, which are used to pad Queue T, Index Data Group A, and state group V, respectively. Subsequently, iterative processing for key confusion will take place, and the detailed process will be explained in the following text. Let T [i] represent the value of the i-th byte data in the Queue T, V [i] represent the value of the i-th  
Figure 3: Update Vector Function (UVF) logic diagram. Figure 2: Round Function (RF) logic diagram. bit in the State Data Group V, A [i] represent the value of the i-th bit in the Address Data Group A, and T [i][j] represent the value of the j-th bit of the i-th byte in the Queue T.  
Step 1: when the Index Data Group A and State Data Group V are initialized or updated, the values of the (A + 1)-th and (V + 1)-th numbers in the S-box (with indexing starting from 0) are swapped, denoted as Swap (S[A],S [V]);  
Step 2: through the previous step, the mapping (substitution) relationship represented by the S-box is obfuscated once, and the value of S [V] is used to update the State Data Group V, denoted as V = S [V];  
Step 3: Through the previous step, the values in the State Data Group V are updated, and when storing them in the Queue T, they are inserted at the tail of the Queue T [7]. Before that, make sure to remove and assign the head of the Queue T [0] to the Index Data Group A, denoted as A = T.pop (), T.push (V);  
Step 4: Through the previous step, the values of the Index Data Group A are updated, and the data in the Queue T are updated. In software-implemented cryptographic algorithms, arithmetic addition has a significant advantage in enhancing the nonlinearity of the cipher. The iterative update of the State Data Group V uses arithmetic addition, denoted as V = V\(\oplus\)A + 0b01111111, where 0b0111111 is binary for 127. In the iterative update of the Index Data Group A, A [0]-A [7] take values from T [0][2], T [1][4], T [2][0], T [3][6], T [4][1], T [5][3], T [6][7], and T [7][5], denoted as A = T [0][2] | 1 T [1][4] | 1 T [2][0] | 1 T [3][6] | 1 T [4][1] | 1 T [5][3] | 1 T [6][7] | 1 T [7][5];  
Step 5: If the iteration round is less than or equal to 80, proceed to the first step; otherwise, begin the Update Vector Function (UVF) of the cryptographic algorithm, output the key stream, and perform XOR with plaintext data.