{"id":160768,"date":"2025-04-25T23:03:59","date_gmt":"2025-04-25T17:33:59","guid":{"rendered":"https:\/\/www.electronicsforu.com\/?p=160768"},"modified":"2025-04-25T23:04:36","modified_gmt":"2025-04-25T17:34:36","slug":"iot-security-system-with-aes-encryption","status":"publish","type":"post","link":"https:\/\/www.electronicsforu.com\/electronics-projects\/iot-security-system-with-aes-encryption","title":{"rendered":"IoT Security System With AES Encryption"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"161\" height=\"147\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/Ashwini-EFY-Tested.webp\" alt=\"EFY Stamp\" class=\"wp-image-160874\"\/><\/figure><\/div>\n\n\n<p>In the era of interconnected devices, securing IoT systems is paramount to protect sensitive data from unauthorized access. This project demonstrates an <strong>IoT Security System<\/strong> leveraging <strong>AES (Advanced Encryption Standard)<\/strong> encryption to transform plain-text data into a &#8220;secret code&#8221; that only authorized users can decipher. <\/p>\n\n\n\n<p>By integrating AES with an IndusBoard Coin, we ensure that data transmitted over Wi-Fi, such as sensor readings or user messages, remains confidential and tamper-proof. The system aligns with the <strong>IndusBoard Coin Security System<\/strong> concept, emphasizing robust encryption for IoT applications.<\/p>\n\n\n\n<p>AES is a symmetric encryption algorithm widely used for its efficiency and strength. Here, we use it to encrypt data on the Coin board, which supports hardware-accelerated AES via its cryptographic engine. This project evolves in two parts:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A standalone encryption demo using AES-256.<\/li>\n\n\n\n<li>An IoT sender-receiver system with a web UI for encrypting and decrypting messages in AP\/STA mode.<\/li>\n<\/ol>\n\n\n\n<p>Supported on any board and CHIP that features built-in AES hardware acceleration. The <strong>IndusBoard Coin Security System<\/strong> could theoretically integrate with IoT, using AES alongside secure elements like the ATECC608A for key storage, though this project focuses on software-based AES for simplicity.<\/p>\n\n\n\n<p><strong>AES (Advanced Encryption Standard)<\/strong> is a symmetric encryption algorithm established by the U.S. National Institute of Standards and Technology (NIST) in 2001. It is widely used to secure data in applications ranging from banking to IoT devices due to its speed, efficiency, and robust security. AES operates on fixed-size blocks of data (16 bytes or 128 bits) and supports key sizes of 128, 192, or 256 bits\u2014here, we use AES-128 and AES-256 variants.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How AES Works<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Key Expansion<\/strong>: The encryption key (e.g. 32 bytes for AES-256) is expanded into a set of round keys using a key schedule. Each round key is used in subsequent transformation steps.<\/li>\n\n\n\n<li><strong>Encryption Process<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>SubBytes<\/strong>: Each byte of the 16-byte block is substituted using a predefined S-box (Substitution box), adding non-linearity.<\/li>\n\n\n\n<li><strong>ShiftRows<\/strong>: Rows of the block are shifted cyclically to diffuse the data.<\/li>\n\n\n\n<li><strong>MixColumns<\/strong>: Columns are mixed using a mathematical transformation to further scramble the data.<\/li>\n\n\n\n<li><strong>AddRoundKey<\/strong>: The block is XORed with a round key. This process repeats for multiple rounds (10 for AES-128, 14 for AES-256).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Decryption<\/strong>: The inverse operations (InvSubBytes, InvShiftRows, etc.) are applied with the same key to recover the original data.<\/li>\n\n\n\n<li><strong>Modes<\/strong>: AES can operate in modes like ECB (Electronic Codebook) or CBC (Cipher Block Chaining). ECB encrypts each block independently, while CBC uses an Initialization Vector (IV) to chain blocks, enhancing security.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Bill of Materials&nbsp;<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Item<\/th><th>Description<\/th><th>Quantity<\/th><\/tr><\/thead><tbody><tr><td>Board with AES Support and has a built-in secure engine (<a href=\"https:\/\/indus.electronicsforu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">IndusBoard Coin<\/a>)<\/td><td>IoT Board with AES encryption system<\/td><td>1<\/td><\/tr><tr><td>Wi-Fi Network<\/td><td>For testing<\/td><td>1<\/td><\/tr><tr><td>Micro USB Cable<\/td><td>For programming and power<\/td><td>1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Part 1: Standalone AES-256 Encryption Demo<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Code Explanation<\/strong><\/h3>\n\n\n\n<p>The first code demonstrates AES-256 encryption and decryption using the mbedtls library.<\/p>\n\n\n\n<p>Here in code, the inbuilt AES encryption is called, then a 256-bit AES encryption KEY is inserted in the code array. Next, it has a default message that you can change for encryption. Now, upload the code.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1004\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/code-1024x1004.jpeg\" alt=\"Standalone AES-256 Encryption Code\" class=\"wp-image-160773\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/code-1024x1004.jpeg 1024w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/code-500x490.jpeg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/code-429x420.jpeg 429w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/code-696x682.jpeg 696w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/code.jpeg 1410w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig 1. Code Snippet AES key array<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Testing AES-256 Encryption and Decryption<\/strong><\/h2>\n\n\n\n<p>Upload the code to Coin&nbsp;via Arduino IDE. Open the Serial Monitor (115200 baud).<\/p>\n\n\n\n<p>Then you can see the encryption and decryption process in serial.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"559\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/output-1024x559.jpeg\" alt=\"AES message encryption and decryption\" class=\"wp-image-160774\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/output-1024x559.jpeg 1024w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/output-500x273.jpeg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/output-769x420.jpeg 769w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/output-696x380.jpeg 696w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/output.jpeg 1440w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig 2. AES message encryption and decryption <\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Part 2: IoT Encrypted Data Transmission with Web UI<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Project Continuation: Sender-Receiver with Encryption<\/strong><\/h3>\n\n\n\n<p>In our IoT system, AES encrypts messages sent from a web UI to a COIN sender, ensuring that intercepted Wi-Fi traffic appears as gibberish (e.g., 6EF23A&#8230;) without the key. The receiver decrypts it using the shared key, restoring the original message. <\/p>\n\n\n\n<p>This protects confidentiality and aligns with the <strong>InusBoard Coin Security System<\/strong> concept by making data readable only to authorized parties.<\/p>\n\n\n\n<p>This code modifies the previous sender-receiver system to use AES-128 with a web UI, allowing users to input messages, see encrypted output, and decrypt them on the Serial Monitor.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"684\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-1024x684.jpeg\" alt=\"Encrypted IoT Data Transmission\" class=\"wp-image-160776\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-1024x684.jpeg 1024w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-500x334.jpeg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-1536x1026.jpeg 1536w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-629x420.jpeg 629w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-696x465.jpeg 696w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui.jpeg 1872w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig 3. UI webpage to send the  data and message <\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Code<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>WiFi.h: Configures the ESP32 as a Wi-Fi Access Point (AP) to host the UI.<\/li>\n\n\n\n<li>WebServer.h: Manages HTTP requests and responses for the web interface.<\/li>\n\n\n\n<li>mbedtls\/aes.h: Provides the AES encryption\/decryption functions from the mbedTLS library, included in the ESP32 Arduino core.<\/li>\n<\/ul>\n\n\n\n<p>ssid and password: Define the AP\u2019s name and password (must be 8+ characters).<\/p>\n\n\n\n<p>server(80): Creates a web server on port 80, the default HTTP port.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"264\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cdcdc-1024x264.jpeg\" alt=\"AES (Advanced Encryption Standard) KEY\" class=\"wp-image-160779\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cdcdc-1024x264.jpeg 1024w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cdcdc-500x129.jpeg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cdcdc-696x180.jpeg 696w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cdcdc.jpeg 1318w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig 4. AES KEY <\/figcaption><\/figure>\n\n\n\n<p>aes_key: A 16-byte (128-bit) key for AES-128, specified as individual characters to avoid string termination issues.<\/p>\n\n\n\n<p>plaintext: Stores the 16-byte input message.<\/p>\n\n\n\n<p>encrypted_output: Holds the encrypted ciphertext.<\/p>\n\n\n\n<p>decrypted_output: Stores the decrypted result for verification.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Testing<\/strong> <strong>IoT Encrypted Data Transmission with Web UI<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"684\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-1024x684.jpeg\" alt=\"IoT Encrypted Data Transmission with Web UI\" class=\"wp-image-160776\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-1024x684.jpeg 1024w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-500x334.jpeg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-1536x1026.jpeg 1536w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-629x420.jpeg 629w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui-696x465.jpeg 696w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/webui.jpeg 1872w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig 5. Web UI to send the message or data <\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"264\" src=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cds-1024x264.jpeg\" alt=\"IoT Encrypted Data Transmission\" class=\"wp-image-160780\" srcset=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cds-1024x264.jpeg 1024w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cds-500x129.jpeg 500w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cds-696x180.jpeg 696w, https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/cds.jpeg 1318w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Fig 6. IoT Encrypted Data Transmission with Web UI<\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Connect to the \u201cIndusIoT security&#8221; Wi-Fi network (password: &#8220;12345678&#8221;).<\/li>\n\n\n\n<li>Open a browser and go to http:\/\/192.168.4.1.<\/li>\n\n\n\n<li>Enter a message (e.g., &#8220;Test1234&#8221;) and submit.<\/li>\n\n\n\n<li>Check the Serial Monitor (115200 baud) for encrypted output and decrypted message<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-0fab91b7-e79a-415b-bbe7-94f9c997676f\" href=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/encryptionDecryption.zip\">Source Code<\/a><a href=\"https:\/\/www.electronicsforu.com\/wp-contents\/uploads\/2025\/04\/encryptionDecryption.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-0fab91b7-e79a-415b-bbe7-94f9c997676f\">Download<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In the era of interconnected devices, securing IoT systems is paramount to protect sensitive data from unauthorized access. This project demonstrates an IoT Security System leveraging AES (Advanced Encryption Standard) encryption to transform plain-text data into a &#8220;secret code&#8221; that only authorized users can decipher. By integrating AES with an IndusBoard Coin, we ensure that [&hellip;]<\/p>\n","protected":false},"author":33369,"featured_media":160775,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,23,6070,7786,6189,11851],"tags":[],"class_list":{"0":"post-160768","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-electronics-projects","8":"category-hardware-diy","9":"category-advanced-projects","10":"category-ai-ml-projects","11":"category-esp32-projects","12":"category-super-innovative-projects"},"_links":{"self":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/160768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/users\/33369"}],"replies":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/comments?post=160768"}],"version-history":[{"count":2,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/160768\/revisions"}],"predecessor-version":[{"id":161884,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/posts\/160768\/revisions\/161884"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/media\/160775"}],"wp:attachment":[{"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/media?parent=160768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/categories?post=160768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.electronicsforu.com\/wp-json\/wp\/v2\/tags?post=160768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}