## 4 Research Methodology
### Dynamic AES Key Replacement Mechanism  
The proposed mechanism addresses the critical vulnerability of key reuse in AES encryption, which can result in power consumption or electromagnetic signal leakage that can be exploited by SCAs. This vulnerability stems from the repeated use of the same encryption key rather than the key length itself. Although longer keys, such as AES  
Figure 5: Actual client-side setup. Figure 6: Server-side configuration display. 256, could theoretically reduce these risks, their higher computational overhead renders them impractical for resource-constrained IoT devices. Therefore, this study focuses on implementing a dynamic key replacement mechanism that enhances security without imposing additional computational burdens. * Initial Key Configuration and Key Replacement  
As shown in Figure 7, the mechanism begins with a pre-configured initial key, \(Key[0]\), used solely during the initial connection negotiation. The D-H key exchange protocol then generates the first 32-bit hopping operator, \(d[0]\), which is combined with \(Key[0]\), using a hash function to derive the next encryption key:  
\[Key[1]=hash(Key[0],d[0]).\]  
This dynamic key replacement ensures that \(Key[0]\) is never reused for encryption, thereby mitigating potential leakage of AES characteristics and reducing SCA risks. The hash function, implemented in the HashAESKey method, dynamically updates the AES key to ensure enhanced security while maintaining computational efficiency for IoT devices. The process works as follows: The hash function takes \(d[0]\) (the 32-bit hopping operator) as the salt and processes it to modify \(Key[0]\). The AES key is represented as a 16-byte array, and the hashing process iterates over these 16 bytes in four 4-byte blocks. For each byte, a bitwise XOR operation is performed between the byte and the least significant 8 bits of the salt. After each XOR operation, the salt is right-shifted by 4 bits to ensure all bits contribute to the transformation. This operation produces \(Key[1]\), which is used for subsequent encryption cycles. The algorithm can be summarized as follows:  
* Step 1: initialize the salt with \(d[0]\). * Step 2: iterate over the 16 bytes of \(Key[0]\) in four 4-byte blocks. * Step 3: for each byte, apply a bitwise XOR with the least significant 8 bits of the salt. * Step 4: right-shift the salt by 4 bits after processing each byte. * Step 5: update the corresponding byte in \(Key[0]\) to produce \(Key[1]\). This lightweight hashing process ensures that the updated key incorporates sufficient randomness and unpredictability derived from \(d[0]\), while keeping computational overhead minimal. By leveraging this approach, the dynamic key replacement mechanism prevents key reuse and enhances resilience against SCAs, ensuring secure communication in resource-constrained IoT environments. * Dynamic Key Replacement Process  
The key replacement process, illustrated in Figure 8, is triggered after every \(M\) data transmission. A new hopping operator is generated using the D-H key exchange, which derives a fresh encryption key to prevent key reuse. For enhanced randomness, the private keys in the D-H exchange are generated from high-quality random numbers or, in offline scenarios, through analog value readings from the microcontroller's pins, such as using the Arduino analogRead() function. Figure 7: Key generation concept in dynamic key replacement for AES encryption. This mechanism significantly strengthens IoT system security by ensuring that each transmission uses a unique encryption key, effectively thwarting SCAs that exploit predictable electromagnetic signals. * D-H Key Exchange Implementation The lightweight implementation of the D-H key exchange is specifically tailored for resource-constrained microcontrollers, such as the Arduino Uno. This implementation utilizes carefully chosen parameters to strike an optimal balance between security and computational efficiency: a generator \((G=37)\) and a prime modulus \((P=2,147,483,647)\).