S-box Analyzer Web Version

With the website we have prepared to evaluate the cryptographic security of S-boxes, you can have your S-boxes analyzed according to five basic criteria such as non-linearity, bit independence criterion (BIC), strict avalanche criterion (SAC), differential uniformity and linear uniformity. This tool helps you test the resilience of your S-boxes against various types of attacks.

Enter 256 numbers between 0-255.
Numbers can be in decimal or hexadecimal, the system detects them automatically.
Numbers can be separated by comma, period, semicolon, new line or space, it is detected automatically.
For testing example s-box(AES S-box as integer):

1. Non-linearity

Non-linearity is a measure of how much an S-box deviates from being a linear or affine function. A high degree of non-linearity is desired in cryptographic applications because it enhances the resistance of the S-box to linear cryptanalysis. Linear cryptanalysis involves approximating the behavior of a cryptographic algorithm using linear equations, and high non-linearity ensures that such approximations are difficult to find.
Formula: The non-linearity N f N f N_(f)N_fNf of a Boolean function f f fff is defined as the minimum Hamming distance between the function f f fff and all affine functions A A AAA. Mathematically, this can be expressed as:
N f = min A { d H ( f , A ) } N f = min A { d H ( f , A ) } N_(f)=min_(A){d_(H)(f,A)}N_f = \min_{A} \{d_H(f, A)\}Nf=minA{dH(f,A)}
where d H d H d_(H)d_HdH denotes the Hamming distance, which is the number of positions at which the corresponding bits are different between two binary sequences.
For an S-box S S SSS mapping n n nnn input bits to m m mmm output bits, the non-linearity of each output bit function f i f i f_(i)f_ifi (where S ( x ) = ( f 1 ( x ) , f 2 ( x ) , , f m ( x ) ) S ( x ) = ( f 1 ( x ) , f 2 ( x ) , , f m ( x ) ) S(x)=(f_(1)(x),f_(2)(x),dots,f_(m)(x))S(x) = (f_1(x), f_2(x), \ldots, f_m(x))S(x)=(f1(x),f2(x),,fm(x))) is calculated, and the overall non-linearity of the S-box is often considered as the minimum non-linearity among these functions.
To calculate the non-linearity of a Boolean function f f fff, you can use the following steps:
  1. Compute the truth table of f f fff.
  2. Construct all possible affine functions of the same dimension.
  3. Calculate the Hamming distance between f f fff and each affine function.
  4. The smallest Hamming distance obtained is the non-linearity of f f fff.
The formula for the Hamming distance d H d H d_(H)d_HdH between two binary sequences x x xxx and y y yyy of length n n nnn is:
d H ( x , y ) = i = 1 n ( x i y i ) d H ( x , y ) = i = 1 n ( x i y i ) d_(H)(x,y)=sum_(i=1)^(n)(x_(i)o+y_(i))d_H(x, y) = \sum_{i=1}^{n} (x_i \oplus y_i)dH(x,y)=i=1n(xiyi)
where o+\oplus denotes the XOR operation.
In practice, the calculation of non-linearity for an S-box involves examining each output bit function, as well as considering the overall structure of the S-box to ensure high resistance to linear attacks.

2. Strict Avalanche Criterion (SAC)

The Strict Avalanche Criterion (SAC) is a measure of how each output bit of an S-box changes when a single input bit is flipped. Specifically, SAC requires that, on average, flipping any single input bit should change each output bit with a probability of 0.5. This ensures that small changes in the input produce widespread changes in the output, enhancing the diffusion properties of the S-box.
Formula: To evaluate the SAC for an S-box, consider the following:
  1. Let S S SSS be an S-box mapping n n nnn-bit inputs to m m mmm-bit outputs.
  2. Denote the output bits of S S SSS as ( f 1 ( x ) , f 2 ( x ) , , f m ( x ) ) ( f 1 ( x ) , f 2 ( x ) , , f m ( x ) ) (f_(1)(x),f_(2)(x),dots,f_(m)(x))(f_1(x), f_2(x), \ldots, f_m(x))(f1(x),f2(x),,fm(x)) for an input x x xxx.
For each output bit f j ( x ) f j ( x ) f_(j)(x)f_j(x)fj(x), calculate the probability that it changes when a single input bit x i x i x_(i)x_ixi is flipped:
P ( f j ( x ) f j ( x e i ) ) = 1 2 n x { 0 , 1 } n ( f j ( x ) f j ( x e i ) ) P ( f j ( x ) f j ( x e i ) ) = 1 2 n x { 0 , 1 } n f j ( x ) f j ( x e i ) P(f_(j)(x)!=f_(j)(x o+e_(i)))=(1)/(2^(n))sum_(x in{0,1}^(n))(f_(j)(x)o+f_(j)(x o+e_(i)))P(f_j(x) \neq f_j(x \oplus e_i)) = \frac{1}{2^n} \sum_{x \in \{0, 1\}^n} \left( f_j(x) \oplus f_j(x \oplus e_i) \right)P(fj(x)fj(xei))=12nx{0,1}n(fj(x)fj(xei))
where:
  • e i e i e_(i)e_iei is the i i iii-th unit vector in n n nnn-dimensional space, indicating a flip in the i i iii-th input bit.
  • x e i x e i x o+e_(i)x \oplus e_ixei denotes the input x x xxx with the i i iii-th bit flipped.
  • o+\oplus represents the XOR operation.
To satisfy the SAC, this probability should be close to 0.5 for each output bit f j f j f_(j)f_jfj and each input bit x i x i x_(i)x_ixi.
Steps to Compute SAC:
  1. For each output bit f j f j f_(j)f_jfj and each input bit x i x i x_(i)x_ixi:
    • Iterate over all possible inputs x { 0 , 1 } n x { 0 , 1 } n x in{0,1}^(n)x \in \{0, 1\}^nx{0,1}n.
    • Flip the i i iii-th input bit by using the vector e i e i e_(i)e_iei.
    • Compute the number of times f j ( x ) f j ( x e i ) f j ( x ) f j ( x e i ) f_(j)(x)!=f_(j)(x o+e_(i))f_j(x) \neq f_j(x \oplus e_i)fj(x)fj(xei).
  2. Calculate the probability for each pair ( x i , f j ) ( x i , f j ) (x_(i),f_(j))(x_i, f_j)(xi,fj).
  3. Verify that these probabilities are close to 0.5 for all pairs.
In practice, an S-box that satisfies the SAC ensures that the effect of changing a single input bit propagates to the output bits in a balanced and unpredictable manner, significantly complicating differential attacks and enhancing overall cryptographic strength.

3. Bit Independence Criterion (BIC)

The Bit Independence Criterion (BIC) assesses the independence of output bits in response to changes in the input bits. Specifically, it measures how each output bit changes independently when each input bit is flipped. High BIC values indicate that changes in one input bit affect the output bits independently, which is desirable for secure cryptographic transformations.
Formula: To evaluate the Bit Independence Criterion for an S-box, consider the following:
  1. Let S S SSS be an S-box mapping n n nnn-bit inputs to m m mmm-bit outputs.
  2. Denote the output bits of S S SSS as ( f 1 ( x ) , f 2 ( x ) , , f m ( x ) ) ( f 1 ( x ) , f 2 ( x ) , , f m ( x ) ) (f_(1)(x),f_(2)(x),dots,f_(m)(x))(f_1(x), f_2(x), \ldots, f_m(x))(f1(x),f2(x),,fm(x)) for an input x x xxx.
To assess the independence, compute the correlation between output bits for each possible input bit flip:
Correlation ( f i , f j ) = 1 2 n x { 0 , 1 } n ( 1 ) f i ( x ) f i ( x e k ) f j ( x ) f j ( x e k ) Correlation ( f i , f j ) = 1 2 n x { 0 , 1 } n ( 1 ) f i ( x ) f i ( x e k ) f j ( x ) f j ( x e k ) "Correlation"(f_(i),f_(j))=(1)/(2^(n))sum_(x in{0,1}^(n))(-1)^(f_(i)(x)o+f_(i)(x o+e_(k))o+f_(j)(x)o+f_(j)(x o+e_(k)))\text{Correlation}(f_i, f_j) = \frac{1}{2^n} \sum_{x \in \{0, 1\}^n} (-1)^{f_i(x) \oplus f_i(x \oplus e_k) \oplus f_j(x) \oplus f_j(x \oplus e_k)}Correlation(fi,fj)=12nx{0,1}n(1)fi(x)fi(xek)fj(x)fj(xek)
where:
  • f i f i f_(i)f_ifi and f j f j f_(j)f_jfj are output bit functions of the S-box.
  • e k e k e_(k)e_kek is the k k kkk-th unit vector in n n nnn-dimensional space, indicating a flip in the k k kkk-th input bit.
  • x e k x e k x o+e_(k)x \oplus e_kxek denotes the input x x xxx with the k k kkk-th bit flipped.
  • o+\oplus represents the XOR operation.
The correlation should be close to zero for high independence, indicating that the output bits change independently when any single input bit is flipped.
Steps to Compute BIC:
  1. For each pair of output bits f i f i f_(i)f_ifi and f j f j f_(j)f_jfj:
    • Iterate over all possible inputs x { 0 , 1 } n x { 0 , 1 } n x in{0,1}^(n)x \in \{0, 1\}^nx{0,1}n.
    • Flip each input bit k k kkk by using the vector e k e k e_(k)e_kek.
    • Calculate the correlation between the bit changes.
  2. Analyze the correlations: lower values indicate higher independence.
In practice, an S-box with high bit independence ensures that each output bit responds independently to changes in the input bits, which is critical for preventing attacks that exploit correlations between output bits.

4. Differential Uniformity

Differential uniformity is a measure of the uniformity of the output differences resulting from input differences in an S-box. It quantifies the maximum number of times any particular output difference occurs when a specific input difference is applied. A low differential uniformity indicates strong resistance to differential cryptanalysis, a method that exploits patterns in the differences between inputs and outputs.
Formula: The differential uniformity δ δ delta\deltaδ of an S-box S S SSS is defined as the maximum value of the differential distribution table (DDT). The DDT records how often each output difference Δ y Δ y Delta y\Delta yΔy occurs for each input difference Δ x Δ x Delta x\Delta xΔx.
To construct the DDT for an S-box S S SSS:
  1. Let S S SSS map n n nnn-bit inputs to m m mmm-bit outputs.
  2. Define the input difference Δ x Δ x Delta x\Delta xΔx and output difference Δ y Δ y Delta y\Delta yΔy as: Δ x = x x Δ x = x x Delta x=x o+x^(')\Delta x = x \oplus x'Δx=xx Δ y = S ( x ) S ( x ) Δ y = S ( x ) S ( x ) Delta y=S(x)o+S(x^('))\Delta y = S(x) \oplus S(x')Δy=S(x)S(x)
  3. Count the number of pairs ( x , x ) ( x , x ) (x,x^('))(x, x')(x,x) that produce each Δ y Δ y Delta y\Delta yΔy for a given Δ x Δ x Delta x\Delta xΔx: D D T ( Δ x , Δ y ) = | { x { 0 , 1 } n S ( x ) S ( x Δ x ) = Δ y } | D D T ( Δ x , Δ y ) = { x { 0 , 1 } n S ( x ) S ( x Δ x ) = Δ y } DDT(Delta x,Delta y)=|{x in{0,1}^(n)∣S(x)o+S(x o+Delta x)=Delta y}|DDT(\Delta x, \Delta y) = \left| \{ x \in \{0, 1\}^n \mid S(x) \oplus S(x \oplus \Delta x) = \Delta y \} \right|DDT(Δx,Δy)=|{x{0,1}nS(x)S(xΔx)=Δy}|
The differential uniformity δ δ delta\deltaδ is then:
δ = max Δ x 0 , Δ y D D T ( Δ x , Δ y ) δ = max Δ x 0 , Δ y D D T ( Δ x , Δ y ) delta=max_(Delta x!=0,Delta y)DDT(Delta x,Delta y)\delta = \max_{\Delta x \neq 0, \Delta y} DDT(\Delta x, \Delta y)δ=maxΔx0,ΔyDDT(Δx,Δy)
Steps to Compute Differential Uniformity:
  1. Initialize a table D D T D D T DDTDDTDDT of size 2 n × 2 m 2 n × 2 m 2^(n)xx2^(m)2^n \times 2^m2n×2m with zeros.
  2. For each non-zero input difference Δ x Δ x Delta x\Delta xΔx:
    • For each possible input x { 0 , 1 } n x { 0 , 1 } n x in{0,1}^(n)x \in \{0, 1\}^nx{0,1}n:
      • Compute x = x Δ x x = x Δ x x^(')=x o+Delta xx' = x \oplus \Delta xx=xΔx.
      • Compute the output difference Δ y = S ( x ) S ( x ) Δ y = S ( x ) S ( x ) Delta y=S(x)o+S(x^('))\Delta y = S(x) \oplus S(x')Δy=S(x)S(x).
      • Increment the corresponding entry in the DDT: D D T ( Δ x , Δ y ) D D T ( Δ x , Δ y ) DDT(Delta x,Delta y)DDT(\Delta x, \Delta y)DDT(Δx,Δy).
  3. Identify the maximum value in the DDT for non-zero Δ x Δ x Delta x\Delta xΔx, which is the differential uniformity δ δ delta\deltaδ.

5. Linear Uniformity

Linear uniformity measures how uniformly the output bits of an S-box can be approximated by linear functions of the input bits. It is an indicator of an S-box's resistance to linear cryptanalysis, a method that exploits linear approximations of the relationship between input and output bits to recover secret keys. Lower linear uniformity values indicate higher resistance to such attacks.
Formula: The linear uniformity L U L U LULULU of an S-box is determined by the maximum absolute value of the correlation between linear combinations of input and output bits. This is captured using the Walsh-Hadamard transform.
For an S-box S S SSS mapping n n nnn-bit inputs to m m mmm-bit outputs, the linear approximation table (LAT) is used to compute these correlations:
  1. Define the linear approximation of an input x x xxx and an output y y yyy as:
    L α , β ( x , y ) = α x β y L α , β ( x , y ) = α x β y L_(alpha,beta)(x,y)=alpha*x o+beta*y\mathcal{L}_{\alpha, \beta}(x, y) = \alpha \cdot x \oplus \beta \cdot yLα,β(x,y)=αxβy
    where α α alpha\alphaα and β β beta\betaβ are non-zero n n nnn-bit and m m mmm-bit vectors, respectively, and *\cdot denotes the dot product.
  2. Calculate the correlation between input and output bit combinations:
    L A T ( α , β ) = x { 0 , 1 } n ( 1 ) L α , β ( x , S ( x ) ) L A T ( α , β ) = x { 0 , 1 } n ( 1 ) L α , β ( x , S ( x ) ) LAT(alpha,beta)=sum_(x in{0,1}^(n))(-1)^(L_(alpha,beta)(x,S(x)))LAT(\alpha, \beta) = \sum_{x \in \{0, 1\}^n} (-1)^{\mathcal{L}_{\alpha, \beta}(x, S(x))}LAT(α,β)=x{0,1}n(1)Lα,β(x,S(x))
  3. The linear uniformity L U L U LULULU is defined as:
    L U = max α 0 , β | L A T ( α , β ) | L U = max α 0 , β | L A T ( α , β ) | LU=max_(alpha!=0,beta)|LAT(alpha,beta)|LU = \max_{\alpha \neq 0, \beta} |LAT(\alpha, \beta)|LU=maxα0,β|LAT(α,β)|
Steps to Compute Linear Uniformity:
  1. Initialize a table L A T L A T LATLATLAT of size 2 n × 2 m 2 n × 2 m 2^(n)xx2^(m)2^n \times 2^m2n×2m with zeros.
  2. For each non-zero α { 0 , 1 } n α { 0 , 1 } n alpha in{0,1}^(n)\alpha \in \{0, 1\}^nα{0,1}n:
    • For each β { 0 , 1 } m β { 0 , 1 } m beta in{0,1}^(m)\beta \in \{0, 1\}^mβ{0,1}m:
      • Compute the sum x { 0 , 1 } n ( 1 ) α x β S ( x ) x { 0 , 1 } n ( 1 ) α x β S ( x ) sum_(x in{0,1}^(n))(-1)^(alpha*x o+beta*S(x))\sum_{x \in \{0, 1\}^n} (-1)^{\alpha \cdot x \oplus \beta \cdot S(x)}x{0,1}n(1)αxβS(x) and store it in L A T ( α , β ) L A T ( α , β ) LAT(alpha,beta)LAT(\alpha, \beta)LAT(α,β).
  3. Identify the maximum absolute value in the L A T L A T LATLATLAT, which is the linear uniformity L U L U LULULU.