Privacy-Centric AI and IoT Solutions for Smart Rural Farm Monitoring and Control

The integration of artificial intelligence (AI) and the Internet of Things (IoT) in agriculture has significantly transformed rural farming. However, the adoption of these technologies has also introduced privacy and security concerns, particularly unauthorized breaches and cyber-attacks on data collected from IoT devices and sensitive information. The present study addresses these concerns by developing a comprehensive framework that provides practical, privacy-centric AI and IoT solutions for monitoring smart rural farms. This is performed by designing a framework that includes a three-phase protocol that secures data exchange between the User, the IoT Sensor Layer, and the Central Server. In the proposed protocol, the Central Server is responsible for establishing a secure communication channel by verifying the legitimacy of the IoT Sensor devices and the User and securing the data using rigorous cryptographic techniques. The proposed protocol is also validated using the Automated Validation of Internet Security Protocols and Applications (AVISPA) tool. The formal security analysis confirms the robustness of the protocol and its suitability for real-time applications in AI and IoT-enabled smart rural farms, demonstrating resistance against various attacks and enhanced performance metrics, including a computation time of 0.04 s for 11 messages and a detailed search where 119 nodes were visited at a depth of 12 plies in a mere search time of 0.28 s.


Introduction
Rural farming practices have been a significant driving force in the evolution of agriculture, progressing from the use of simple tools to the advanced deployment of automated equipment which has boosted productivity and enhanced efficiency.The era of traditional farming, rooted in manual labor, animal power, and rudimentary farming techniques sensitive to environmental conditions, has faced persistent challenges related to efficiency, scalability, and sustainability.However, in recent years, rural farming has steadily begun to include technological advancements and innovations to overcome the inherent limitations of traditional farming practices [1].This continuous integration of technology reached a pivotal transformation with the advent of smart farming, referred to as Agriculture 4.0, a modern approach that uses the Internet of Things (IoT), artificial intelligence (AI), Sensors 2024, 24, 4157 2 of 24 cloud computing, and other advanced hardware and software to revolutionize agricultural practices [2].
Smart farming employs various sensors and gadgets to continuously gather and communicate vast amounts of data about crop health, weather patterns, soil conditions, and machine learning algorithms that predict crop diseases and optimize harvesting schedules [3].These sensors connected to the IoT are the driving force behind smart farms, as they collect data in real time and process it locally or on a cloud server using advanced AI algorithms to offer farmers access to previously unimaginable insights and decision-making tools [4].
Studies on smart farming have focused on hardware components like sensors, unmanned aerial vehicles (UAV), global positioning systems (GPSs), and automated machinery and software components that involve data analysis platforms, decision support systems, and mobile applications that process and interpret collected data to aid in decisionmaking.Innovations in this field involve increasing sensor accuracy, refining the software's data processing capabilities, and improving UAVs' operational efficiency.
However, despite these technological advancements and increased academic and commercial research on smart farming, there is a significant gap in the research on privacycentric solutions, necessary for rural farm monitoring and control.This is particularly important as deploying AI and IoT in rural settings introduces complex challenges in data security and privacy management due to limited cybersecurity infrastructures.Additionally, with more advanced and linked technologies being used, processing and storing agricultural data has become more and more dependent on cloud-based infrastructure due to the growth in data collection, which raises privacy and security concerns about sensitive agricultural data.This definition of "data" includes farmers' financial and personal information, including meteorological patterns and statistics on agricultural productivity, which could be compromised if insufficient security precautions are implemented [5].Furthermore, considering most farmers are unfamiliar with digital security, they are ill-equipped to tackle the complexities of safeguarding their digital information [6].
Conventionally, in smart farming, IoT sensors, cloud servers, and human experts are the three primary nodes that must be managed effectively.IoT sensors positioned systematically throughout the farm serve as the primary data collection points, gathering accurate details about crops and the surrounding environment [7].On the other hand, cloud sensors act as the primary hub for data processing and storage, utilizing AI algorithms to analyze the gathered data and produce informative results.Within this system, the human expert, typically a farmer or farm manager, collects information, makes defendable judgments, and sometimes manually controls or modifies IoT devices in response to ideas given [8].
Our research thus focuses on developing a secure and privacy-centric framework for smart rural farm monitoring and control by proposing a protocol that ensures secure data exchange across different layers in the smart farm AI-IoT architecture.This protocol is designed to encrypt data, establish a secure communication channel, verify the legitimacy of all nodes, and restrict access exclusively to authorized entities.Implementing such a layer of protection is essential for averting catastrophic consequences and protecting farm operational data from unwanted access and data breaches [9].To test the robustness and efficiency of the proposed protocol, we use the Automated Validation of Internet Security Protocols and Applications (AVISPA) tool, an accepted standard for verifying and validating security protocols [10,11].Our objective is thus to develop a framework that enables the integration of AI and IoT technologies in rural agriculture while ensuring the security and privacy of all participants and to add to the existing literature on smart farming by offering insights and recommendations that can enhance the security of smart rural farms.
The rest of the article is organized into seven main sections: Section 2 discusses related works in smart farming and advanced technological solutions in smart farming.This is followed by a discussion of the integration of AI and IoT in smart farming in Section 3 and a discussion of privacy concerns in AI and IoT in smart farming in Section 4. Section 5 introduces our protocol, which involves three entities: the User, the IoT Sensor Layer, and the Central Server.Section 6 addresses the formal verification of the proposed protocol using the AVISPA tool, presents the results of the simulation, and compares these results with other existing security protocols.Finally, Section 7 summarizes and presents the conclusions outlining the future scope of AI-IoT research in smart rural farm monitoring and control.

Related Work
Numerous studies have been conducted to develop systems that employ AI and IoT for environmental monitoring, crucial for agriculture decision-making.These technologies also form part of precision agriculture, ensuring that resources are used efficiently, minimizing waste, and maximizing output.These systems typically use sensors to gather data on environmental parameters like temperature, humidity, rainfall, and barometric pressure [12].Several studies have also focused on developing smart irrigation systems to optimize water usage, prevent resource wastage, and adjust to the crop's specific hydration requirements.For instance, soil moisture sensors help determine the most effective watering schedules to prevent over-or under-watering.Similarly, pH sensors that monitor soil acidity can influence nutrient availability and absorption, while temperature and humidity sensors help predict frost events or identify conditions conducive to fungal infections.Additional research has looked into decision support systems (DSS) that use AI algorithms to provide insight into pest management issues and crop rotation recommendations for sustainability [2].
In all these studies, the collected data from sensors are subsequently sent to cloud servers for storage and analysis.This employment of cloud computing facilitates a faster, easier, and more maintainable monitoring process.The application of this technology also allows seamless collaboration among stakeholders and provides farmers with a holistic view of their operations.These numerous advantages of utilizing cloud computing via data collection and management with AI and IoT integration allow farmers to access advanced technologies and data analysis tools that improve productivity, efficiency, and sustainability.However, these advantages are accompanied by challenges such as data security, reliable internet connectivity, and the need for technical expertise.
Key security concerns include data breaches and distributed denial of service (DDoS), where unauthorized access to sensitive farm data can disrupt farming operations.Other dangers that can compromise data security involve data loss due to technical failures, accidental deletions, inadequate backup practices, and insider threats from workers or third-party suppliers with access to cloud systems.Additionally, data sharing and thirdparty access can result in farm data being accessed and shared without explicit consent, leading to potential misuse or unauthorized disclosures [13].Moreover, there are worries over transparency and the possible misuse of personal data because the AI algorithms that process and evaluate this data frequently function as "black boxes" [14].
To address these concerns, various methods of protecting privacy have been created and applied in comparable situations.Three notable methods are federated learning, which trains AI models across multiple decentralized devices or servers holding local data samples without exchanging them; data anonymization, which removes personally identifiable information from data sets; and encryption, which secures data both in transit and at rest [15].Another potentially effective method is secure multi-party computation, which allows individuals to collaboratively compute a function based on their inputs while preserving the privacy of those inputs [16].However, many existing solutions are too resource-intensive or excessively complicated to use in rural locations where resources might be scarce [17].Furthermore, the lack of technical expertise hinders the effective use of platforms that integrate these various AI and IoT innovations, which calls for reliable, userfriendly, and efficient confidential solutions adaptable to rural farming requirements [17,18].
Several studies have addressed these concerns in smart farming by proposing different security mechanisms, such as privacy-oriented blockchain-based solutions in green IoTbased agriculture, authentication and access control, symmetric data encryption between agricultural sensors, intrusion detection systems, and physical countermeasures.Early studies involved smartcard and password-based protocols to ensure the security of wireless sensor networks, which proved ineffective against evolving threats such as insider and impersonation attacks.
Some traditional solutions also depended on a trusted third party for device identity management, introducing risks such as single points of failure and security threats from third parties [19].Subsequent research introduced protocols that addressed mutual authentication and the absence of password change phases.However, these protocols were also vulnerable to impersonation attacks and weaknesses such as session key leakage and offline password guessing attacks.So, with the further advancement of technologies and the IoT, blockchain-based authentication and key agreement schemes were developed, which unfortunately suffered from high costs.Recent research then prioritized using elliptic curve cryptography (ECC) and other advanced cryptographic techniques to create security protocols to address the various vulnerabilities.
The use of the AVISPA tool also emerged as a useful tool in testing the robustness of security protocols with the integration of the Dolev-Yao (DY) threat model in AVISPA during the simulation of security protocols.Since the DY model assumes that an adversary can intercept, modify, and fabricate messages, AVISPA can effectively test protocols under worst-case scenarios.

Integration of AI and IoT in Smart Farming
By 2050, the human population is estimated to be 9.4 to 10.1 billion, which necessitates an increase in food production, particularly planting and livestock production.According to the Food and Agricultural Organization (FAO), global food systems will be unable to keep up with this population growth unless substantial changes have been made towards agricultural productivity.However, environmental changes caused by human activities have endangered the agrarian sector, while urbanization has decreased labor availability in traditional food production areas.Considering how food production must increase by one-third over the current level to meet the growing population demand, smart farming has emerged as an answer to these challenges by employing diverse technologies across various levels and stages of agriculture production.Another notable factor is how smart farming has reduced the adverse impact of conventional agricultural practices, such as the extensive use of fertilizers and pesticides, which often result in soil depletion, water contamination, and loss of biodiversity, ultimately leading to environmental degradation.
Smart farming practices have also effectively mitigated water scarcity, as these systems enable efficient water management through precise irrigation systems that conserve water but enhance crop yield and growth by maintaining ideal soil moisture levels at all times.These advantages thus help improve sustainability and food security by guaranteeing a stable supply of food to meet the demands of the growing population [20].Conventionally, a smart rural farm works through the interconnected system of devices, known as the IoT, that employs various types of devices to collect data, communication networks to transmit this data, and cloud servers that manage and analyze the collected data through AI-human-centric experts.Figure 1 illustrates such a typical AI and IoT framework under real-time conditions.
As depicted in Figure 1, the importance of smart farming can be observed from the IoT applications in algorithms that help monitor soil, crop growth, and the environment, along with AI algorithms that help analyze the data collected by the IoT devices to predict crop yields, detect diseases, and recommend optimal planting schedules through deep learning models [21].As depicted in Figure 1, the importance of smart farming can be observed from the IoT applications in algorithms that help monitor soil, crop growth, and the environment, along with AI algorithms that help analyze the data collected by the IoT devices to predict crop yields, detect diseases, and recommend optimal planting schedules through deep learning models [21].
Prior research discusses the architecture of the IoT for smart farming, which consists of four main layers: perception, transport, processing, and application.The perception layer comprises physical devices like sensors and UAVs that can be custom-built using platforms such as Arduino and Rasberry Pi.The data gathered from these devices is transmitted to the processing layer by the transport layer using various communication protocols like Wi-Fi, GPRS, 3G, Bluetooth, SigFox, LoRaWAN, and ZigBee.While the processing layer handles the data storage, management, and analysis by employing big data technologies, the application layer provides the necessary management information to farmers through mobile and web applications for effective agriculture production.
Combining the IoT with data analytics allows for extracting essential insights from large datasets of collected information.Prior research has shown how big data can enhance farm management practices and optimize the food supply chain.Crop forecasting helps farmers plan, make decisions, and conduct additional studies on the yield quality by predicting the crop yield before the crop harvest.Additionally, maturity sensors monitor the crop at various phases of development, considering elements like fruit color and size to determine the ideal time for harvesting.Multicolor (RGB) satellite photographs are also used to cover large areas for farm monitoring and control.These real-time data are displayed in mobile applications for farmers and other stakeholders by developing and installing a yield monitor.Another recent advancement in smart farming has been the deployment of automatic and remote-controlled mobile robotics that can operate tasks such as planting, weeding, and harvesting, reducing labor costs, increasing efficiency, and enhancing productivity and sustainability.

Vulnerability in Information
Farming-related AI and IoT devices gather a wide variety of data, such as crop yields, soil conditions, meteorological information, and even personal information about the farmer.This vast amount of collected data, necessary for effective farm monitoring and control, poses a serious risk if improperly secured [22].Due to its sensitive nature, this data may also be subject to cyberattacks, which could result in monetary losses or harm to one's reputation.The likelihood of these assaults is also higher in rural areas where cybersecurity precautions are weaker [23].Furthermore, because AI algorithms can Prior research discusses the architecture of the IoT for smart farming, which consists of four main layers: perception, transport, processing, and application.The perception layer comprises physical devices like sensors and UAVs that can be custom-built using platforms such as Arduino and Rasberry Pi.The data gathered from these devices is transmitted to the processing layer by the transport layer using various communication protocols like Wi-Fi, GPRS, 3G, Bluetooth, SigFox, LoRaWAN, and ZigBee.While the processing layer handles the data storage, management, and analysis by employing big data technologies, the application layer provides the necessary management information to farmers through mobile and web applications for effective agriculture production.
Combining the IoT with data analytics allows for extracting essential insights from large datasets of collected information.Prior research has shown how big data can enhance farm management practices and optimize the food supply chain.Crop forecasting helps farmers plan, make decisions, and conduct additional studies on the yield quality by predicting the crop yield before the crop harvest.Additionally, maturity sensors monitor the crop at various phases of development, considering elements like fruit color and size to determine the ideal time for harvesting.Multicolor (RGB) satellite photographs are also used to cover large areas for farm monitoring and control.These real-time data are displayed in mobile applications for farmers and other stakeholders by developing and installing a yield monitor.Another recent advancement in smart farming has been the deployment of automatic and remote-controlled mobile robotics that can operate tasks such as planting, weeding, and harvesting, reducing labor costs, increasing efficiency, and enhancing productivity and sustainability.

Vulnerability in Information
Farming-related AI and IoT devices gather a wide variety of data, such as crop yields, soil conditions, meteorological information, and even personal information about the farmer.This vast amount of collected data, necessary for effective farm monitoring and control, poses a serious risk if improperly secured [22].Due to its sensitive nature, this data may also be subject to cyberattacks, which could result in monetary losses or harm to one's reputation.The likelihood of these assaults is also higher in rural areas where cybersecurity precautions are weaker [23].Furthermore, because AI algorithms can deduce extra sensitive information from seemingly non-sensitive data, the integration of AI in data processing might further complicate privacy and increase the potential effect of a data leak [24].

Potential Hazards of Cloud Storage
The massive volumes of data collected by IoT devices are often managed and stored in cloud storage.Though this provides accessibility and scalability, it also raises concerns like data breaches and illegal access by outside parties [25].Also, since farmers frequently rely on outside service providers for cloud storage, it raises questions about data handling and security procedures.Privacy problems may also be made worse by the lack of direct control over these cloud servers [26].Another major worry is the possibility of insider attacks at the cloud service provider, where staff members may access or abuse the data [27].

Interception throughout Transmission
Information sent from IoT devices to cloud servers or other devices may be intercepted, which is particularly troubling in rural locations where secure network infrastructure might not be as developed [28].Additionally, in rural farming installations, standard encryption protocols are often ignored when transferring data across open or unprotected networks, increasing the risk of being intercepted by unauthorized parties and leading to privacy violations [6,29].

Failure of Data Governance
Data management for farmers can be challenging for those unfamiliar with data collection, storage, and application, as the lack of transparency and control may pose significant privacy risks.Additionally, contracts with technology providers may include opaque terms and conditions on data usage that farmers cannot fully comprehend, leading them to unintentionally consent to extensive data usage rights.Addressing these privacy concerns requires transparent data governance policies that give farmers more control and knowledge over their data [30,31].

Unauthorized Data Access Incidents
Significant privacy violations occurred when an agri-tech company illegally accessed data from IoT devices used by large-scale farming operations.This particular company engaged in analytic services exploited a weakness in data transmission and collected confidential information without consent [9].The collected data included comprehensive details on agricultural productivity, soil health, irrigation schedules, and personal information of the farm owners and crew, prompting serious concerns about the protection of personal data and the operational confidentiality of the farm [32].The consequence of this incident included a legal battle and substantial financial losses for the farming company.This highlights the disastrous impact of inadequate data security protocols in IoT-enabled farming contexts [33].

Cybersecurity Breaches
Another notable incident was a cyberattack on a mid-sized farm's cloud storage system, exploiting vulnerabilities in the cloud server provider's security system [34].Hackers bypassed security measures to access a vast amount of information, including real-time crop conditions, agriculture equipment usage, and financial records [35].Furthermore, personal information such as addresses and phone numbers were also compromised, disrupting farm operations and causing significant challenges for individuals whose identities were stolen, affecting their privacy.

Implementing Robust Data Encryption
In rural farming communities where information technology (IT) infrastructure is sometimes lacking, efficient data encryption is crucial to protect data collected through various IoT devices while in use and at rest [7].Additionally, in remote areas with higher risks of local network breaches, advanced encryption technologies ensure that data remains unintel-ligible to unauthorized users [36].Encryption also protects data from internal and external vulnerabilities, preventing unauthorized access by workers and service providers [37].

Ensuring Secure Transmission of Data
Since data transmission from IoT devices to cloud servers is a critical point where information can be intercepted, it is necessary to use reliable transmission mechanisms to prevent unauthorized access [25].Accordingly, data should be encrypted during transfer through technologies like Secure Sockets Layer and Transport Layer Security (SSL/TLS) since these provide a secure channel over an insecure network.This assures the authenticity and privacy of any data exchanged between servers located in the cloud and IoT devices [6,38].

Enhancing Knowledge and Training
A frequently overlooked aspect of data privacy is human errors that can be mitigated with proper guidance and instruction on the importance of data confidentiality and the risks of information leaks.Providing regular training and updates on emerging privacy issues, fraud attempts, and the best counter practices will also help maintain a knowledgeable workforce capable of securely managing personal information [29,39].
The above discussion illustrates how exhaustive the network of connections and protocols must be to ensure data security in the rural farm when employing AI and the IoT for a smart farming framework.This is illustrated in Figure 2, which highlights the critical measures that need to be taken to prevent security attacks and the roles of different stakeholders in a smart rural farm for monitoring and control.

Implementing Robust Data Encryption
In rural farming communities where information technology (IT) infrastructure is sometimes lacking, efficient data encryption is crucial to protect data collected through various IoT devices while in use and at rest [7].Additionally, in remote areas with higher risks of local network breaches, advanced encryption technologies ensure that data remains unintelligible to unauthorized users [36].Encryption also protects data from internal and external vulnerabilities, preventing unauthorized access by workers and service providers [37].

Ensuring Secure Transmission of Data
Since data transmission from IoT devices to cloud servers is a critical point where information can be intercepted, it is necessary to use reliable transmission mechanisms to prevent unauthorized access [25].Accordingly, data should be encrypted during transfer through technologies like Secure Sockets Layer and Transport Layer Security (SSL/TLS) since these provide a secure channel over an insecure network.This assures the authenticity and privacy of any data exchanged between servers located in the cloud and IoT devices [6,38].

Enhancing Knowledge and Training
A frequently overlooked aspect of data privacy is human errors that can be mitigated with proper guidance and instruction on the importance of data confidentiality and the risks of information leaks.Providing regular training and updates on emerging privacy issues, fraud attempts, and the best counter practices will also help maintain a knowledgeable workforce capable of securely managing personal information [29,39].
The above discussion illustrates how exhaustive the network of connections and protocols must be to ensure data security in the rural farm when employing AI and the IoT for a smart farming framework.This is illustrated in Figure 2, which highlights the critical measures that need to be taken to prevent security attacks and the roles of different stakeholders in a smart rural farm for monitoring and control.

Proposed Protocol
The authentication protocol described in this work involves three entities: the user U r j , the IoT Sensor layer IoT SL j , and the central server CS.Upon the user's login to the IoT Sensor layer, the protocol carries out authentication for every entity.Figure 3 depicts this framework for each entity.

Proposed Protocol
The authentication protocol described in this work involves three entities: the user  , the IoT Sensor layer  , and the central server .Upon the user's login to the IoT Sensor layer, the protocol carries out authentication for every entity.Figure 3 depicts this framework for each entity.The proposed authentication protocol consists of three sequential phases: registration, login, and verification. is a trustworthy authentication central server that includes an Edge gateway and cloud layer that is accountable for the user and the IoT sensor layer's registration and authentication.Furthermore, the proposed verification protocol utilizes timestamps, necessitating the temporal synchronization between the authentication server , user  , and IoT sensor layer  .Table 1 below lists the various notations of the proposed protocol and its description.One-way hash Function The proposed authentication protocol consists of three sequential phases: registration, login, and verification.CS is a trustworthy authentication central server that includes an Edge gateway and cloud layer that is accountable for the user and the IoT sensor layer's registration and authentication.Furthermore, the proposed verification protocol utilizes timestamps, necessitating the temporal synchronization between the authentication server CS, user U r j , and IoT sensor layer IoT SL j .Table 1 below lists the various notations of the proposed protocol and its description.One-way hash Function XOR Function ∥ Concatenation

Registration Phase
At the registration phase, the user, U r j and the IoT server, IoT SL j , initiate a registration request to the central server CS.As a reciprocal action, the central server provides the user, U r j , with the required values for the login and authentication stages to the IoT server, IoT SL j , as depicted in Figure 4.
tion request to the central server CS.As a reciprocal action, the central server provides the user,  , with the required values for the login and authentication stages to the IoT server,  , as depicted in Figure 4.  transmits its identity value,   , to CS through a secure channel.CS then calculates the  (Server information) value, which contains the information sent to  by the IoT server through a secure connection.
The  selects the user ID,  , and password,  , calculates the encrypted password,  , and transmits the registration request message ( ,  ,   ) together with the user's anonymity values to the central server .

𝑈𝑖𝑛𝑓 = 𝐻(𝐸𝑛𝑐𝑝𝑤 ∥ 𝑆 )
iii.The user's anonymity value,   , the user's secret information value,  , and the status-bit values are all stored in .The status-bit value is stored as 1 if the user completes the registration process, and 0 if there is no registration.Then  issues an identity to  .IoT SL j transmits its identity value, IoT SL I d j , to CS through a secure channel.CS then calculates the Serv j (Server information) value, which contains the information sent to IoT SL j by the IoT server through a secure connection.
The U r j selects the user ID, I d j , and password, P w i , calculates the encrypted password, Encpw i , and transmits the registration request message (I d j , Encpw i , U r I d j ) together with the user's anonymity values to the central server CS.

Encpw i = H I d j ∥ h(P w i )
ii.The CS generates the user's confidential information value, Uin f j , and creates U r I d j , Uin f j , Encpw i , H( * ), and H(S k ) as a user identity.
iii.The user's anonymity value, U r I d j , the user's secret information value, Uin f j , and the status-bit values are all stored in CS.The status-bit value is stored as 1 if the user completes the registration process, and 0 if there is no registration.Then CS issues an identity to U r j .

Login and Verification Phases
The verification of legitimate users is conducted during the login and verification phase as shown in Figure 5.The user, U r j , sends a registration request message to the IoT sensor layer, IoT SL j , in order to log in, and CS verifies each entity.Then, U r j , IoT SL j , and CS generates the similar session key.

i.
U r j inputs their U r I d j and password, P w i .CS calculates the Encpw i ′ and compares the information with Encpw i .The user is confirmed as a legitimate user if the information matches.Termination of the session occurs when the information fails to correspond.

Login and Verification Phases
The verification of legitimate users is conducted during the login and verification phase as shown in Figure 5.The user,  , sends a registration request message to the IoT sensor layer,  , in order to log in, and  verifies each entity.Then,  ,  , and  generates the similar session key.ii.U r j , the verified user, selects a random value, n i 1 , for each session.Using H(S k ), Uin f j , and the chosen random value n i 1 computes C i and the user verifier VerU r j .Next, a timestamp called t s is generated.
iii.The user, U r j , sets up the login request message (C i , VerU r j , t s , U r I d j by including their anonymity value, U r I d j , calculating C i and t s , and then transmits the message to the IoT sensor layer, IoT SL j .
iv.The IoT sensor layer, IoT SL j , upon receiving the login request message from U r j , chooses a random number, n i 2 , for each session and calculates D i and Ver f s i using the Serv j value received during the registration step.
IoT SL j sends the login request message to CS.The message is set up for the C i , U r I d j (received from the user U r j ), the IoT SL j unique identification value IoT SL I d j , D i (which was generated earlier), and the timestamp t s .vi.The CS that received the login request message from IoT SL j calculates t s ′ = t s + t s ′ represents the timestamp indicating the moment the server received the login message.t s refers to the shortest possible authentication time, taking into account the time it takes for the login message to be transmitted.vii.CS produces Serv j using the received IoT SL I d j value and its own master key, and then retrieves the n i 2 value using the D i value obtained from the login request message.
Using the U r I d j from the login request message, the system can search for the U r In f o i generated during the registration phase.CS randomly selects the value n i 3 and calculates the n i 1 ′ value by using the received C i value, the generated H(S k ), and the previously retrieved U r In f o i .By utilizing a calculated n i 1 value and H(S k ), the VerU r j ′ value is generated.After verifying the received VerU r j value with the login request message, the system authenticates the user as legitimate and generates the session key SK.If there is no match, the session will be terminated.
x.A timestamp, t s , is generated afterward, it calculates the E i , F i , L i , and transmits the mutual authentication message (E i , F i , L i , t s ) to IoT SL j .
xi. Upon receiving the mutual authentication message, IoT SL j calculates the n i 1 n i 3 ′ using its own IoT SL I d j value and the random value n i 2 .
xii.This computes the value of H(C ∥ H(S k ) ′ by utilizing its own IoT SL I d j value and the random value n i 2 , with the F i value obtained from the mutual authentication message.It generates the session key, SK, by combining its own random value, n i 2 , with the previously computed n i 1 n i 3 ′ .Afterwards, the IoT SL j calculates L i and sends a login response message (F i , t s ) to the user U r j .
xiii.Upon receiving the login request message, the user performs a computation to confirm the time difference meets the required criteria.t s ′ represents the timestamp at which the server receives the login message, while vi.The  that received the login request message from    calculates   '=  + 1 , and then verifies the difference between   ′ and   , denoted as ⊿  ≥   '−  .In this context, ⊿  ′ represents the timestamp indicating the moment the server received the login message.  refers to the shortest possible authentication time, taking into account the time it takes for the login message to be transmitted.
vii.  produces   using the received      value and its own master key, and then retrieves the   2 value using the   value obtained from the login request message.
′ t s ≥ t s ′ −t s represents the minimum authentication time, taking into account the transmission time for the login message.Using the L i value obtained from the mutual authentication message, U r j is able to calculate the value of (n i 2 n i 3 using the C i value provided by the user and the H(S k ) value. (n xiv.The user, U r j , can independently process a randomly generated value (n i 1 ) along with (n i 2 n i 3 .By utilizing its own value C i and the H(S k ) value, the U r j can generate the session key SK.Thus, the user U r j , IoT SL j , and authentication server CS can authenticate by producing an identical session key.

Formal Security Analysis and Verification Using the AVISPA Tool
The robustness of the proposed protocol is tested using the AVISPA tool, which employs a role-based scripting language, High-Level Protocol Specification Language (HLPSL) that helps with protocol analysis and implementation to determine whether a security protocol is SAFE or UNSAFE [40].AVISPA mimics the protocol behavior to find potential vulnerabilities using back-ends such as the OFMC (on-the-fly model checker), CL-AtSe (constraint-logic-based attack searcher), SATMC (SAT-based model checker), and TA4SP (tree automata-based security protocol), shown in Figure 6, of which the OFMC and CL-AtSe back-ends were used to simulate our proposed protocol.Also, the Dolev-Yao threat model was implemented to examine the presence of intruder attacks in the protocol [41].In the present study, the different entities, User, IoT Senser Layer, and Central Server, are represented as the agents US, IOTSL, and CS, respectively.Figures 7-9 show the HLPSL script and their roles, while Figures 10-12 discuss the HLPSL script of the sessions, environment, and goals.Figure 13 shows the SPAN protocol simulation built using the message sequence between the agents discussed in the next section.In the present study, the different entities, User, IoT Senser Layer, and Central Server, are represented as the agents US, IOTSL, and CS, respectively.Figures 7-9 show the HLPSL script and their roles, while Figures 10-12 discuss the HLPSL script of the sessions, environment, and goals.Figure 13 shows the SPAN protocol simulation built using the message sequence between the agents discussed in the next section.In the present study, the different entities, User, IoT Senser Layer, and Central Server, are represented as the agents US, IOTSL, and CS, respectively.Figures 7-9 show the HLPSL script and their roles, while Figures 10-12 discuss the HLPSL script of the sessions, environment, and goals.Figure 13 shows the SPAN protocol simulation built using the message sequence between the agents discussed in the next section.Description: The User (US) initiates the protocol by registering itself with the identity 'Newuser' and sending its identity along with a nonce 'N1' encrypted with the public key of Central Server 'Kcs'.
Purpose: To securely communicate the new user's identity and nonce to the Central Server for registration.
Purpose: To provide the user with an identity, the authentication of nonces, and the time stamps of the session while ensuring integrity.Purpose: To securely communicate the new user's identity and nonce to the Central Server for registration.
2. CS->US: /\ SND({USid'.HashFunc(N1'.N2').T1start'.T1expire'}_Kus) Description: The Central Server (CS) decrypts the previous encrypted message using its private key.After verifying the user, it assigns an identity Usid' and sends it along   Purpose: To securely communicate the new user's identity and nonce to the Central Server for registration.

3.
US->CS: /\ SND({{N2'.T1'}_inv(Kus)}_Kcs) Description: The User (US) decrypts the received message using its private key and sends back the nonce 'N2' that is computed from the hash function, along with token 'T1', which are encrypted with its private key 'Kus" and then encrypted again with the public key of Central Server 'Kcs'.
Purpose: To confirm the user's identity and authentication of the nonce, ensuring mutual authentication and integrity through the asymmetric key pair providing a signature.

Attack Prevention
Several security issues are addressed by the proposed protocol, which are discussed below.
Identity and Password Guessing Attack: In this type of attack, the intruder attempts to guess a user's identity or password by trying multiple combinations, especially if it uses a low-entropy password or an easily guessable identity.Our proposed protocol ensures that this is not possible through the use of cryptographic hashing functions and hybrid encryption.To understand the identity of the User, the intruder will have to guess multiple unknown parameters simultaneously, all of which are protected by non-invertible hash functions.
Impersonation-of-user attack: In this type of attack, the attacker poses as the one who initiated the communication.Our proposed protocol mitigates this by involving nonces (N1 and N2) and verification through the hash function, making it difficult for the attacker to use old messages or predict values needed to impersonate the user.For instance, /\({N1 ′ .Newuser'}_Kcs) and /\({USid'.HashFunc(N1 ′ .N2 ′ ).T1start'.T1expire'}_Kus) involve the fresh exchange of nonces, ensuring message uniqueness and validity for only one session.
Impersonation-of-server attack: This attack occurs when the attacker tries to impersonate the server to intercept or alter communications.This is prevented by requiring mutual authentication and the use of encrypted nonces.Messages encrypted with the public key ensure that only the legitimate server can decrypt and respond correctly: /\ ({USid'.HashFunc(N1 ′ .N2 ′ ).T1start'.T1expire'}_Kus).The use of the witness function, also /\ witness(CS,US,auth_1,N2 ′ ), verifies the authenticities of the nonces and the communication parties, preventing server impersonation.
Privilege Insider Attack: This attack occurs when a malicious insider attempts to misuse their access to gain unauthorized information.Our protocol limits such attacks by ensuring that sensitive information is not directly accessible or stored in a decipherable form.For instance, identities and other data are hashed before storage or transmission, and the function /\ ({HashFunc(USid.Request1 ′ )}_Kcsus') /\ ({HashFunc(NIOTSLid.Information1 ′ )}_Kcsiotsl) ensures that even if an insider accesses stored data, they cannot easily reverseengineer to compute the original data.
Replay attacks: Replay attacks are possible when the intruder is able to send an old message and gain unauthorized access successfully.The proposed protocol withstands these attacks using fresh nonces and current time stamps, and it generates /\ T1start':=new() /\ T1expire':=new() /\ N1':=new().Since new() operators are performed at every stage of the communication, it prevents the intruder from performing a replay attack (/\ T2start':=new() /\ T2expire':=new() /\ N2':=new()).Four protocol sessions were considered for testing against a replay attack, where one session contained all legitimate participants, and all other sessions contained an intruder impersonating any of the legitimate participants.Across all configurations, with different attack scenarios, the results showed that the protocol is safe using both OFMC and CL-AtSe.The obtained summaries demonstrate that the protocol is safe in all sessions withou intruding attacks while guaranteeing that all secrecy and authentication goals are fulfilled

AVISPA Statistical Comparison
The OFMC and Cl-AtSe outcome summaries were compared against various othe authentication protocols and are detailed in Table 2.In the table, computation time refer to the complete execution time of a protocol transaction or the length of a series of trans actions that are being examined.This can include aspects like the time needed for authen tication, key exchange, and data transfer.Since extended transaction durations might no be ideal for applications that need to be completed quickly, it is important to know th computation time to assess its practical applicability.In terms of performance testing

AVISPA Statistical Comparison
The OFMC and Cl-AtSe outcome summaries were compared against various other authentication protocols and are detailed in Table 2.In the table, computation time refers to the complete execution time of a protocol transaction or the length of a series of transactions that are being examined.This can include aspects like the time needed for authentication, key exchange, and data transfer.Since extended transaction durations might not be ideal for applications that need to be completed quickly, it is important to know the computation time to assess its practical applicability.In terms of performance testing comparisons, our proposed protocol was simulated several times using an Intel Core i5 Asus computer with 8 GB of RAM and MS Windows 10 Enterprise 64-bit.The other columns in the table refer to depth and visited nodes.While depth indicates how thoroughly a given scenario is examined, visited nodes refer to how many nodes have been looked into.So, a high number of visited nodes and significant depth suggest that a detailed search was performed quickly.
When compared against other protocols, our protocol demonstrates notable improvements in various performance metrics.Firstly, as shown in Figure 16, our protocol matches the depth of [46] with a depth of 12 but with a decrease in the number of visited nodes (119) when compared against [46]'s 348 visited nodes, which demonstrates a more efficient traversal, indicating that our proposal is optimized to reach the desired outcomes and decision-making process within the IoT network.Secondly, regarding the search time, our protocol has one of the fastest search times, second only to [45] which has a much lower depth of four and fewer visited nodes at sixteen.This demonstrates that our protocol is highly efficient in quickly locating the necessary data, which is crucial in real-time applications like smart farming.Thirdly, in terms of computation time, an important parameter for IoT applications that require fast processing and quick response times, our protocol had one of the shortest amounts of time required for computing.Finally, considering the computation time and the ability to handle messages, our protocol could handle the highest number of messages (11) without compromising performance as illustrated in Figure 17.As discussed in the previous section, the higher number of messages has contributed significantly to our protocol's robust communication and data exchange, which are vital components for comprehensive IoT systems in smart farming.

Conclusions
The article presents a comprehensive framework for privacy-centered AI and IoT solutions designed to monitor and control smart rural farms.It also presents significant privacy and security concerns by discussing the need for such a framework to meet the increasing demand for agriculture production and the increasing integration of IoT technologies for enhancing efficiency, productivity, and sustainability.To address these concerns, we propose a protocol that ensures secure data exchange across the IoT Sensor Layer, the

Conclusions
The article presents a comprehensive framework for privacy-centered AI and IoT solutions designed to monitor and control smart rural farms.It also presents significant privacy and security concerns by discussing the need for such a framework to meet the increasing demand for agriculture production and the increasing integration of IoT technologies for enhancing efficiency, productivity, and sustainability.To address these concerns, we propose a protocol that ensures secure data exchange across the IoT Sensor Layer, the Central Server, and the User.Through a three-phase scheme, the protocol employs encryption using symmetric and asymmetric key pairs, secure communication channels, concatenations, hash functions, and other rigorous verification mechanisms to efficiently safeguard the data gathered from IoT devices and sensitive information from unauthorized access and potential breaches.
The robustness and efficiency of the proposed protocol were also validated using the AVISPA tool through the OFMC and CL-AtSe back-ends.The simulation finding showed that the proposed protocol can withstand identity guessing, impersonation, replay attacks, man-in-the-middle attacks, safeguard the data from privilege-insider attacks, and ensure anonymity and untraceability.Furthermore, the proposed protocol outperformed existing security protocols in performance metrics, such as computation time, search time, visited nodes, and depth, demonstrating its suitability for real-time applications in smart rural farms.The present study thus adds to the growing body of literature on smart farming by providing a secure and privacy-centric solution to enhance the resilience of rural farm monitoring and control.This study also presents the groundwork for future work to expand on this robust protocol by investigating the application of the protocol in diverse agricultural environments, which will help ensure the protocol's adaptability and effectiveness in various settings.Additionally, the protocol can be incorporated into large-scale farm operations to examine its scalability and efficiency when handling vast amounts of data and numerous IoT devices.Also, further studies can explore the integration of ML into the protocol to enhance its capabilities for real-time anomaly detection and predictive analytics.

Figure 1 .
Figure 1.Internet-based framework for smart farming.

Figure 1 .
Figure 1.Internet-based framework for smart farming.

Figure 2 .
Figure 2. Framework illustrating roles and need for data privacy and security.Figure 2. Framework illustrating roles and need for data privacy and security.

Figure 2 .
Figure 2. Framework illustrating roles and need for data privacy and security.Figure 2. Framework illustrating roles and need for data privacy and security.

Figure 3 .
Figure 3. Framework for each entity of the proposed protocol.

Figure 3 .
Figure 3. Framework for each entity of the proposed protocol.

Figure 7 .
Figure 7. Role specification of the User (US) in HLPSL.Figure 7. Role specification of the User (US) in HLPSL.

Figure 7 . 25 Figure 8 .
Figure 7. Role specification of the User (US) in HLPSL.Figure 7. Role specification of the User (US) in HLPSL.Sensors 2024, 24, x FOR PEER REVIEW 14 of 25

Figure 9 .
Figure 9. Role specification of the Central Server (CS) in HLPSL.

Figure 10 .
Figure 10.Role specification of sessions in AVISPA.

Figure 11 .
Figure 11.Role specification of the environment in AVISPA.

Figure 11 .
Figure 11.Role specification of the environment in AVISPA.Figure 11.Role specification of the environment in AVISPA.

Figure 11 .
Figure 11.Role specification of the environment in AVISPA.Figure 11.Role specification of the environment in AVISPA.

Figure 12 .
Figure 12.Role specification of goals in AVISPA.

Figure 13 .
Figure 13.The message sequence chart from the protocol simulation.

6. 1 .
Protocol Steps and Messages 1. US->CS: /\ SND({N1'.Newuser'}_Kcs)Description: The User (US) initiates the protocol by registering itself with the identity Newuser' and sending its identity along with a nonce N1′ encrypted with the public key of Central Server Kcs'.

Figure 13 .
Figure 13.The message sequence chart from the protocol simulation.

6. 1 .
Protocol Steps and Messages 1. US->CS: /\ SND({N1'.Newuser'}_Kcs)Description: The User (US) initiates the protocol by registering itself with the identity Newuser' and sending its identity along with a nonce N1′ encrypted with the public key of Central Server Kcs'.

Figure 13 .
Figure 13.The message sequence chart from the protocol simulation.

Figure 14 .
Figure 14.Summary of the protocol simulation using the OFMC back-end.

Figure 15 .
Figure 15.Summary of the protocol simulation using the CL-AtSe back-end.

Figure 15 .
Figure 15.Summary of the protocol simulation using the CL-AtSe back-end.

Table 1 .
Proposed protocol notation and description.

Table 1 .
Proposed protocol notation and description.
sends the login request message to .The message is set up for the   ,      (received from the user    ), the    unique identification value      ,   (which was generated earlier), and the timestamp   .vi.The  that received the login request message from    calculates   '=  + 1 , and then verifies the difference between   ′ and   , denoted as ⊿  ≥   '−  .In this context, ⊿  ′ represents the timestamp indicating the moment the server received the login message.refers to the shortest possible authentication time, taking into account the time it takes for the login message to be transmitted.vii. produces   using the received      value and its own master key, and then retrieves the   2 value using the   value obtained from the login request message.The message is set up for the   ,      ser    ), the    unique identification value      ,   earlier), and the timestamp   .the login request message from    calculates   '=  + 1 , ifference between   ′ and   , denoted as ⊿  ≥   '−  .In this ts the timestamp indicating the moment the server received the rs to the shortest possible authentication time, taking into acfor the login message to be transmitted.ing the received      value and its own master key, and alue using the   value obtained from the login request mes- v. viii.By utilizing the calculated   2 value,  generates the   Z value.If the   ' value matches the   value received in the login request message, it is confirmed as the legitimate    .If there is no match, the connection is terminated.  ′ = ((     ∥   ) ∥   2 ′)   =?   ′ t s ≥ t s ′ −t s .In this context, 11 of 25 request message to .ted   2 value,  generates the   Z value.If the   ' value received in the login request message, it is confirmed as f there is no match, the connection is terminated.
By utilizing the calculated n i 2 value, CS generates the Ver f s i Z value.If the Ver f s i ′ value matches the D i value received in the login request message, it is confirmed as the legitimate IoT SL j .If there is no match, the connection is terminated.
sends the login request message to .The message is set up for the   ,      (received from the user    ), the    unique identification value      ,   (which was generated earlier), and the timestamp   .