[go: up one dir, main page]

TWI730355B - Dynamic key generating method for wireless communication - Google Patents

Dynamic key generating method for wireless communication Download PDF

Info

Publication number
TWI730355B
TWI730355B TW108125987A TW108125987A TWI730355B TW I730355 B TWI730355 B TW I730355B TW 108125987 A TW108125987 A TW 108125987A TW 108125987 A TW108125987 A TW 108125987A TW I730355 B TWI730355 B TW I730355B
Authority
TW
Taiwan
Prior art keywords
key
message
communication
data packet
array
Prior art date
Application number
TW108125987A
Other languages
Chinese (zh)
Other versions
TW202106060A (en
Inventor
賞恩 邱
Original Assignee
新加坡商優納比控股私人有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 新加坡商優納比控股私人有限公司 filed Critical 新加坡商優納比控股私人有限公司
Priority to TW108125987A priority Critical patent/TWI730355B/en
Priority to JP2020125618A priority patent/JP7017802B2/en
Publication of TW202106060A publication Critical patent/TW202106060A/en
Application granted granted Critical
Publication of TWI730355B publication Critical patent/TWI730355B/en

Links

Images

Landscapes

  • Mobile Radio Communication Systems (AREA)
  • Telephone Function (AREA)

Abstract

A dynamic key generating method for wireless communication is provided. For each time transmitting encrypted data, a communication key obtains from a first key array to encrypt the data. Generating information which indicates a second key array and includes first verification information is randomly generated. The number of the byte of the generating information is different from the number of the byte of the encrypted data. A communication key obtains from the first key array to encrypt the generating information. Send the encrypted generating information and ask second verification information. The second verification information should be sent when the first verification information is verified. Compare the second verification information when it is received. When the second verification information is correct, the first key array is replaced by the second key array which the communication key obtains from for each time transmitting encrypted data.

Description

無線通信的動態金鑰產生方法Dynamic key generation method for wireless communication

本發明係關於一種動態金鑰產生方法,特別是一種針對無線通信環境的動態金鑰產生方法。 The present invention relates to a method for generating a dynamic key, in particular to a method for generating a dynamic key for a wireless communication environment.

人類使用網際網路存取網路資料、與人聯絡溝通,而物品現在也開始透過物聯網(Internet of Thing)互相傳送資料進行溝通。能源業在不同地區設置的能源用量表,可以透過物聯網隨時回傳用戶的能源使用狀況,讓能源業者統計分析能源使用狀況,在不同時段中調整能源的轉換量和供應傳輸量,使得能源利用率更高。食品業透過物聯網取得各地農田的溫濕度計、土壤檢測計所偵測的感測資料,統計分析農作品的生產情形,根據農作物的生產情形規畫調整每一季生產的食品種類或產能,並根據產線狀況預先規畫後續的行銷計畫。 Humans use the Internet to access network data, communicate with people, and objects are now beginning to communicate with each other through the Internet of Things (Internet of Things). The energy consumption meters set up by the energy industry in different regions can return users' energy usage status at any time through the Internet of Things, allowing energy companies to analyze the energy usage status, and adjust the energy conversion and supply transmission volume in different periods to make energy use The rate is higher. The food industry uses the Internet of Things to obtain the sensing data detected by the temperature and humidity meters and soil detectors in various farmlands, statistically analyze the production situation of agricultural works, and plan and adjust the types of food or production capacity produced in each season according to the production situation of the crops, and Pre-plan the follow-up marketing plan according to the production line status.

準確的統計分析和精準的商業決定,需要大量的感測資料作為支持。為了取得大量的感測資料,資料使用業者需要廣泛地建置感測器,並依靠物聯網和雲端空間來傳輸資料和儲存資料。這將會消耗資料使用業者許多的建置成本,也使得這些收集到的感測資料成為資料使用業者的重要資產,因此如何提升感測資料的資訊安全性,保護資料使用業者的重要資產,是物聯網技術的另一項重要議題。 Accurate statistical analysis and precise business decisions require a large amount of sensory data as support. In order to obtain a large amount of sensing data, data users need to build sensors extensively and rely on the Internet of Things and cloud space to transmit and store data. This will consume a lot of the construction cost of the data user, and also make the collected sensing data become an important asset of the data user. Therefore, how to improve the information security of the sensor data and protect the important asset of the data user is Another important topic of IoT technology.

本發明在於提供一種無線通信的動態金鑰產生方法,藉由動態金鑰來加密感測資料,提高感測資料在無線通信環境中傳輸的資料安全性,進而保護資料擁有者的重要資產。 The present invention is to provide a dynamic key generation method for wireless communication, which encrypts the sensing data by the dynamic key, improves the data security of the sensing data in the wireless communication environment, and protects the important assets of the data owner.

本發明所揭露的無線通信的動態金鑰產生方法,包括於每次傳輸加密資料時,自第一金鑰陣列中取得通訊金鑰,並以取得的通訊金鑰進行資料加密。隨機地產生與加密資料位元組數不同的生成訊息。生成訊息指示第二金鑰陣列,且包含第一驗證訊息。自第一金鑰陣列中取得通訊金鑰,加密生成訊息。發送已加密的生成訊息並要求第二驗證訊息。第二驗證訊息係於第一驗證訊息被驗證正確後發送。比對已接收的第二驗證訊息,當第二驗證訊息比對正確時,以第二金鑰陣列取代第一金鑰陣列,據以於每次傳輸加密資料時,自第二金鑰陣列中取得通訊金鑰來進行資料加密。 The method for generating a dynamic key for wireless communication disclosed in the present invention includes obtaining a communication key from the first key array every time an encrypted data is transmitted, and encrypting the data with the obtained communication key. Randomly generate generated messages that are different from the number of encrypted data bytes. The generated message indicates the second key array and includes the first verification message. Obtain the communication key from the first key array and encrypt it to generate a message. Send the encrypted generated message and request a second verification message. The second verification message is sent after the first verification message is verified correctly. Compare the received second verification message. When the second verification message is correctly compared, replace the first key array with the second key array, so that every time encrypted data is transmitted, from the second key array Obtain the communication key to encrypt data.

本發明所揭露的無線通信的動態金鑰產生方法,包括於每次接收到加密的資料封包時,依據資料封包的位元組數,判斷資料封包的類型。自資料封包對應的當前金鑰陣列中取得多個通訊金鑰其中之一,解密資料封包。當資料封包為生成訊息類型時,判斷資料封包解密後的資料內容是否正確。當解密後的資料內容比對正確時,發送驗證訊息。依據生成訊息類型的資料封包解密後的資料內容,判斷新金鑰陣列,並以新金鑰陣列取代當前金鑰陣列,據以於每次接收到加密的資料封包時,自新金鑰陣列中取得多個通訊金鑰其中之一來進行資料解密。 The method for generating a dynamic key for wireless communication disclosed in the present invention includes determining the type of the data packet according to the number of bytes of the data packet each time an encrypted data packet is received. Obtain one of a plurality of communication keys from the current key array corresponding to the data packet, and decrypt the data packet. When the data packet is of the generated message type, it is determined whether the decrypted data content of the data packet is correct. When the content of the decrypted data is correctly compared, a verification message is sent. Determine the new key array based on the decrypted data content of the data packet of the generated message type, and replace the current key array with the new key array, so that every time an encrypted data packet is received, the new key array is replaced Obtain one of multiple communication keys to decrypt data.

根據上述本發明所揭露的無線通信的動態金鑰產生方法,藉由在傳輸資料時是從金鑰陣列中選擇的通訊金鑰來對資料進行加密,避免使用固定的通訊金鑰加密,讓資料加密的安全性更高,資料被監聽時不易被正確讀取。此外,動態金鑰產生方法更不定期地依據隨機產生的訊息,更換金鑰陣列,讓通訊金鑰的多元性更高。 According to the dynamic key generation method for wireless communication disclosed in the present invention, the data is encrypted by the communication key selected from the key array during data transmission, avoiding the use of fixed communication key encryption, so that the data The security of encryption is higher, and the data is not easy to be read correctly when monitored. In addition, the dynamic key generation method more irregularly replaces the key array based on randomly generated messages, so that the communication key is more diversified.

以上之關於本揭露內容之說明及以下之實施方式之說明係用以示範與解釋本發明之精神與原理,並且提供本發明之專利申請範圍更進一步之解釋。 The above description of the disclosure and the following description of the embodiments are used to demonstrate and explain the spirit and principle of the present invention, and to provide a further explanation of the scope of the patent application of the present invention.

1:無線感測裝置 1: Wireless sensing device

2:基地台 2: base station

3:伺服器 3: server

4:資料使用端 4: Data use side

S101~S111、S301~S317、S501~S509、S701~S713:步驟 S101~S111, S301~S317, S501~S509, S701~S713: steps

第1圖係根據本發明一實施例之無線通信網路系統的示意圖。 Figure 1 is a schematic diagram of a wireless communication network system according to an embodiment of the present invention.

第2圖係根據本發明一實施例之無線通信的動態金鑰產生方法的步驟流程圖。 FIG. 2 is a flowchart of the steps of a method for generating a dynamic key for wireless communication according to an embodiment of the present invention.

第3圖係根據本發明另一實施例之無線通信的動態金鑰產生方法的步驟流程圖。 FIG. 3 is a flowchart of the steps of a method for generating a dynamic key for wireless communication according to another embodiment of the present invention.

第4圖係根據本發明再一實施例之無線通信的動態金鑰產生方法的步驟流程圖。 FIG. 4 is a flowchart of the steps of a method for generating a dynamic key for wireless communication according to another embodiment of the present invention.

第5圖係根據本發明又一實施例之無線通信的動態金鑰產生方法的步驟流程圖。 FIG. 5 is a flowchart of the steps of a method for generating a dynamic key for wireless communication according to another embodiment of the present invention.

以下在實施方式中詳細敘述本發明之詳細特徵以及優點,其內容足以使任何熟習相關技藝者了解本發明之技術內容並據以實施,且根據本說明書所揭露之內容、申請專利範圍及圖式,任何熟習相關技藝者可輕易地理解本發明相關之目的及優點。以下之實施例係進一步詳細說明本發明之觀點,但非以任何觀點限制本發明之範疇。 The detailed features and advantages of the present invention will be described in detail in the following embodiments. The content is sufficient to enable anyone familiar with the relevant art to understand the technical content of the present invention and implement it accordingly, and according to the content disclosed in this specification, the scope of patent application and the drawings. Anyone who is familiar with relevant skills can easily understand the purpose and advantages of the present invention. The following examples further illustrate the viewpoints of the present invention in detail, but do not limit the scope of the present invention by any viewpoint.

請參照第1圖及第2圖,第1圖係為根據本發明一實施例之無線通信網路系統的示意圖,第2圖係為根據本發明一實施例之無線通信的動態金鑰產生方法的步驟流程圖。如圖所示,動態金鑰產生方法運用於無線通信網路環境中。無線通信網路環境例如具有無線感測裝置1、基地台2、伺服器3及資料使用端4。無線感測裝置1具備有無線通訊功能及感測器功能。無線通訊功能例如是以通訊模組來實現,通訊模組可以透過長距離傳輸的低功率廣域網路(Low-Power Wide-Area Network,LPWAN)如SigFox、LoRa(Long Range)、NB-IoT(窄頻帶物聯網)等通訊技術與通訊技術匹配的基地台2連線,互相傳送資料和指令。除了LPWAN以外,無線感測裝置1的無線通訊功能也可以透過其他通訊技術例如LTE (Long Term Evolution)、LTE-A(LTE-Advanced)、GSM、UMTS、W-CDMA、CDMA2000、WiMAX、WiMAX2、IEEE802.16或WiFi(Wireless Fidelity)、Z-wave等方式來實現,本實施例不予限制。 Please refer to Figures 1 and 2. Figure 1 is a schematic diagram of a wireless communication network system according to an embodiment of the present invention, and Figure 2 is a dynamic key generation method for wireless communications according to an embodiment of the present invention Flow chart of the steps. As shown in the figure, the dynamic key generation method is used in a wireless communication network environment. The wireless communication network environment includes, for example, a wireless sensing device 1, a base station 2, a server 3, and a data user terminal 4. The wireless sensing device 1 has a wireless communication function and a sensor function. For example, the wireless communication function is realized by a communication module. The communication module can be transmitted through a Low-Power Wide-Area Network (LPWAN) such as SigFox, LoRa (Long Range), NB-IoT (narrow range). The base station 2 that matches the communication technology and the communication technology is connected to each other to transmit data and instructions. In addition to LPWAN, the wireless communication function of the wireless sensing device 1 can also be achieved through other communication technologies such as LTE (Long Term Evolution), LTE-A (LTE-Advanced), GSM, UMTS, W-CDMA, CDMA2000, WiMAX, WiMAX2, IEEE802.16 or WiFi (Wireless Fidelity), Z-wave, etc., this embodiment No restrictions.

無線感測裝置1的感測器功能,可以設置感測器於無線感測裝置1中來實現,但不以此為限。感測器例如是溫度感測器、濕度感測器、霍爾感測器(Hall sensor)、磁感測器(Magnetic sensor)、地磁感測器(Geomagnetic sensor)、加速度感測器(Accelerometer sensor)、震動感測器(Vibration sensor)、紅外線感測器(IR sensor)或其他合適的感測器。以溫度感測器和溼度感測器為例來說,無線感測裝置1的溫度感測器和溼度感測器感測環境的溫度和溼度,並依據無線通訊協定的通訊頻率及資料量標準,將感測到的溫溼度資料傳送出去,使基地台2接收。無線感測裝置1的感測器種類和數量可由所屬技術領域具有通常知識者,依實際需求配置,本實施例不予限制。 The sensor function of the wireless sensor device 1 can be implemented by installing a sensor in the wireless sensor device 1, but is not limited to this. The sensor is, for example, a temperature sensor, a humidity sensor, a Hall sensor, a magnetic sensor, a geomagnetic sensor, and an acceleration sensor. ), Vibration sensor, IR sensor or other suitable sensors. Taking temperature sensors and humidity sensors as examples, the temperature sensors and humidity sensors of the wireless sensing device 1 sense the temperature and humidity of the environment, and are based on the communication frequency and data volume standards of the wireless communication protocol , To transmit the sensed temperature and humidity data to the base station 2 to receive it. The types and number of sensors of the wireless sensor device 1 can be configured by persons with ordinary knowledge in the relevant technical field according to actual requirements, and this embodiment is not limited.

基地台2接收無線感測裝置1產生的感測資料後,經由無線或有線的網際網路傳輸至伺服器3,由伺服器3將資料進行整理儲存。而資料使用端4同樣也透過有線或無線的網際網路連線至伺服器3,根據每個資料使用端4不同的資料存取權限,從伺服器3取得感測資料。資料使用端4例如是業者或個人使用者的電腦、行動裝置、伺服器、雲端主機或其他合適的裝置,本實施例不予限制。總體來說,運用動態金鑰產生方法的無線通信網路環境,係指無線感測裝置1透過無線通信的方式傳輸其感測資料至基地台2,但不限制基地台2、伺服器3及資料使用端4之間是有線傳輸或無線傳輸。 After the base station 2 receives the sensing data generated by the wireless sensing device 1, it is transmitted to the server 3 via the wireless or wired Internet, and the server 3 organizes and stores the data. The data consumer 4 also connects to the server 3 through a wired or wireless Internet, and obtains sensing data from the server 3 according to the different data access permissions of each data consumer 4. The data user 4 is, for example, a computer, a mobile device, a server, a cloud host, or other suitable device of a business or individual user, which is not limited in this embodiment. Generally speaking, the wireless communication network environment using the dynamic key generation method refers to the wireless sensing device 1 transmitting its sensing data to the base station 2 through wireless communication, but it does not limit the base station 2, the server 3, and the base station 2. There is wired transmission or wireless transmission between the data use terminals 4.

此外,本案的實施例同樣不限制無線通信網路環境中的無線感測裝置1、基地台2、伺服器3及資料使用端4分別的數量。舉例來說,在無線感測裝置1無線傳輸範圍內的一個或多個基地台2都能接收到無線感測裝置1加密的感測資料。基地台2收集到的感測資料可以傳送到第一 層伺服器3,再由第二層伺服器3向第一層伺服器3存取。第一層伺服器3或第二層伺服器3可以提供給一或多個資料使用端4存取資料。資料使用端4亦可以再將感測資料提供給另一個資料使用端4。於所屬技術領域具有通常知識者可以依據實際需求設定存取權限、裝置數量和資料存取流程,本實施例不予限制。 In addition, the embodiment of the present case also does not limit the respective numbers of the wireless sensing device 1, the base station 2, the server 3, and the data user 4 in the wireless communication network environment. For example, one or more base stations 2 within the wireless transmission range of the wireless sensing device 1 can receive the sensing data encrypted by the wireless sensing device 1. The sensing data collected by base station 2 can be sent to the first The layer server 3 is then accessed from the second layer server 3 to the first layer server 3. The first-tier server 3 or the second-tier server 3 can be provided to one or more data users 4 to access data. The data consumer 4 can also provide the sensing data to another data consumer 4. Those with ordinary knowledge in the relevant technical field can set the access authority, the number of devices, and the data access process according to actual needs, which is not limited in this embodiment.

另一方面,動態金鑰產生方法亦可以根據不同的無線通信網路環境做不同的運用。舉例來說,當無線感測裝置1產生的感測資料以通訊金鑰加密後,透過廣播的方式傳輸出去。由無線感測裝置1無線傳輸範圍內的一個或多個基地台2接收,並傳送至第一層伺服器3後,由第一層伺服器3根據感測資料的解密金鑰進行解碼,則動態金鑰產生方法由無線感測裝置1和第一層伺服器3執行。換言之,當第一層伺服器3接收到感測資料,但並未解密,而是根據感測資料的擁有者將感測資料分類地傳送給第二層伺服器3,由第二層伺服器3根據感測資料的解密金鑰進行解碼,則動態金鑰產生方法由無線感測裝置1和第二層伺服器3執行。除了前述方式,動態金鑰產生方法亦可以由無線感測裝置1和資料使用端4執行,或由第一層伺服器3和資料使用端4執行,本案的實施例不予限制。 On the other hand, the dynamic key generation method can also be used differently according to different wireless communication network environments. For example, when the sensing data generated by the wireless sensing device 1 is encrypted with a communication key, it is transmitted by broadcasting. After being received by one or more base stations 2 within the wireless transmission range of the wireless sensing device 1, and transmitted to the first layer server 3, the first layer server 3 decodes the data according to the decryption key of the sensed data, then The dynamic key generation method is executed by the wireless sensor device 1 and the first layer server 3. In other words, when the first layer server 3 receives the sensed data, but does not decrypt it, it sends the sensed data to the second layer server 3 according to the owner of the sensed data, and the second layer server 3 3 Decode according to the decryption key of the sensing data, and the dynamic key generation method is executed by the wireless sensing device 1 and the second layer server 3. In addition to the foregoing methods, the dynamic key generation method can also be executed by the wireless sensor device 1 and the data consumer 4, or executed by the first-tier server 3 and the data consumer 4, and the embodiment of this case is not limited.

為了方便說明,以下實施例係以無線感測裝置1進行感測資料的加密和伺服器3進行感測資料的解密作為例子來說明,但並非限制本發明實施例可以應用的方式,於所述技術領域具有通常知識者可以根據以下實施例應用於不同的無線通信網路環境和不同的資料存取流程中。 For the convenience of description, the following embodiments take the wireless sensing device 1 to encrypt the sensing data and the server 3 to decrypt the sensing data as examples, but it does not limit the ways in which the embodiments of the present invention can be applied. Those with ordinary knowledge in the technical field can apply the following embodiments to different wireless communication network environments and different data access procedures.

動態金鑰產生方法如第2圖所示,於步驟S101中,無線感測裝置1於每次傳輸加密資料時,自第一金鑰陣列Ka中取得多個通訊金鑰其中之一,並以取得的通訊金鑰進行資料加密。換言之,無線感測裝置1在每次傳輸欲加密的感測資料時,會從第一金鑰陣列Ka取得一個通訊金鑰,並以當次取得的通訊金鑰加密感測資料。當無線感測裝置1再傳輸下一筆感測資料時,便會再從第一金鑰陣列Ka取得另一個通訊金鑰來對感 測資料進行加密。於一個實施例中,無線感測裝置1傳輸下一筆感測資料時,從第一金鑰陣列Ka取得的通訊金鑰是順序中的下一個通訊金鑰,但不以此限。此外,於步驟S101中,無線感測裝置1是於傳輸加密資料時,才取得通訊金鑰對資料加密。換言之,本實施例不限制無線感測裝置1一定對每一筆要傳輸的感測資料都進行加密,無線感測裝置1可依據傳輸資料的重要性選擇地進行加密,亦可以對每一筆感測資料都進行加密。為了方便描述,以下實施例僅說明要加密感測資料的情形,但不是限制無線感測裝置1的每一筆感測資料都需要進行加密。 The dynamic key generation method is shown in Figure 2. In step S101, the wireless sensor device 1 obtains one of a plurality of communication keys from the first key array Ka each time when transmitting encrypted data, and uses The obtained communication key is used for data encryption. In other words, each time the wireless sensor device 1 transmits the sensing data to be encrypted, it obtains a communication key from the first key array Ka, and encrypts the sensing data with the communication key obtained at that time. When the wireless sensing device 1 transmits the next sensing data, it will obtain another communication key from the first key array Ka to compare the sensing data. The test data is encrypted. In one embodiment, when the wireless sensing device 1 transmits the next sensing data, the communication key obtained from the first key array Ka is the next communication key in the sequence, but it is not limited thereto. In addition, in step S101, the wireless sensor device 1 obtains the communication key to encrypt the data when the encrypted data is transmitted. In other words, this embodiment does not restrict the wireless sensor device 1 to encrypt every piece of sensing data to be transmitted. The wireless sensor device 1 can selectively encrypt each piece of sensing data according to the importance of the transmitted data, or it can also perform the encryption on every piece of sensing data. The data is encrypted. For the convenience of description, the following embodiments only describe the situation where the sensing data is to be encrypted, but it does not limit that every sensing data of the wireless sensing device 1 needs to be encrypted.

於一個實施例中,第一金鑰陣列Ka可以列表(Table)的方式儲存於無線感測裝置1中。在更安全的考量下,第一金鑰陣列Ka不以列表的方式儲存於無線感測裝置1中,而是於無線感測裝置1中以軟體或其他合適的方式實現。以軟體為例來說,第一金鑰陣列Ka是對應於第一函式。無線感測裝置1於每次要傳輸加密資料時,軟體便會執行第一函式,使第一函式產生一個金鑰數列作為通訊金鑰。本實施例不以使用軟體的方式為達到資料安全的限制。 In one embodiment, the first key array Ka may be stored in the wireless sensor device 1 in a table. In consideration of more security, the first key array Ka is not stored in the wireless sensing device 1 in a list, but is implemented in the wireless sensing device 1 by software or other suitable methods. Taking software as an example, the first key array Ka corresponds to the first function. Each time the wireless sensor device 1 wants to transmit encrypted data, the software will execute the first function so that the first function generates a key sequence as the communication key. In this embodiment, software is not used to limit data security.

金鑰數列的長度可以設定與感測資料的最大有效載荷(payload)相同,使得金鑰數列加密不同長度的感測資料後,加密後的感測資料長度皆相同。例如當感測資料的最大有效載荷是12位元組(byte)時,則第一函式產生的金鑰數列長度為12bytes。當有些感測資料的有效載荷不到12bytes時,感測資料的有效載荷中會被補入位元,讓感測資料變成12bytes後再以12bytes的金鑰數列進行加密。於另一個例子中,當無線感測裝置1傳輸的感測資料都只有9bytes時,亦可以設定第一函式每次產生的金鑰數列為9bytes,或是產生12bytes的金鑰數列後再從中取出9bytes作為通訊金鑰。 The length of the key array can be set to be the same as the maximum payload of the sensing data, so that after the key array encrypts sensing data of different lengths, the encrypted sensing data have the same length. For example, when the maximum payload of the sensing data is 12 bytes, the length of the key sequence generated by the first function is 12 bytes. When the payload of some sensed data is less than 12bytes, bits will be added to the payload of the sensed data, so that the sensed data becomes 12bytes and then encrypted with a 12bytes key sequence. In another example, when the sensing data transmitted by the wireless sensor device 1 is only 9 bytes, it is also possible to set the key array generated by the first function to 9 bytes each time, or to generate a 12-byte key array and then use it. Take out 9bytes as the communication key.

於其他實施例中,當無線感測裝置1限制於處理器的運算效能、記憶體大小等問題時,執行第一函式每次產生的金鑰數列長度為4 bytes。為了產生12bytes的通訊金鑰,無線感測裝置1會產生多個4bytes的金鑰數列,並將金鑰數列串接起來成為12bytes的通訊金鑰。又例如當第一函式每次產生的金鑰數列長度為8bytes時,為了產生12bytes的通訊金鑰,無線感測裝置1會產生多個8bytes的金鑰數列,並將金鑰數列串接起來後,取其中的12bytes作為通訊金鑰。為了方便說明,第一金鑰陣列Ka中第n個通訊金鑰,將以(Ka,n)表示,第一金鑰陣列Ka中第n+1個通訊金鑰,將以(Ka,n+1)表示。換言之,(Ka,n)、(Ka,n+1)、...、(Ka,n+i)等通訊金鑰可以是第一函式直接產生的金鑰數列、金鑰數列取部分位元組組成、多個金鑰數列串接後組成,或多個金鑰數列串接後取部分位元組組成,實施例不予限制。再者,第一金鑰陣列Ka中具有的通訊金鑰數量亦不受到限制,亦即本實施例不限制無線感測裝置1執行第一函式的次數。如此一來,可以避免限制通訊金鑰數量時,使用完所有通訊金鑰後,會再依照相同順序重複使用通訊金鑰的狀況,進而更降低加密資料被監聽竊取後,加密資料被破解讀取的可能性。 In other embodiments, when the wireless sensor device 1 is limited by the computing performance of the processor, the size of the memory, etc., the length of the key sequence generated each time the first function is executed is 4 bytes. In order to generate a 12-byte communication key, the wireless sensor device 1 generates multiple 4-byte key arrays, and concatenates the key arrays to form a 12-byte communication key. For another example, when the length of the key sequence generated by the first function each time is 8 bytes, in order to generate a 12-byte communication key, the wireless sensor device 1 will generate multiple 8-byte key sequences and concatenate the key sequences. After that, take 12 bytes of it as the communication key. For the convenience of explanation, the nth communication key in the first key array Ka will be represented by (Ka,n), and the n+1th communication key in the first key array Ka will be represented by (Ka,n+ 1) Representation. In other words, (Ka,n), (Ka,n+1),..., (Ka,n+i) and other communication keys can be the key sequence directly generated by the first function, and the key sequence takes some bits. Tuple composition, multiple key arrays connected in series, or multiple key arrays connected in series with partial bytes, the embodiment is not limited. Furthermore, the number of communication keys in the first key array Ka is also not limited, that is, the present embodiment does not limit the number of times the wireless sensor device 1 executes the first function. In this way, it is possible to avoid the situation that when the number of communication keys is limited, after all the communication keys are used, the communication keys will be reused in the same order, which further reduces the encrypted data after being intercepted and stolen, and the encrypted data is cracked and read. Possibility.

當無線感測裝置1每次要傳輸加密的感測資料,而從第一金鑰陣列Ka取得通訊金鑰時,每次取出的通訊金鑰不限制相同或不同。在讓資料安全性更高的考量下,可以讓每次取得的通訊金鑰都不同。由於無線感測裝置1產生的感測資料可能與前後幾筆感測資料相同或相近,因此當每一筆感測資料都以不同的通訊金鑰來進行加密時,加密後的感測資料將會與前後幾筆加密後的感測資料有差異,進而避免重複傳遞相同的資料內容,容易被監聽解讀的風險。 When the wireless sensing device 1 transmits encrypted sensing data each time and obtains the communication key from the first key array Ka, the communication key taken out each time is not restricted to be the same or different. In consideration of making the data more secure, the communication key obtained each time can be different. Since the sensing data generated by the wireless sensing device 1 may be the same or similar to the previous and subsequent sensing data, when each sensing data is encrypted with a different communication key, the encrypted sensing data will be It is different from the encrypted sensing data before and after, so as to avoid the risk of repeated transmission of the same data content, which is easy to be monitored and interpreted.

當伺服器3在接收到無線感測裝置1的感測資料時,伺服器3會以與無線感測裝置1技術匹配的動態金鑰產生方式,產生可以解密感測資料的通訊金鑰,進而解密感測資料,具體的說明將於後文敘述。 When the server 3 receives the sensing data of the wireless sensing device 1, the server 3 will generate a communication key that can decrypt the sensing data in a dynamic key generation method that matches the technology of the wireless sensing device 1, and then Decrypt the sensing data, the specific instructions will be described later.

於步驟S103中,無線感測裝置1隨機地產生生成訊息。當無線感測裝置1使用第一金鑰陣列Ka一段時間後,無線感測裝置1會開 始執行替換第一金鑰陣列Ka的程序。無線感測裝置1觸發替換第一金鑰陣列Ka的機制,例如定期的在固定的時間點進行替換,或依照軟體執行順序進行更換,或由其他機制觸發軟體進行更換,本實施例不予限制。換言之,當無線感測裝置1要替換第一金鑰陣列Ka時,無線感測裝置1會隨機地產生生成訊息,並預備將生成訊息傳送給伺服器3,讓伺服器3進入準備替換第一金鑰陣列Ka的程序。於一個實施例中,生成訊息的有效載荷位元組數與感測資料的有效載荷位元組數不同,據以讓伺服器3判斷收到的訊息非感測資料,而是用來告知準備替換第一金鑰陣列Ka的生成訊息。以實例來說,當無線感測裝置1每次傳輸加密後的感測資料是12bytes時,生成訊息的有效載荷位元組數可以是11bytes、10bytes、90bits或其他數量,本實施例不予限制。 In step S103, the wireless sensor device 1 randomly generates a message. When the wireless sensing device 1 uses the first key array Ka for a period of time, the wireless sensing device 1 will turn on The process of replacing the first key array Ka is started. The wireless sensing device 1 triggers the mechanism for replacing the first key array Ka, such as periodically replacing at a fixed time point, or replacing according to the software execution sequence, or triggering software replacement by other mechanisms, which is not limited in this embodiment . In other words, when the wireless sensor device 1 wants to replace the first key array Ka, the wireless sensor device 1 randomly generates a generated message, and prepares to send the generated message to the server 3, so that the server 3 enters and prepares to replace the first key array Ka. The procedure of the key array Ka. In one embodiment, the number of payload bytes of the generated message is different from the number of payload bytes of the sensed data, so that the server 3 can determine that the received message is not sensed data, but is used to inform preparation Replace the generated message of the first key array Ka. For example, when the encrypted sensing data transmitted by the wireless sensor device 1 is 12 bytes each time, the number of payload bytes of the generated message can be 11 bytes, 10 bytes, 90 bits or other numbers, which is not limited in this embodiment. .

此外,生成訊息中包含了指示第二金鑰陣列的訊息seedb及第一驗證訊息Va。指示第二金鑰陣列的訊息seedb是隨機地產生,而第一驗證訊息Va不限制是否隨機產生。於步驟S105中,無線感測裝置1自第一金鑰陣列Ka中取得另一個通訊金鑰,並以取得的通訊金鑰加密生成訊息。於一個實施例中,當無線感測裝置1產生生成訊息之前,無線感測裝置1傳送的最後一筆感測資料係以通訊金鑰(Ka,n+i)進行加密時,無線感測裝置1便可以第一金鑰陣列Ka中的下一個通訊金鑰(Ka,n+i+1)對生成訊息進行加密。於一個實施例中,無線感測裝置1係取通訊金鑰(Ka,n+i+1)的部分位元組為生成訊息進行加密.但不以此為限。 In addition, the generated message includes the message seed b indicating the second key array and the first verification message Va. The message seed b indicating the second key array is generated randomly, and the first verification message Va does not limit whether it is generated randomly. In step S105, the wireless sensor device 1 obtains another communication key from the first key array Ka, and encrypts the obtained communication key to generate a message. In one embodiment, before the wireless sensor device 1 generates a message, the last piece of sensing data transmitted by the wireless sensor device 1 is encrypted with the communication key (Ka, n+i), the wireless sensor device 1 Then, the next communication key (Ka, n+i+1) in the first key array Ka can be used to encrypt the generated message. In one embodiment, the wireless sensing device 1 takes part of the bytes of the communication key (Ka, n+i+1) to generate the message for encryption. But not limited to this.

於步驟S107中,發送已加密的生成訊息並要求第二驗證訊息Vb。換言之,生成訊息被包含於一個資料封包中後發送,且包含生成訊息的資料封包更要求伺服器3回覆訊息。於一個實施例中,包含生成訊息的資料封包在表頭(Header)有部分的位元(bit)可令伺服器3依據此位元判斷要回傳訊息給無線感測裝置1。因此,當伺服器3接收到包含生成訊息的資料封包後,便先驗證生成訊息是否正確,並於生成訊息驗證正確 後,回傳包含有第二驗證訊息Vb的資料封包給無線感測裝置1。 In step S107, the encrypted generated message is sent and the second verification message Vb is requested. In other words, the generated message is sent after being included in a data packet, and the data packet containing the generated message further requires the server 3 to reply to the message. In one embodiment, the bit in the header of the data packet containing the generated message can enable the server 3 to determine that the message is to be returned to the wireless sensor device 1 based on this bit. Therefore, when the server 3 receives the data packet containing the generated message, it first verifies whether the generated message is correct, and then verifies that the generated message is correct Then, the data packet containing the second verification message Vb is returned to the wireless sensor device 1.

於步驟S109中,無線感測裝置1接收到包含有第二驗證訊息Vb的資料封包後,無線感測裝置1比對第二驗證訊息Vb,判斷第二驗證訊息Vb是否正確。於一個實施例中,第一驗證訊息Va和第二驗證訊息Vb例如是儲存於無線感測裝置1和伺服器3中的固定內容。換言之,無線感測裝置1會將隨機產生用以指示第二金鑰陣列的訊息seedb和固定內容的第一驗證訊息Va串接作為生成訊息,並加密生成訊息後傳送給伺服器3,讓伺服器3依據生成訊息中是否具有第一驗證訊息Va的固定內容,來判斷收到的訊息是否真的來自於無線感測裝置1,亦即判斷生成訊息是否正確。當無線感測裝置1接收到伺服器3回覆的資料封包時,無線感測裝置1亦根據資料封包中的內容是否有預設好的第二驗證訊息Vb,判斷第二驗證訊息Vb是否正確,亦即判斷資料封包是否真的來自於伺服器3。 In step S109, after the wireless sensor device 1 receives the data packet containing the second verification message Vb, the wireless sensor device 1 compares the second verification message Vb to determine whether the second verification message Vb is correct. In one embodiment, the first verification message Va and the second verification message Vb are, for example, fixed content stored in the wireless sensor device 1 and the server 3. In other words, the wireless sensor device 1 connects the message seed b randomly generated to indicate the second key array and the first verification message Va with fixed content as the generated message, encrypts the generated message, and sends it to the server 3 so that The server 3 determines whether the received message really comes from the wireless sensor device 1 according to whether the generated message has the fixed content of the first verification message Va, that is, determines whether the generated message is correct. When the wireless sensing device 1 receives the data packet replies from the server 3, the wireless sensing device 1 also determines whether the second verification message Vb is correct according to whether the content in the data packet has a preset second verification message Vb. That is, it is judged whether the data packet really comes from the server 3.

此外,生成訊息中可另包含檢驗訊息,讓無線感測裝置1依據檢驗訊息,判斷生成訊息是否正確。檢驗訊息例如隱含於指示第二金鑰陣列的訊息seedb和第一驗證訊息Va的格式之中,或另外設定生成訊息部分的位元組作為檢驗訊息的位置,本實施例不予限制。 In addition, the generated message may additionally include a test message, so that the wireless sensor device 1 can determine whether the generated message is correct according to the test message. The verification message is, for example, implicit in the format of the message seed b indicating the second key array and the first verification message Va, or the byte of the generated message part is set as the location of the verification message, which is not limited in this embodiment.

於另一個實施例中,第二驗證訊息Vb係依據第一驗證訊息Va產生。換句話說,當第一驗證訊息Va是隨機產生時,伺服器3驗證生成訊息正確後,便將第一驗證訊息Va從生成訊息中取出作為第二驗證訊息Vb,並回傳給無線感測裝置1。當無線感測裝置1從伺服器3接收到包含有第二驗證訊息Vb的訊息,並驗證第二驗證訊息Vb與第一驗證訊息Va相同時,表示第二驗證訊息Vb比對正確。 In another embodiment, the second verification message Vb is generated based on the first verification message Va. In other words, when the first verification message Va is randomly generated, after verifying that the generated message is correct, the server 3 takes the first verification message Va from the generated message as the second verification message Vb and sends it back to the wireless sensor. Device 1. When the wireless sensor device 1 receives a message containing the second verification message Vb from the server 3 and verifies that the second verification message Vb is the same as the first verification message Va, it means that the second verification message Vb is correctly compared.

於其他實施例中,第二驗證訊息亦可以是第一驗證訊息Va的部分位元組。也就是說,伺服器3係從第一驗證訊息Va取出部分位元組當作第二驗證訊息Vb,回傳給無線感測裝置1來進行比對。第二驗證訊息Vb除了用以讓無線感測裝置1確認收到的訊息是從安全的伺服器3中發 送,還可以讓無線感測裝置1確認伺服器3已經收到生成訊息。於所屬技術領域具有通常知識者可以依照實際的需求,設計運用無線感測裝置1確認訊息來源正確的方法,本實施例不予限制。 In other embodiments, the second verification message may also be a partial byte of the first verification message Va. In other words, the server 3 takes some bytes from the first verification message Va as the second verification message Vb, and sends it back to the wireless sensor device 1 for comparison. The second verification message Vb is used to allow the wireless sensor device 1 to confirm that the received message is sent from the secure server 3. It can also allow the wireless sensing device 1 to confirm that the server 3 has received the generated message. Those with ordinary knowledge in the relevant technical field can design a method for using the wireless sensor device 1 to confirm the correct source of the message according to actual needs, which is not limited in this embodiment.

當第二驗證訊息Vb比對正確時,於步驟S111中,無線感測裝置1以第二金鑰陣列Kb取代第一金鑰陣列Ka,據以於之後一段時間內每次傳輸加密資料時,無線感測裝置1改自第二金鑰陣列Kb中取得通訊金鑰來進行資料加密,亦即使用第二金鑰陣列Kb中的通訊金鑰來對感測資料加密,於所屬技術領域具有通常知識者可以依據前述內容實施,本實施例不在重複敘述。 When the second verification message Vb is correctly compared, in step S111, the wireless sensor device 1 replaces the first key array Ka with the second key array Kb, so that every time encrypted data is transmitted in the subsequent period of time, the wireless sensor device 1 replaces the first key array Ka with the second key array Kb. The wireless sensor device 1 obtains the communication key from the second key array Kb to encrypt the data, that is, uses the communication key in the second key array Kb to encrypt the sensing data, which is common in the technical field. The knowledgeable person can implement it based on the foregoing content, and the description will not be repeated in this embodiment.

於前述實施例中,隨機產生的訊息seedb除了讓伺服器3據以推導出第二金鑰陣列Kb以外,無線感測裝置1亦依據隨機產生的訊息seedb,產生第二金鑰陣列Kb。於一個例子中,無線感測裝置1具有陣列生成函式,陣列生成函式根據隨機產生的訊息seedb,產生關連於第二金鑰陣列Kb的第二函式。也就是說,當無線感測裝置1以第二金鑰陣列Kb取代第一金鑰陣列Ka後,之後每次無線感測裝置1要傳輸加密資料時,會由軟體執行第二函式,使第二函式產生金鑰數列來作為加密感測資料的通訊金鑰。同樣地,當伺服器3接收到指示第二金鑰陣列的訊息seedb後,伺服器3亦可利用指示第二金鑰陣列的訊息seedb,產生第二金鑰陣列Kb,並改以第二金鑰陣列Kb中的通訊金鑰來對收到的訊息進行解密。 In the foregoing embodiments, randomly generated seed b in addition to the message server 3 according to derive a second key array Kb outside, the wireless sensing device 1 also based on randomly generated seed b message, generating a second key array Kb . In one example, the wireless sensor device 1 has an array generation function, and the array generation function generates a second function related to the second key array Kb according to a randomly generated message seed b. That is to say, when the wireless sensor device 1 replaces the first key array Ka with the second key array Kb, then every time the wireless sensor device 1 wants to transmit encrypted data, the software will execute the second function so that The second function generates a key sequence as the communication key for encrypting the sensing data. Similarly, when the server 3 receives the message seed b indicating the second key array, the server 3 can also use the message seed b indicating the second key array to generate the second key array Kb, and change it to the first key array Kb. The communication key in the two key array Kb is used to decrypt the received message.

實務上,當無線感測裝置1於步驟S107沒有收到伺服器3回覆訊息時,無線感測裝置1會再發送一次已加密的生成訊息。於一個實施例中,無線感測裝置1會再重複執行步驟S105,並以另一個通訊金鑰重新加密生成訊息。具體來說,當無線感測裝置1以通訊金鑰(Ka,n+i+1)對生成訊息進行加密,且發送加密的生成訊息後仍未收到伺服器3回覆,則無線感測裝置1再以順序中的下一個通訊金鑰(Ka,n+i+2)對生成訊息進行加密,並發送重新加密的生成訊息,並要求伺服器3回覆。於所屬技 術領域具有通常知識者可以自行設計重新發送生成訊息所要使用的通訊金鑰,本實施例不限制要用順序中的下一個通訊金鑰來進行加密。 In practice, when the wireless sensor device 1 does not receive the reply message from the server 3 in step S107, the wireless sensor device 1 sends the encrypted generated message again. In one embodiment, the wireless sensor device 1 repeats step S105 again, and re-encrypts the message with another communication key to generate a message. Specifically, when the wireless sensor device 1 encrypts the generated message with the communication key (Ka, n+i+1), and after sending the encrypted generated message, it still does not receive a reply from the server 3, the wireless sensor device 1 Then encrypt the generated message with the next communication key (Ka, n+i+2) in the sequence, send the re-encrypted generated message, and request the server 3 to reply. Yu Owned Technology Those with ordinary knowledge in the technical field can design by themselves the communication key used to re-send the generated message. This embodiment does not limit the use of the next communication key in the sequence for encryption.

此外,在安全性的考量下,伺服器3回覆第二驗證訊息Vb時,伺服器3可以選擇對第二驗證訊息Vb進行加密。伺服器3加密第二驗證訊息Vb的方式例如從第一金鑰陣列Ka取得一個通訊金鑰,並以取得的通訊金鑰加密第二驗證訊息Vb。具體來說,當伺服器3收到的生成訊息是以通訊金鑰(Ka,n+i+1)對生成訊息進行加密,則伺服器3可以順序中下一個通訊金鑰(Ka,n+i+2)對第二驗證訊息Vb加密。當伺服器3收到的生成訊息是以通訊金鑰(Ka,n+i+2)對生成訊息進行加密,則伺服器3以順序中下一個通訊金鑰(Ka,n+i+3)對第二驗證訊息Vb加密,但不以此為限。換言之,當伺服器3選擇對第二驗證訊息Vb進行加密,而無線感測裝置1接收到包含有第二驗證訊息Vb的資料封包時,無線感測裝置1會進一步具有解密第二驗證訊息Vb的步驟。 In addition, in consideration of security, when the server 3 replies to the second verification message Vb, the server 3 may choose to encrypt the second verification message Vb. The server 3 encrypts the second verification message Vb, for example, obtains a communication key from the first key array Ka, and encrypts the second verification message Vb with the obtained communication key. Specifically, when the generated message received by the server 3 is encrypted with the communication key (Ka,n+i+1), then the server 3 can sequence the next communication key (Ka,n+i+1). i+2) Encrypt the second verification message Vb. When the generated message received by the server 3 is encrypted with the communication key (Ka,n+i+2), the server 3 uses the next communication key (Ka,n+i+3) in the sequence The second verification message Vb is encrypted, but not limited to this. In other words, when the server 3 chooses to encrypt the second verification message Vb, and the wireless sensor device 1 receives the data packet containing the second verification message Vb, the wireless sensor device 1 will further have the ability to decrypt the second verification message Vb A step of.

請參照第1圖及第3圖,第3圖係為根據本發明另一實施例之無線通信的動態金鑰產生方法的步驟流程圖。如圖所示,於步驟S301中,無線感測裝置1於每次欲傳輸加密的感測資料時,會自第一金鑰陣列Ka中取得多個通訊金鑰其中之一,並以取得的通訊金鑰進行感測資料加密。當無線感測裝置1使用第一金鑰陣列Ka加密感測資料一段時間後,無線感測裝置1開始執行替換第一金鑰陣列Ka的程序。因此,於步驟S303中,無線感測裝置1隨機地產生生成訊息,生成訊息包含指示第二金鑰陣列Kb的訊息和第一驗證訊息Va。於步驟S305中,無線感測裝置1自第一金鑰陣列Ka中取得通訊金鑰,並以取得的通訊金鑰加密生成訊息。於步驟S307中,無線感測裝置1發送已加密的生成訊息,並要求第二驗證訊息Vb。當伺服器3接收到包含生成訊息的資料封包,並驗證生成訊息後,回傳包含有第二驗證訊息Vb的資料封包給無線感測裝置1。於步驟S309中,無線感測裝置1接收第二驗證訊息Vb,並比對判斷第二驗證訊息Vb是否正確。 Please refer to FIG. 1 and FIG. 3. FIG. 3 is a flowchart of a method for generating a dynamic key for wireless communication according to another embodiment of the present invention. As shown in the figure, in step S301, each time the wireless sensor device 1 wants to transmit encrypted sensing data, it obtains one of a plurality of communication keys from the first key array Ka, and obtains The communication key encrypts the sensing data. After the wireless sensor device 1 uses the first key array Ka to encrypt the sensing data for a period of time, the wireless sensor device 1 starts to perform the procedure of replacing the first key array Ka. Therefore, in step S303, the wireless sensor device 1 randomly generates a generated message, and the generated message includes a message indicating the second key array Kb and the first verification message Va. In step S305, the wireless sensor device 1 obtains a communication key from the first key array Ka, and encrypts the obtained communication key to generate a message. In step S307, the wireless sensing device 1 sends the encrypted generated message and requests the second verification message Vb. When the server 3 receives the data packet containing the generated message and verifies the generated message, it returns the data packet containing the second verification message Vb to the wireless sensor device 1. In step S309, the wireless sensor device 1 receives the second verification message Vb, and compares it to determine whether the second verification message Vb is correct.

於第3圖的實施例中,步驟S301到步驟S309與第1圖實施例大致上相同,且於所屬技術領域具有通常知識者可以參照第1圖的實施例變化運用到步驟S301至步驟S309,不再重複贅述。接下來,於步驟S311中,當第二驗證訊息Vb比對正確時,無線感測裝置1產生待命訊息,並自第一金鑰陣列Ka或第二金鑰陣列Kb其中之一中取得通訊金鑰,加密待命訊息。 In the embodiment of Fig. 3, steps S301 to S309 are substantially the same as those of the embodiment of Fig. 1, and those with ordinary knowledge in the relevant technical field can refer to the embodiment of Fig. 1 and apply them to steps S301 to S309. Do not repeat it again. Next, in step S311, when the second verification message Vb is correctly compared, the wireless sensor device 1 generates a standby message, and obtains communication funds from one of the first key array Ka or the second key array Kb Key to encrypt the standby message.

待命訊息可以是固定的資料內容,或自第一金鑰陣列Ka中的一個通訊金鑰取得,或是自第二金鑰陣列Kb中的一個通訊金鑰取得,本實施例不予限制。具體來說,當待命訊息是固定的資料內容時,無線感測裝置1可以設定自第一金鑰陣列Ka或第二金鑰陣列Kb其中之一中取得通訊金鑰來加密待命訊息。當待命訊息是自第一金鑰陣列Ka中的一個通訊金鑰取得時,無線感測裝置1可以自第二金鑰陣列Kb中取得通訊金鑰來加密待命訊息。當待命訊息是自第二金鑰陣列Kb中的一個通訊金鑰取得時,無線感測裝置1可以自第一金鑰陣列Ka中取得通訊金鑰來加密待命訊息。本實施例不限制待命訊息的訊息內容及加密待命訊息使用的通訊金鑰。 The standby message can be fixed data content, or obtained from a communication key in the first key array Ka, or obtained from a communication key in the second key array Kb, which is not limited in this embodiment. Specifically, when the standby message is a fixed data content, the wireless sensor device 1 can be configured to obtain a communication key from one of the first key array Ka or the second key array Kb to encrypt the standby message. When the standby message is obtained from a communication key in the first key array Ka, the wireless sensor device 1 can obtain the communication key from the second key array Kb to encrypt the standby message. When the standby message is obtained from a communication key in the second key array Kb, the wireless sensor device 1 can obtain the communication key from the first key array Ka to encrypt the standby message. This embodiment does not limit the message content of the standby message and the communication key used to encrypt the standby message.

接著,於步驟S313中,無線感測裝置1將已加密的待命訊息發送出去,並要求回應訊息。換言之,待命訊息被包含於一個資料封包中後發送,且包含待命訊息的資料封包要求伺服器3回覆訊息。於一個實施例中,具有待命訊息的資料封包具有用以要求伺服器3回傳訊息的位元,讓伺服器3在接收到資料封包時,依據此位元判斷要回傳回應訊息給無線感測裝置1。於一個實施例中,待命訊息的位元組數不同於生成訊息的位元組數及感測資料有效載荷的位元組數。伺服器3可以根據收到資料封包的位元組數,判斷收到的資料封包是關於待命訊息。換言之,伺服器3可以根據資料封包的類型,判斷應該回傳第二驗證訊息Vb或回應訊息給無線感測裝置1。 Then, in step S313, the wireless sensor device 1 sends the encrypted standby message and requests a response message. In other words, the standby message is sent after being included in a data packet, and the data packet containing the standby message requires the server 3 to reply to the message. In one embodiment, the data packet with the standby message has a bit used to request the server 3 to return a message, so that when the server 3 receives the data packet, it determines that it should return a response message to the wireless sensor based on this bit.测装置1。 Measuring device 1. In one embodiment, the number of bytes of the standby message is different from the number of bytes of the generated message and the number of bytes of the payload of the sensing data. The server 3 can determine that the received data packet is about a standby message based on the number of bytes of the received data packet. In other words, the server 3 can determine whether to return the second verification message Vb or the response message to the wireless sensor device 1 according to the type of the data packet.

當無線感測裝置1接收到伺服器3回傳的回應訊息時,於步驟S315中,無線感測裝置1比對回應訊息。當回應訊息比對正確時,於步驟S317中,無線感測裝置1以第二金鑰陣列Kb取代第一金鑰陣列Ka,據以於之後一段時間內每次傳輸加密資料時,無線感測裝置1改自第二金鑰陣列Kb中取得通訊金鑰來進行資料加密。 When the wireless sensor device 1 receives the response message returned by the server 3, in step S315, the wireless sensor device 1 compares the response message. When the response message is correctly compared, in step S317, the wireless sensor device 1 replaces the first key array Ka with the second key array Kb, so that every time encrypted data is transmitted within a period of time, the wireless sensor device 1 The device 1 obtains the communication key from the second key array Kb to perform data encryption.

為了更具體說明,以實際的例子來說,當無線感測裝置1於步驟S305中,以通訊金鑰(Ka,n+i+1)加密生成訊息,並於步驟S309中接收到伺服器3回傳的第二驗證訊息Vb,且第二驗證訊息Vb比對正確時,無線感測裝置1於步驟S311中將以自通訊金鑰(Kb,1)中取部分的位元組作為待命訊息,並以第一金鑰陣列Ka順序中的下一個通訊金鑰(Ka,n+i+2)加密待命訊息,發送加密後的待命訊息,以等待伺服器3的回覆。伺服器3回覆的回應訊息可以根據待命訊息使用的通訊金鑰,以同一個或下一個順序的通訊金鑰進行加密,亦即例如以通訊金鑰(Ka,n+i+2)或通訊金鑰(Ka,n+i+3)加密待命訊息。由於通訊金鑰的位元組數與待命訊息和回應訊息的位元組數不同,因此無線感測裝置1和伺服器3可設定僅以通訊金鑰部分的位元組來加密待命訊息和回應訊息。 For more specific description, take a practical example, when the wireless sensor device 1 encrypts a message with the communication key (Ka, n+i+1) in step S305, and receives the message from the server 3 in step S309 When the second verification message Vb is returned, and the second verification message Vb is correctly compared, the wireless sensor device 1 will use a portion of the bytes taken from the communication key (Kb, 1) as the standby message in step S311 , And encrypt the standby message with the next communication key (Ka, n+i+2) in the sequence of the first key array Ka, and send the encrypted standby message to wait for the reply from the server 3. The response message from the server 3 can be encrypted with the same or the next sequence of communication keys according to the communication key used by the standby message, that is, for example, with the communication key (Ka, n+i+2) or communication key The key (Ka, n+i+3) encrypts the standby message. Since the number of bytes of the communication key is different from the number of bytes of the standby message and response message, the wireless sensor device 1 and server 3 can be configured to encrypt the standby message and response only with the bytes of the communication key part message.

當無線感測裝置1發送待命訊息後,未收到伺服器3的回覆時,無線感測裝置1可以再重傳一次加密後的待命訊息給伺服器3,或是重複步驟S311,以第一金鑰陣列Ka順序中的下一個通訊金鑰(Ka,n+i+3)重新加密待命訊息,並發送重新加密的待命訊息要求伺服器3的回覆。此時,當伺服器3接收到以通訊金鑰(Ka,n+i+3)加密的待命訊息時,伺服器3亦可以通訊金鑰(Ka,n+i+3)或通訊金鑰(Ka,n+i+4)加密回應訊息,回覆給無線感測裝置1。 When the wireless sensor device 1 sends the standby message but does not receive a reply from the server 3, the wireless sensor device 1 can retransmit the encrypted standby message to the server 3 again, or repeat step S311 to first The next communication key (Ka, n+i+3) in the key array Ka sequence re-encrypts the standby message, and sends the re-encrypted standby message to request a reply from the server 3. At this time, when the server 3 receives the standby message encrypted with the communication key (Ka, n+i+3), the server 3 can also use the communication key (Ka, n+i+3) or the communication key ( Ka,n+i+4) Encrypt the response message and reply to the wireless sensor device 1.

於另一個例子中,當無線感測裝置1於步驟S305中,以通訊金鑰(Ka,n+i+1)加密生成訊息,並於步驟S309中接收到伺服器3回傳的第二驗證訊息Vb,且第二驗證訊息Vb比對正確時,於步驟S311中 無線感測裝置1將自順序中下一個通訊金鑰(Ka,n+i+2)中取部分的位元組作為待命訊息,並以第二金鑰陣列Kb的第一個通訊金鑰(Kb,1)加密待命訊息,並發送加密的待命訊息來等待伺服器3的回覆。此時,伺服器3回覆的回應訊息可以根據待命訊息使用的通訊金鑰,以同一個或下一個順序的通訊金鑰進行加密,例如使用通訊金鑰(Kb,1)或通訊金鑰(Kb,2)加密回應訊息。 In another example, when the wireless sensor device 1 generates a message encrypted with the communication key (Ka, n+i+1) in step S305, and receives the second verification returned by the server 3 in step S309 Message Vb, and when the second verification message Vb is correctly compared, in step S311 The wireless sensor device 1 takes a portion of the bytes from the next communication key (Ka, n+i+2) in the sequence as a standby message, and uses the first communication key ( Kb, 1) Encrypt the standby message, and send the encrypted standby message to wait for the reply from the server 3. At this time, the response message replies from the server 3 can be encrypted with the same or next communication key according to the communication key used by the standby message, for example, using the communication key (Kb, 1) or the communication key (Kb , 2) Encrypt the response message.

當無線感測裝置1發送待命訊息後,仍未收到伺服器3的回覆時,無線感測裝置1可以再重傳一次加密後的待命訊息給伺服器3,或是重複步驟S311,以第一金鑰陣列Ka順序中的下一個通訊金鑰(Ka,n+i+3)取部分的位元組作為待命訊息,並以同樣的通訊金鑰(Kb,1)重新加密的待命訊息,重新發送加密的待命訊息,據以要求伺服器3的回覆。 When the wireless sensor device 1 sends the standby message but still does not receive a reply from the server 3, the wireless sensor device 1 can retransmit the encrypted standby message to the server 3 again, or repeat step S311, The next communication key (Ka, n+i+3) in the sequence of a key array Ka takes part of the byte as the standby message, and re-encrypts the standby message with the same communication key (Kb, 1), Re-send the encrypted standby message and request a reply from the server 3.

於所屬技術領域具有通常知識者應可理解,當伺服器3回覆的回應訊息有加密時,於步驟S315之前,無線感測裝置1應具有解密回應訊息的步驟,於此不再加以贅述。 Those with ordinary knowledge in the technical field should understand that when the response message from the server 3 is encrypted, the wireless sensor device 1 should have a step of decrypting the response message before step S315, which will not be repeated here.

伺服器3可以根據是否接收到待命訊息,來確認無線感測裝置1已收到第二驗證訊息Vb,亦可根據待命訊息的資料內容,再次確認先前根據生成訊息所推導出的第二金鑰陣列Kb是否正確。而伺服器3回覆的回應訊息內容可以是固定的內容,亦可以是取自於待命訊息的內容,本實施例不予限制。 The server 3 can confirm that the wireless sensor device 1 has received the second verification message Vb according to whether the standby message is received, or according to the data content of the standby message, reconfirm the second key derived from the generated message. Whether the array Kb is correct. The content of the response message replies from the server 3 can be fixed content or can be taken from the content of the standby message, which is not limited in this embodiment.

於一個實施例中,當無線感測裝置1確認回應訊息比對正確後,無線感測裝置1以第二金鑰陣列Kb取代第一金鑰陣列Ka,且以第二金鑰陣列Kb中未使用過的通訊金鑰來加密感測資料,以進行資料傳輸。具體來說,當無線感測裝置1於步驟S311中是自通訊金鑰(Kb,1)中取部分的位元組作為待命訊息時,無線感測裝置1以第二金鑰陣列Kb取代第一金鑰陣列Ka,恢復傳送感測資料時,無線感測裝置1會使用通訊金鑰(Kb,2)加密恢復傳送感測資料後的第一筆資料。當無線感測裝置1於步 驟S311中是自通訊金鑰(Ka,n+i+2)中取部分的位元組作為待命訊息,並以使用通訊金鑰(Kb,1)加密待命訊息時,在無線感測裝置1以第二金鑰陣列Kb取代第一金鑰陣列Ka,恢復傳送感測資料後,無線感測裝置1會使用通訊金鑰(Kb,2)加密恢復傳送感測資料後的第一筆資料。 In one embodiment, after the wireless sensor device 1 confirms that the response message is correctly compared, the wireless sensor device 1 replaces the first key array Ka with the second key array Kb, and replaces the second key array Kb with no data in the second key array Kb. The used communication key is used to encrypt the sensing data for data transmission. Specifically, when the wireless sensor device 1 takes part of the bytes from the communication key (Kb, 1) as the standby message in step S311, the wireless sensor device 1 replaces the second key array Kb with the second key array Kb. A key array Ka. When the sensor data is resumed, the wireless sensor device 1 uses the communication key (Kb, 2) to encrypt the first data after the sensor data is sent. When the wireless sensing device 1 is in step In step S311, some bytes from the communication key (Ka, n+i+2) are taken as the standby message, and the communication key (Kb, 1) is used to encrypt the standby message. Replace the first key array Ka with the second key array Kb. After the sensor data is resumed, the wireless sensor device 1 encrypts and recovers the first data after the sensor data is sent with the communication key (Kb, 2).

接下來說明無線通信的動態金鑰產生方法運用於伺服器3的實施例。請參照第1圖及第4圖,第4圖係為根據本發明再一實施例之無線通信的動態金鑰產生方法的步驟流程圖。如圖所示,於步驟S501中,伺服器3於每次接收到加密的資料封包時,依據資料封包的位元組數,判斷資料封包的類型。由於生成訊息的有效載荷位元組數與感測資料的有效載荷位元組數不同,因此伺服器3可以依據收到的資料封包的位元組數,來判斷資料封包的類型。舉例來說,當伺服器3接收到有效載荷為12bytes的資料封包時,判斷此資料封包為感測資料類型。當伺服器3接收到有效載荷為11bytes的資料封包時,判斷此資料封包為生成訊息類型,但不以此為限。 Next, an embodiment in which the dynamic key generation method of wireless communication is applied to the server 3 will be explained. Please refer to FIG. 1 and FIG. 4. FIG. 4 is a flowchart of a method for generating a dynamic key for wireless communication according to another embodiment of the present invention. As shown in the figure, in step S501, each time the server 3 receives an encrypted data packet, it determines the type of the data packet according to the number of bytes of the data packet. Since the number of payload bytes of the generated message is different from the number of payload bytes of the sensing data, the server 3 can determine the type of the data packet according to the number of bytes of the received data packet. For example, when the server 3 receives a data packet with a payload of 12 bytes, it determines that the data packet is a sensing data type. When the server 3 receives a data packet with a payload of 11 bytes, it determines that the data packet is a generated message type, but it is not limited to this.

於步驟S503中,伺服器3自資料封包對應的當前金鑰陣列中取得多個通訊金鑰其中之一,解密資料封包。由於無線感測裝置1在每次傳輸欲加密的資料時,會從第一金鑰陣列Kc取得一個通訊金鑰,並以當次取得的通訊金鑰加密資料。因此,伺服器3也透過與無線感測裝置1對應的動態金鑰產生方法來解密資料封包。具體來說,伺服器3每次透過基地台2接收到來自無線感測裝置1的加密資料封包時,伺服器3會依據資料封包判斷來源的無線感測裝置1,進而從無線感測裝置1對應的當前金鑰陣列中,取得通訊金鑰來解密資料封包。於一個實施例中,伺服器3可以僅使用通訊金鑰的部分位元組來解密資料封包,本實施例不予限制。為了方便說明,後續描述將以第一金鑰陣列Kc來代替說明伺服器3中的當前金鑰陣列。 In step S503, the server 3 obtains one of a plurality of communication keys from the current key array corresponding to the data packet, and decrypts the data packet. Because the wireless sensor device 1 obtains a communication key from the first key array Kc every time it transmits data to be encrypted, and encrypts the data with the communication key obtained at that time. Therefore, the server 3 also decrypts the data packet through the dynamic key generation method corresponding to the wireless sensor device 1. Specifically, every time the server 3 receives an encrypted data packet from the wireless sensor device 1 through the base station 2, the server 3 will determine the source of the wireless sensor device 1 according to the data packet, and then obtain the data from the wireless sensor device 1. In the corresponding current key array, obtain the communication key to decrypt the data packet. In one embodiment, the server 3 may only use part of the bytes of the communication key to decrypt the data packet, which is not limited in this embodiment. For the convenience of description, the following description will replace the current key array in the server 3 with the first key array Kc.

於一個實施例中,伺服器3根據資料封包的序列號 (Sequence Number),來推測資料封包使用的通訊金鑰。當第一金鑰陣列Kc例如以列表的方式儲存於伺服器3中時,伺服器3可以依據資料封包的序列號,自第一金鑰陣列Kc的列表中查找資料封包的通訊金鑰。在另一個實施例中,第一金鑰陣列Kc不以列表的方式儲存於伺服器3中,而是以軟體或其他合適的方式實現。以軟體為例來說,於每次接收到加密資料時,伺服器3的軟體會執行第一函式,依據第一函式產生的金鑰數列作為通訊金鑰,來解密資料封包。因此,伺服器3將比較上一次收到資料封包的序列號和這次收到資料封包的序列號,據以選擇執行第一函式的次數,並以執行第一函式最後所產生的金鑰數列作為通訊金鑰。以實際例子來說,當伺服器3上一次收到資料封包的序列號為5,而此次收到資料封包的序列號為6,伺服器3比較兩個序列號後,依據序列號的差值1,執行一次第一函式,據以取得此次資料封包的通訊金鑰。又例如,伺服器3上一次收到資料封包的序列號為5,而此次收到資料封包的序列號為8,伺服器3比較兩次的序列號。依據序列號的差值3,執行三次第一函式,並以第三次執行第一函式所取得的金鑰數列作為解密此次資料封包的通訊金鑰。此軟體執行第一函式的實現方式及序列號的數值僅為說明之用,並非限制具體實施的方式及本發明涵蓋的權利範圍。 In one embodiment, the server 3 according to the serial number of the data packet (Sequence Number) to guess the communication key used by the data packet. When the first key array Kc is stored in the server 3 in the form of a list, for example, the server 3 can search for the communication key of the data packet from the list of the first key array Kc according to the serial number of the data packet. In another embodiment, the first key array Kc is not stored in the server 3 in the form of a list, but is implemented in software or other suitable methods. Taking software as an example, every time it receives encrypted data, the software of the server 3 will execute the first function, and use the key sequence generated by the first function as the communication key to decrypt the data packet. Therefore, the server 3 compares the serial number of the data packet received last time with the serial number of the data packet received this time, and selects the number of times to execute the first function based on the key generated at the end of the execution of the first function. The sequence is used as the communication key. Taking a practical example, when the serial number of the data packet received by the server 3 last time is 5, and the serial number of the data packet received this time is 6, after the server 3 compares the two serial numbers, it is based on the difference between the serial numbers. Value 1, execute the first function once to obtain the communication key of this data packet. For another example, the last time the server 3 received a data packet with a serial number of 5, and the data packet received this time with a serial number of 8, the server 3 compares the serial numbers twice. According to the difference 3 of the serial number, execute the first function three times, and use the key sequence obtained by executing the first function the third time as the communication key to decrypt the data packet. The implementation method of the first function executed by this software and the numerical value of the serial number are for illustrative purposes only, and do not limit the specific implementation method and the scope of rights covered by the present invention.

在某些情況下,伺服器3會限制於處理器的運算效能、記憶體大小等問題,因此在執行第一函式時,所產生的金鑰數列長度受到限制。例如伺服器3每次執行第一函式只能產生4bytes的金鑰數列。為了取得長度更長例如12bytes的通訊金鑰,伺服器3便會多次執行第一函式,並將金鑰數列串接起來作為通訊金鑰,亦即將多個4bytes的金鑰數列串接起來成為12bytes的通訊金鑰。又例如當第一函式每次產生的金鑰數列長度為8bytes時,為了產生12bytes的通訊金鑰,伺服器3會產生多個8bytes的金鑰數列,並將金鑰數列串接起來後,取其中的12bytes作為通訊金鑰。換言之,當伺服器3比較上一次收到資料封包的序列號和這次收到 資料封包的序列號後,選擇第一函式執行的次數亦會依據第一函式能產生的數列長度有關。以伺服器3每次執行第一函式產生4bytes的金鑰數列,而通訊金鑰設定為12bytes的例子來說,伺服器3上一次收到資料封包的序列號為5,而此次收到資料封包的序列號為6。伺服器3將根據序列號的差值1,執行3次第一函式,並串接第1次至第3次產生金鑰數列作為解密此次資料封包的通訊金鑰。又例如,伺服器3上一次收到資料封包的序列號為5,而此次收到資料封包的序列號為8,伺服器3根據序列號的差值3,執行9次第一函式,並串接第7次至第9次產生的金鑰數列作為解密此次資料封包的通訊金鑰。 In some cases, the server 3 is limited by the computing performance of the processor, the size of the memory, and so on. Therefore, when the first function is executed, the length of the key sequence generated is limited. For example, the server 3 can only generate a 4bytes key sequence every time the first function is executed. In order to obtain a communication key with a longer length such as 12 bytes, the server 3 will execute the first function multiple times and concatenate the key sequence as the communication key, that is, concatenate multiple 4bytes of key sequence Become a 12bytes communication key. For another example, when the length of the key sequence generated by the first function is 8 bytes each time, in order to generate a 12-byte communication key, the server 3 will generate multiple 8-byte key sequences and concatenate the key sequence. Take 12 bytes of it as the communication key. In other words, when the server 3 compares the serial number of the data packet received last time with the data packet received this time After the serial number of the data packet, the number of times the first function is selected for execution will also depend on the length of the sequence that the first function can generate. Take the example where server 3 executes the first function to generate a 4bytes key sequence each time, and the communication key is set to 12bytes, the last time server 3 received a data packet with a serial number of 5, and this time it received The serial number of the data packet is 6. The server 3 will execute the first function three times according to the difference of 1 of the serial number, and concatenate the sequence of generated keys from the 1st to the 3rd as the communication key for decrypting the data packet. For another example, the last time the server 3 received a data packet with a serial number of 5, and the data packet received this time with a serial number of 8, the server 3 executes the first function 9 times according to the difference 3 of the serial numbers. And concatenate the key sequence generated from the 7th to 9th time as the communication key for decrypting the data packet.

在實務上,以軟體實現第一金鑰陣列Kc的方式,第一金鑰陣列Kc中可具有的通訊金鑰數量不會受到限制,亦即伺服器3執行第一函式的次數不受到限制。如此一來,可以避免限制通訊金鑰數量時,使用完所有通訊金鑰後,會再依照相同順序重複使用通訊金鑰的狀況,進而更降低加密資料被監聽竊取後,加密資料被破解讀取的可能性。 In practice, by using software to implement the first key array Kc, the number of communication keys that can be in the first key array Kc is not limited, that is, the number of times the server 3 executes the first function is not limited . In this way, it is possible to avoid the situation that when the number of communication keys is limited, after all the communication keys are used, the communication keys will be reused in the same order, which further reduces the encrypted data after being intercepted and stolen, and the encrypted data is cracked and read. Possibility.

當伺服器3已判斷此資料封包為感測資料類型,伺服器3在解密資料封包後,便會儲存解密後的資料內容,並提供給具有對應資料存取權限的資料使用端4存取。當此資料封包為生成訊息類型時,伺服器3在解密資料封包後,將進一步配合無線感測裝置1執行準備替換第一金鑰陣列Kc的程序,故於步驟S505中,伺服器3判斷資料封包解密後的資料內容是否正確。 When the server 3 has determined that the data packet is a sensing data type, the server 3 will store the decrypted data content after decrypting the data packet and provide it to the data user 4 with corresponding data access rights to access. When the data packet is of the message generation type, after decrypting the data packet, the server 3 will further cooperate with the wireless sensor device 1 to execute the procedure of preparing to replace the first key array Kc. Therefore, in step S505, the server 3 determines the data Whether the data content after decryption of the packet is correct.

於一個實施例中,伺服器3中有預設的第一驗證訊息V1,且已設定解密後資料內容中的部分位元組是無線感測裝置1放置第一驗證訊息V1的位置,因此伺服器3可以從預設放置第一驗證訊息V1的該些位元組中讀出待驗證訊息Vc,並比對待驗證訊息Vc與預設的第一驗證訊息V1。根據待驗證訊息Vc和第一驗證訊息V1是否相同,來判斷資料封包解密後的資料內容是否正確。於另一個實施例中,伺服器3可以預設解密 後資料內容的正確格式。當伺服器3解密後資料內容的格式符合預設格式時,判斷資料封包解密後的資料內容正確。於其他實施例中,伺服器3亦可以是預設解密後資料內容中的部分位元組為放置檢驗訊息的位置。伺服器3依據檢驗訊息是否正確,來判斷解密後的資料內容是否正確。 In one embodiment, the server 3 has a preset first verification message V1, and it has been set that part of the bytes in the data content after decryption is the position where the wireless sensor device 1 places the first verification message V1, so the server The device 3 can read the to-be-verified message Vc from the bytes of the preset first verification message V1, and compare the to-be-verified message Vc with the preset first verification message V1. According to whether the to-be-verified message Vc and the first verification message V1 are the same, it is determined whether the data content after the decryption of the data packet is correct. In another embodiment, the server 3 can decrypt by default The correct format of the content of the post data. When the format of the data content after decryption by the server 3 conforms to the preset format, it is determined that the data content after the decryption of the data packet is correct. In other embodiments, the server 3 may also preset part of the bytes in the data content after decryption as the location where the verification message is placed. The server 3 judges whether the decrypted data content is correct according to whether the check message is correct.

當伺服器3判斷接收到的資料封包正確時,表示解密的資料內容中包含無線感測裝置1產生的生成訊息,亦即包含了指示新金鑰陣列的訊息seedd及第一驗證訊息V1,且資料封包要求伺服器3回覆訊息。也就是說,當解密後的資料內容比對正確時,於步驟S507中,伺服器3將發送驗證訊息Vd給無線感測裝置1,以回應無線感測裝置1的要求。於一個實施例中,伺服器3將取出的待驗證訊息Vc作為要回覆給無線感測裝置1的驗證訊息Vd,並將驗證訊息Vd包含於資料封包中回覆給無線感測裝置1。於另一個實施例中,伺服器3可以僅從待驗證訊息Vc中取出部分位元組,來當作驗證訊息Vd回傳給無線感測裝置1。伺服器3使用解密後資料內容中的待驗證訊息Vc來回覆,可以讓無線感測裝置1確認收到的訊息是從安全的伺服器3中發送,且伺服器3已經收到生成訊息。於所屬技術領域具有通常知識者可以依照實際的需求,設計運用伺服器3回覆無線感測裝置1的內容,本實施例不予限制。 When the server 3 determines that the received data packet is correct, it means that the decrypted data content includes the generated message generated by the wireless sensor device 1, that is, the message seed d indicating the new key array and the first verification message V1. And the data packet requires the server 3 to reply to the message. That is, when the decrypted data content is correctly compared, in step S507, the server 3 will send the verification message Vd to the wireless sensor device 1 in response to the request of the wireless sensor device 1. In one embodiment, the server 3 uses the retrieved message Vc to be verified as the verification message Vd to be replied to the wireless sensor device 1, and includes the verification message Vd in a data packet to reply to the wireless sensor device 1. In another embodiment, the server 3 may only take out a part of the bytes from the to-be-verified message Vc and send it back to the wireless sensor device 1 as the verification message Vd. The server 3 uses the to-be-verified message Vc in the decrypted data content to reply, allowing the wireless sensor device 1 to confirm that the received message is sent from the secure server 3, and the server 3 has received the generated message. Those with ordinary knowledge in the relevant technical field can design and use the server 3 to reply to the content of the wireless sensing device 1 according to actual needs, and this embodiment is not limited.

在一個例子中,伺服器3可以從第一金鑰陣列Kc中取得通訊金鑰,並以取得的通訊金鑰對驗證訊息Vd進行加密後,回傳給無線感測裝置1。以實際的例子來說,當伺服器3收到的資料封包是以通訊金鑰(Kc,n+i+1)加密,則伺服器3可以順序中下一個通訊金鑰(Kc,n+i+2)對驗證訊息Vd加密。當伺服器3收到的資料封包是以通訊金鑰(Kc,n+i+2)加密,則伺服器3以順序中下一個通訊金鑰(Kc,n+i+3)對驗證訊息Vd加密,但不以此為限。在實務上,可以因通訊金鑰與驗證訊息Vd的位元組數不同,而取通訊金鑰部分的位元組來對驗證訊息Vd加密,本實施例不予限制。 In an example, the server 3 can obtain the communication key from the first key array Kc, encrypt the verification message Vd with the obtained communication key, and then send it back to the wireless sensor device 1. In a practical example, when the data packet received by the server 3 is encrypted with the communication key (Kc,n+i+1), then the server 3 can sequence the next communication key (Kc,n+i+1). +2) Encrypt the verification message Vd. When the data packet received by the server 3 is encrypted with the communication key (Kc,n+i+2), the server 3 uses the next communication key (Kc,n+i+3) in the sequence to verify the message Vd Encryption, but not limited to this. In practice, because the number of bytes of the communication key and the verification message Vd are different, the bytes of the communication key part can be used to encrypt the verification message Vd, which is not limited in this embodiment.

於步驟S509中,伺服器3依據生成訊息類型的資料封包解密後的資料內容,判斷新金鑰陣列,並以新金鑰陣列取代當前金鑰陣列,據以於之後一段時間中,伺服器3每次接收到加密的資料封包時,自新金鑰陣列中取得多個通訊金鑰其中之一來進行資料解密。具體來說,伺服器3已設定解密後資料內容中的部分位元組是無線感測裝置1用以指示新金鑰陣列的訊息seedd,因此伺服器3可以根據指示新金鑰陣列的訊息seedd,判斷無線感測裝置1將替換的新金鑰陣列。新金鑰陣列亦即與無線感測裝置1中用以替代第一金鑰陣列Kc的第二金鑰陣列Kd相同。為了方便說明,後續敘述將以第二金鑰陣列Kd來代替說明伺服器3產生的新金鑰陣列。 In step S509, the server 3 determines the new key array based on the decrypted data content of the data packet of the generated message type, and replaces the current key array with the new key array. According to the following period of time, the server 3 Each time an encrypted data packet is received, one of a plurality of communication keys is obtained from the new key array to decrypt the data. Specifically, the server 3 has configured that part of the bytes in the decrypted data content is the message seed d used by the wireless sensor device 1 to indicate the new key array, so the server 3 can follow the message indicating the new key array seed d , which determines the new key array that the wireless sensor device 1 will replace. The new key array is the same as the second key array Kd used to replace the first key array Kc in the wireless sensor device 1. For the convenience of description, the following description will replace the new key array generated by the server 3 with the second key array Kd.

於一個例子中,伺服器3具有陣列生成函式,陣列生成函式根據指示第二金鑰陣列Kd的訊息seedd,產生關連於第二金鑰陣列Kd的第二函式。也就是說,當伺服器3以第二金鑰陣列Kd取代第一金鑰陣列Kc後,每次伺服器3要解密加密資料時,軟體便會改成執行第二函式,使第二函式產生金鑰數列來作為解密資料的通訊金鑰。第二函式產生金鑰數列的方法可以參照前述的實施例,不再重複贅述。 In one example, the server 3 has an array generation function, and the array generation function generates a second function related to the second key array Kd according to the message seed d indicating the second key array Kd. In other words, when the server 3 replaces the first key array Kc with the second key array Kd, every time the server 3 wants to decrypt the encrypted data, the software will change to execute the second function so that the second function The key sequence is generated by the formula as the communication key for decrypting data. The method for generating the sequence of keys by the second function can refer to the foregoing embodiment, and will not be repeated here.

請參照第1圖及第5圖,第5圖係為根據本發明又一實施例之無線通信的動態金鑰產生方法的步驟流程圖。如圖所示,於步驟S701中,伺服器3於每次接收到加密的資料封包時,依據資料封包的位元組數,判斷資料封包的類型。於步驟S703中,伺服器3自資料封包對應的當前金鑰陣列中取得多個通訊金鑰其中之一,解密資料封包。當伺服器3已判斷此資料封包為感測資料類型,伺服器3在解密資料封包後,便會儲存解密後的資料內容,並提供給具有對應資料存取權限的資料使用端4存取。當此資料封包為生成訊息類型時,伺服器3將配合無線感測裝置1開始執行替換第一金鑰陣列Kc的程序,故於步驟S705中,判斷資料封包解密後的資料內容是否正確,並於判斷資料封包解密後的資料內容正確時,於步驟 S707中,發送驗證訊息Vd給無線感測裝置1。 Please refer to FIG. 1 and FIG. 5. FIG. 5 is a flowchart of a method for generating a dynamic key for wireless communication according to another embodiment of the present invention. As shown in the figure, in step S701, each time the server 3 receives an encrypted data packet, it determines the type of the data packet according to the number of bytes of the data packet. In step S703, the server 3 obtains one of a plurality of communication keys from the current key array corresponding to the data packet, and decrypts the data packet. When the server 3 has determined that the data packet is a sensing data type, the server 3 will store the decrypted data content after decrypting the data packet and provide it to the data user 4 with corresponding data access rights to access. When the data packet is of the message generation type, the server 3 will cooperate with the wireless sensor device 1 to start the process of replacing the first key array Kc. Therefore, in step S705, it is determined whether the decrypted data content of the data packet is correct, and When it is judged that the data content after decryption of the data packet is correct, in step In S707, the verification message Vd is sent to the wireless sensing device 1.

於本實施例中,前述步驟S701至步驟S707的內容與前述實施例大致上相同,於所屬技術領域具有通常知識者可以依據前述實施例的內容加以變換實施,本實施例不再重複贅述。於第5圖實施例中,由於無線感測裝置1在收到驗證訊息Vd,並確認驗證訊息Vd正確後,會再發送待命訊息,讓無線感測裝置1和伺服器3之間可以再次確認更換成第二金鑰陣列Kd的程序。因此,當伺服器3收到加密的資料封包時,回到步驟S701中,伺服器3依據資料封包的位元組數,判斷資料封包的類型。換言之,待命訊息的位元組數、生成訊息的位元組數和感測資料的有效載荷位元組數皆不相同,因此伺服器3可以依據收到的資料封包的位元組數,來判斷資料封包的類型,亦可藉此取得無線感測裝置1更換第一金鑰陣列Kc的程序進度。 In this embodiment, the contents of the foregoing steps S701 to S707 are substantially the same as those of the foregoing embodiment, and those with ordinary knowledge in the relevant technical field can implement modifications based on the content of the foregoing embodiment, and this embodiment will not be repeated. In the embodiment of FIG. 5, since the wireless sensor device 1 receives the verification message Vd and confirms that the verification message Vd is correct, it will send a standby message again, so that the wireless sensor device 1 and the server 3 can confirm again. Change to the procedure of the second key array Kd. Therefore, when the server 3 receives the encrypted data packet, it returns to step S701, and the server 3 determines the type of the data packet according to the number of bytes of the data packet. In other words, the number of bytes in the standby message, the number of bytes in the generated message, and the number of payload bytes in the sensed data are all different. Therefore, the server 3 can determine the number of bytes in the received data packet. The determination of the type of the data packet can also be used to obtain the progress of the process of replacing the first key array Kc by the wireless sensor device 1.

當伺服器3接收到待命訊息類型的資料封包時,於步驟S703中,伺服器3仍將自第一金鑰陣列Kc或第二金鑰陣列Kd其中之一取得通訊金鑰,亦即自資料封包對應的當前金鑰陣列中取得通訊金鑰,並以取得的通訊金鑰對資料封包進行解密。於步驟S709中,伺服器3判斷資料封包解密後的資料內容是否正確。換言之,於一個實施例中,無線感測裝置1產生的待命訊息是固定的資料內容。伺服器3可以根據固定內容的待命訊息,判斷資料封包解密後的資料內容是否正確。此時,無線感測裝置1產生的待命訊息可以選擇以第一金鑰陣列Kc中的通訊金鑰來加密待命訊息,亦可以選擇以第二金鑰陣列Kd中的通訊金鑰來加密待命訊息。因此,於步驟S703中,伺服器3即配合無線感測裝置1加密通訊金鑰的來源,設定要自第一金鑰陣列Kc或第二金鑰陣列Kd中取得通訊金鑰來解密待命訊息類型的資料封包,本實施例不予限制。 When the server 3 receives the data packet of the standby message type, in step S703, the server 3 will still obtain the communication key from one of the first key array Kc or the second key array Kd, that is, from the data The communication key is obtained from the current key array corresponding to the packet, and the data packet is decrypted with the obtained communication key. In step S709, the server 3 determines whether the decrypted data content of the data packet is correct. In other words, in one embodiment, the standby message generated by the wireless sensor device 1 is a fixed data content. The server 3 can determine whether the decrypted data content of the data packet is correct according to the standby message of the fixed content. At this time, the standby message generated by the wireless sensor device 1 can choose to encrypt the standby message with the communication key in the first key array Kc, or choose to encrypt the standby message with the communication key in the second key array Kd. . Therefore, in step S703, the server 3 cooperates with the wireless sensor device 1 to encrypt the source of the communication key, and is configured to obtain the communication key from the first key array Kc or the second key array Kd to decrypt the standby message type The data packet of is not limited in this embodiment.

於另一個實施例中,無線感測裝置1產生的待命訊息是依據第二金鑰陣列Kd中的一個通訊金鑰產生,且以第一金鑰陣列Kc中的通訊 金鑰加密,因此當伺服器3接收到待命訊息類型的資料封包時,於步驟S703中,將自第一金鑰陣列Kc取得通訊金鑰,並以取得的通訊金鑰對資料封包進行解密。於步驟S709中,伺服器3比對解密後的資料內容與第二金鑰陣列Kd中的通訊金鑰,依據比對結果判斷待命訊息類型的資料封包是否正確。 In another embodiment, the standby message generated by the wireless sensor device 1 is generated based on a communication key in the second key array Kd, and is based on the communication key in the first key array Kc. Key encryption. Therefore, when the server 3 receives a data packet of the standby message type, in step S703, it obtains the communication key from the first key array Kc, and decrypts the data packet with the obtained communication key. In step S709, the server 3 compares the decrypted data content with the communication key in the second key array Kd, and determines whether the data packet of the standby message type is correct according to the comparison result.

於另一個實施例中,無線感測裝置1產生的待命訊息是依據第一金鑰陣列Kc中的一個通訊金鑰產生,且以第二金鑰陣列Kd中的通訊金鑰加密。因此伺服器3在接收到待命訊息類型的資料封包時,於步驟S703中,將自第二金鑰陣列Kd取得通訊金鑰,並以取得的通訊金鑰對資料封包進行解密。於步驟S709中,伺服器3比對解密後的資料內容與第一金鑰陣列Kc的通訊金鑰,依據比對結果判斷待命訊息類型的資料封包是否正確。待命訊息可以是通訊金鑰的部分位元組組成,亦可以僅以通訊金鑰的部分位元進行加密,本實施例不再贅述。 In another embodiment, the standby message generated by the wireless sensor device 1 is generated based on a communication key in the first key array Kc and encrypted with the communication key in the second key array Kd. Therefore, when the server 3 receives the data packet of the standby message type, in step S703, it obtains the communication key from the second key array Kd, and decrypts the data packet with the obtained communication key. In step S709, the server 3 compares the decrypted data content with the communication key of the first key array Kc, and determines whether the data packet of the standby message type is correct according to the comparison result. The standby message can be composed of part of the bytes of the communication key, or it can be encrypted with only part of the bits of the communication key, which will not be repeated in this embodiment.

於步驟S711中,當伺服器3確認待命訊息正確時,發送回應訊息給無線感測裝置1。回應訊息可以是固定的內容亦可以是取自於待命訊息的部分位元組,本實施例不予限制。此外,伺服器3亦可以對回應訊息進行加密。舉例來說,當接收到待命訊息類型的資料封包是以第一金鑰陣列Kc中的通訊金鑰(Kc,n+i+2)進行加密時,伺服器3可以通訊金鑰(Kc,n+i+3)加密回應訊息。當接收到待命訊息類型的資料封包是以第二金鑰陣列Kd中的通訊金鑰(Kd,1)進行加密時,伺服器3可以通訊金鑰(Kd,2)加密回應訊息。 In step S711, when the server 3 confirms that the standby message is correct, it sends a response message to the wireless sensor device 1. The response message may be a fixed content or part of the byte taken from the standby message, which is not limited in this embodiment. In addition, the server 3 can also encrypt the response message. For example, when the received data packet of the standby message type is encrypted with the communication key (Kc,n+i+2) in the first key array Kc, the server 3 can use the communication key (Kc,n +i+3) Encrypt the response message. When the received data packet of the standby message type is encrypted with the communication key (Kd, 1) in the second key array Kd, the server 3 can encrypt the response message with the communication key (Kd, 2).

於步驟S713中,伺服器3依據生成訊息類型的資料封包解密後的資料內容,判斷新金鑰陣列,並以新金鑰陣列取代當前金鑰陣列,據以於之後一段時間,伺服器3每次接收到加密的資料封包時,改自新金鑰陣列中取得多個通訊金鑰其中之一來進行資料解密。以無線感測裝置1是自通訊金鑰(Kd,1)中取部分的位元組作為待命訊息的例子來說,當無 線感測裝置1接收到伺服器3發送的回應訊息後,回復傳送感測資料,並以第二金鑰陣列Kd順序中的下一個通訊金鑰(Kd,2)加密感測資料。因此,伺服器3接收到加密的資料封包時,將以第二金鑰陣列Kd順序中的下一個通訊金鑰(Kd,2)解密資料封包。在無線感測裝置1是自第一金鑰陣列Kc中的通訊金鑰取部分位元組作為待命訊息的例子中,當無線感測裝置1接收到伺服器3發送的回應訊息,並恢復傳送感測資料時,由於第二金鑰陣列Kd中的第一個通訊金鑰(Kd,1)被用作為待命訊息的內容,因此,伺服器3接收到加密的資料封包時,將以第二金鑰陣列Kd順序中的下一個通訊金鑰(Kd,2)解密資料封包。 In step S713, the server 3 determines the new key array based on the decrypted data content of the data packet of the generated message type, and replaces the current key array with the new key array. According to the following period of time, the server 3 every time When an encrypted data packet is received, one of the multiple communication keys is obtained from the new key array to decrypt the data. Take the example that the wireless sensor device 1 takes part of the bytes from the communication key (Kd, 1) as the standby message, when there is no After receiving the response message sent by the server 3, the line sensing device 1 sends back the sensing data, and encrypts the sensing data with the next communication key (Kd, 2) in the sequence of the second key array Kd. Therefore, when the server 3 receives the encrypted data packet, it will decrypt the data packet with the next communication key (Kd, 2) in the sequence of the second key array Kd. In the example in which the wireless sensor device 1 takes part of the bytes from the communication key in the first key array Kc as the standby message, when the wireless sensor device 1 receives the response message sent by the server 3, it resumes sending When sensing data, since the first communication key (Kd, 1) in the second key array Kd is used as the content of the standby message, when the server 3 receives the encrypted data packet, it will use the second The next communication key (Kd, 2) in the key array Kd sequence decrypts the data packet.

綜合以上所述,本發明實施例提供一種無線通信的動態金鑰產生方法,藉由在傳輸資料時從金鑰陣列中取得不一定相同的通訊金鑰,來對資料進行加密,讓資料加密的安全性更高。此外,動態金鑰產生方法不定期地依據隨機產生的訊息,更換金鑰陣列,讓加密資料使用的通訊金鑰更不易被猜測。即使原本使用的金鑰陣列被監聽取得,動態金鑰產生方法更換金鑰陣列後,已被監聽取得的金鑰陣列亦將會無法使用,進而提高無線通信環境中傳輸資料的安全性,進而保護資料擁有者的重要資產。 In summary, the embodiment of the present invention provides a dynamic key generation method for wireless communication, which encrypts the data by obtaining a communication key that is not necessarily the same from the key array during data transmission, so that the data is encrypted. Security is higher. In addition, the dynamic key generation method irregularly replaces the key array based on randomly generated messages, so that the communication key used for encrypting data is less likely to be guessed. Even if the key array originally used is obtained by monitoring, after the dynamic key generation method replaces the key array, the key array that has been monitored and obtained will be unusable, thereby improving the security of data transmission in the wireless communication environment and protecting An important asset of the data owner.

雖然本發明以前述之實施例揭露如上,然其並非用以限定本發明。在不脫離本發明之精神和範圍內,所為之更動與潤飾,均屬本發明之專利保護範圍。關於本發明所界定之保護範圍請參考所附之申請專利範圍。 Although the present invention is disclosed in the foregoing embodiments, it is not intended to limit the present invention. All changes and modifications made without departing from the spirit and scope of the present invention fall within the scope of the patent protection of the present invention. For the scope of protection defined by the present invention, please refer to the attached scope of patent application.

S101~S111:步驟 S101~S111: steps

Claims (25)

一種無線通信的動態金鑰產生方法,包括:於每次傳輸加密資料時,自一第一金鑰陣列中取得多個通訊金鑰其中之一,並以取得的該通訊金鑰進行資料加密;隨機地產生一生成訊息,該生成訊息指示一第二金鑰陣列,且包含一第一驗證訊息;自該第一金鑰陣列中取得該些通訊金鑰其中之一,加密該生成訊息;發送已加密的該生成訊息並要求一第二驗證訊息,其中該第二驗證訊息係於該第一驗證訊息被驗證正確後發送;比對已接收的該第二驗證訊息;以及當該第二驗證訊息比對正確時,以該第二金鑰陣列取代該第一金鑰陣列,據以於每次傳輸加密資料時,自該第二金鑰陣列中取得多個通訊金鑰其中之一來進行資料加密;其中該生成訊息的位元組數不同於每次傳輸加密資料的位元組數。 A method for generating a dynamic key for wireless communication includes: obtaining one of a plurality of communication keys from a first key array every time encrypted data is transmitted, and encrypting data with the obtained communication key; Randomly generating a generated message indicating a second key array and including a first verification message; obtaining one of the communication keys from the first key array, encrypting the generated message; sending The generated message is encrypted and requires a second verification message, wherein the second verification message is sent after the first verification message is verified correctly; the received second verification message is compared; and when the second verification message is received When the message comparison is correct, the first key array is replaced by the second key array, so that each time encrypted data is transmitted, one of a plurality of communication keys is obtained from the second key array. Data encryption; the number of bytes in the generated message is different from the number of bytes in each transmission of encrypted data. 如請求項1所述之無線通信的動態金鑰產生方法,更包括:當未收到該第二驗證訊息時,重新自該第一金鑰陣列中取得該些通訊金鑰其中之一,重新加密該生成訊息;以及發送重新加密的該生成訊息並要求該第二驗證訊息。 The method for generating a dynamic key for wireless communication as described in claim 1, further comprising: when the second verification message is not received, reacquiring one of the communication keys from the first key array, and restarting Encrypting the generated message; and sending the re-encrypted generated message and requesting the second verification message. 如請求項1所述之無線通信的動態金鑰產生方法,更包括使用該第一金鑰陣列中該些通訊金鑰其中之一解密已接收的該第二驗證訊息。 The method for generating a dynamic key for wireless communication according to claim 1, further comprising using one of the communication keys in the first key array to decrypt the received second verification message. 如請求項1所述之無線通信的動態金鑰產生方法,其中於自該第一金鑰陣列中取得該些通訊金鑰其中之一加密該生成訊息的步驟中,包括使用已取得的該通訊金鑰的至少部分位元組加密該生成訊息。 The method for generating a dynamic key for wireless communication according to claim 1, wherein the step of obtaining one of the communication keys from the first key array to encrypt the generated message includes using the obtained communication At least part of the bytes of the key encrypts the generated message. 如請求項1所述之無線通信的動態金鑰產生方法,其中該第一金鑰陣列關聯於一第一函式,於每次傳輸加密資料時,自該第一金鑰陣列中取得該些通訊金鑰其中之一的步驟中,更包括於每次傳輸加密資料時,使用該第一函式產生一金鑰數列,該金鑰數列用以作為該通訊金鑰。 The dynamic key generation method for wireless communication according to claim 1, wherein the first key array is associated with a first function, and each time encrypted data is transmitted, the first key array is obtained One of the steps of the communication key further includes using the first function to generate a key array each time the encrypted data is transmitted, and the key array is used as the communication key. 如請求項1所述之無線通信的動態金鑰產生方法,其中該第一金鑰陣列關聯於一第一函式,於每次傳輸加密資料時,自該第一金鑰陣列中取得該些通訊金鑰其中之一的步驟中,更包括:於每次傳輸加密資料時,使用該第一函式產生多個金鑰數列;串接該些金鑰數列;以及使用已串接的該些金鑰數列的至少部分位元組作為該通訊金鑰。 The dynamic key generation method for wireless communication according to claim 1, wherein the first key array is associated with a first function, and each time encrypted data is transmitted, the first key array is obtained One of the steps of the communication key further includes: using the first function to generate a plurality of key sequences each time the encrypted data is transmitted; concatenating the key sequences; and using the concatenated ones At least part of the byte of the key sequence is used as the communication key. 如請求項1所述之無線通信的動態金鑰產生方法,其中該第二驗證訊息係依據該第一驗證訊息產生,於比對已接收的該第二驗證訊息的步驟中,當已接收的該第二驗證訊息包含至少部分該第一驗證訊息時,該第二驗證訊息比對正確。 The method for generating a dynamic key for wireless communication according to claim 1, wherein the second verification message is generated based on the first verification message, and in the step of comparing the received second verification message, when the received When the second verification message includes at least a part of the first verification message, the second verification message is correctly compared. 如請求項1所述之無線通信的動態金鑰產生方法,其中於當該第二驗證訊息比對正確時,以該第二金鑰陣列取代該第一金鑰陣列的步驟中,更包括: 當該第二驗證訊息比對正確時,自該第一金鑰陣列或該第二金鑰陣列其中之一中取得通訊金鑰,加密一待命訊息;發送已加密的該待命訊息並要求一回應訊息;比對已接收的該回應訊息;以及當該回應訊息比對正確時,以該第二金鑰陣列取代該第一金鑰陣列。 The dynamic key generation method for wireless communication according to claim 1, wherein when the second verification message is correctly compared, the step of replacing the first key array with the second key array further includes: When the second verification message is correctly compared, obtain the communication key from one of the first key array or the second key array, encrypt a standby message; send the encrypted standby message and request a response Message; compare the received response message; and when the response message is compared correctly, replace the first key array with the second key array. 如請求項8所述之無線通信的動態金鑰產生方法,更包括當未收到該回應訊息時,重新發送已加密的該待命訊息並要求該回應訊息。 For example, the method for generating a dynamic key for wireless communication as described in claim 8, further includes when the response message is not received, resending the encrypted standby message and requesting the response message. 如請求項8所述之無線通信的動態金鑰產生方法,更包括:自該第一金鑰陣列中取得該些通訊金鑰其中之一,使用已取得的該通訊金鑰生成該待命訊息;當未收到該回應訊息時,重新自該第一金鑰陣列中取得該些通訊金鑰其中之一,並使用重新取得的該通訊金鑰生成該待命訊息;使用原本用以加密該待命訊息的該通訊金鑰,加密重新生成的該待命訊息,其中原本用以加密該待命訊息的該通訊金鑰係取自於該第二金鑰陣列;以及發送重新生成且加密的該待命訊息,並要求該回應訊息。 The dynamic key generation method for wireless communication according to claim 8, further comprising: obtaining one of the communication keys from the first key array, and using the obtained communication key to generate the standby message; When the response message is not received, re-obtain one of the communication keys from the first key array, and use the re-obtained communication key to generate the standby message; use the original method to encrypt the standby message Encrypt the regenerated standby message, wherein the communication key originally used to encrypt the standby message is taken from the second key array; and send the regenerated and encrypted standby message, and Request the response message. 如請求項8所述之無線通信的動態金鑰產生方法,更包括:自該第二金鑰陣列中取得該些通訊金鑰其中之一,使用已取得的該通訊金鑰生成該待命訊息; 當未收到該回應訊息時,重新自該第一金鑰陣列中取得該些通訊金鑰其中之一,加密該待命訊息;以及發送重新生成且加密的該待命訊息,並要求該回應訊息。 The method for generating a dynamic key for wireless communication according to claim 8, further comprising: obtaining one of the communication keys from the second key array, and using the obtained communication key to generate the standby message; When the response message is not received, reacquire one of the communication keys from the first key array, encrypt the standby message; and send the regenerated and encrypted standby message, and request the response message. 如請求項8所述之無線通信的動態金鑰產生方法,其中該生成訊息的位元組數與該待命訊息的位元組數不同。 The method for generating a dynamic key for wireless communication according to claim 8, wherein the number of bytes of the generated message is different from the number of bytes of the standby message. 如請求項8所述之無線通信的動態金鑰產生方法,其中於以該第一金鑰陣列或該第二金鑰陣列其中之一中取得的通訊金鑰加密該待命訊息的步驟中,包括使用已取得的該通訊金鑰的至少部分位元組加密該待命訊息。 The method for generating a dynamic key for wireless communication according to claim 8, wherein the step of encrypting the standby message with a communication key obtained in one of the first key array or the second key array includes Use at least part of the bytes of the obtained communication key to encrypt the standby message. 一種無線通信的動態金鑰產生方法,包括:於每次接收到加密的一資料封包時,依據該資料封包的位元組數,判斷該資料封包的類型;自該資料封包對應的一當前金鑰陣列中取得多個通訊金鑰其中之一,解密該資料封包;當該資料封包為一生成訊息類型時,判斷該資料封包解密後的資料內容是否正確;當解密後的資料內容比對正確時,發送一驗證訊息;以及依據該生成訊息類型的資料封包解密後的資料內容,判斷一新金鑰陣列,並以該新金鑰陣列取代該當前金鑰陣列,據以於每次接收到加密的資料封包時,自該新金鑰陣列中取得多個通訊金鑰其中之一來進行資料解密。 A method for generating a dynamic key for wireless communication includes: each time an encrypted data packet is received, judging the type of the data packet according to the number of bytes of the data packet; from a current data packet corresponding to the data packet Obtain one of a plurality of communication keys from the key array to decrypt the data packet; when the data packet is a generated message type, determine whether the decrypted data content of the data packet is correct; when the decrypted data content is compared correctly When the time, send a verification message; and determine a new key array based on the decrypted data content of the data packet of the generated message type, and replace the current key array with the new key array, based on each received When encrypting the data packet, one of a plurality of communication keys is obtained from the new key array to decrypt the data. 如請求項14所述之無線通信的動態金鑰產生方法,其中於當該資料封包為該生成訊息類型時,判斷該資料封包解密後的資料內容是否正確的步驟中,更包括:依據解密後的該資料內容,判斷一待驗證訊息;以及比對該待驗證訊息,其中當該待驗證訊息比對正確時,表示解密後的資料內容比對正確。 The method for generating a dynamic key for wireless communication according to claim 14, wherein when the data packet is of the generated message type, the step of judging whether the data content after decryption of the data packet is correct further includes: Determine a message to be verified; and compare the message to be verified, wherein when the message to be verified is correct, it means that the decrypted data content is correct. 如請求項15所述之無線通信的動態金鑰產生方法,更包括依據該待驗證訊息產生該驗證訊息。 The method for generating a dynamic key for wireless communication according to claim 15 further includes generating the verification message based on the to-be-verified message. 如請求項15所述之無線通信的動態金鑰產生方法,更包括使用該當前金鑰陣列中該些通訊金鑰其中之一的部分位元組加密該驗證訊息。 The method for generating a dynamic key for wireless communication according to claim 15 further includes using a partial byte of one of the communication keys in the current key array to encrypt the verification message. 如請求項14所述之無線通信的動態金鑰產生方法,其中於自該資料封包對應的該當前金鑰陣列中取得該些通訊金鑰其中之一,解密該資料封包的步驟中,更包括使用已取得的該通訊金鑰的部分位元組解密該資料封包。 The method for generating a dynamic key for wireless communication according to claim 14, wherein the step of obtaining one of the communication keys from the current key array corresponding to the data packet and decrypting the data packet further includes Use the obtained partial bytes of the communication key to decrypt the data packet. 如請求項14所述之無線通信的動態金鑰產生方法,其中該當前金鑰陣列關聯於一第一函式,於每次接收到加密的資料封包時,自該當前金鑰陣列中取得該些通訊金鑰其中之一以解密該資料封包的步驟中,更包括於每次接收到加密的資料封包時,使用該第一函式產生一金鑰數列,該金鑰數列用以作為該通訊金鑰。 The method for generating a dynamic key for wireless communication according to claim 14, wherein the current key array is associated with a first function, and each time an encrypted data packet is received, the current key array is obtained The step of using one of the communication keys to decrypt the data packet further includes using the first function to generate a key sequence each time an encrypted data packet is received, and the key sequence is used as the communication Key. 如請求項14所述之無線通信的動態金鑰產生方法,其中該當前金鑰陣列關聯於一第一函式,於自該資料封包對應的該當前金 鑰陣列中取得該些通訊金鑰其中之一,以解密該資料封包的步驟中,更包括:於每次傳輸加密資料時,使用該第一函式產生多個金鑰數列;串接該些金鑰數列;以及使用已串接的該些金鑰數列的至少部分位元組作為該通訊金鑰。 The dynamic key generation method for wireless communication according to claim 14, wherein the current key array is associated with a first function, and the current key corresponding to the data packet The step of obtaining one of the communication keys from the key array to decrypt the data packet further includes: each time the encrypted data is transmitted, the first function is used to generate a plurality of key sequences; Key sequence; and using at least part of the bytes of the concatenated key sequence as the communication key. 如請求項14所述之無線通信的動態金鑰產生方法,更包括:當接收到資料封包為一待命訊息類型時,判斷該資料封包解密後的資料內容是否正確;以及當該待命訊息類型的資料封包解密後的資料內容正確時,發送一回應訊息;其中該待命訊息類型的資料封包位元組數不同於該生成訊息類型的資料封包位元組數。 For example, the method for generating a dynamic key for wireless communication according to claim 14, further includes: when the received data packet is of a standby message type, determining whether the data content after decryption of the data packet is correct; and when the data packet is of the standby message type When the decrypted data content of the data packet is correct, a response message is sent; wherein the number of data packet bytes of the standby message type is different from the number of data packet bytes of the generated message type. 如請求項21所述之無線通信的動態金鑰產生方法,更包含比對該待命訊息類型的資料封包解密後的資料內容與該新金鑰陣列中該些通訊金鑰其中之一,當解密後的資料內容與該新金鑰陣列中該些通訊金鑰其中之一的部分位元組相同時,該資料封包解密後比對正確。 As described in claim 21, the method for generating a dynamic key for wireless communication further includes comparing the data content after decrypting the data packet of the standby message type with one of the communication keys in the new key array. When the content of the latter data is the same as the partial byte of one of the communication keys in the new key array, the data packet is correctly compared after decryption. 如請求項22所述之無線通信的動態金鑰產生方法,其中當接收到資料封包為待命訊息類型時,係以該當前金鑰陣列其中之一通訊金鑰的部分位元組進行解密。 The method for generating a dynamic key for wireless communication according to claim 22, wherein when the received data packet is of the standby message type, a partial byte of one of the communication keys of the current key array is used for decryption. 如請求項21所述之無線通信的動態金鑰產生方法,更包含比對該待命訊息類型的資料封包解密後的資料內容與該當前金鑰 陣列中該些通訊金鑰其中之一,當解密後的資料內容與該當前金鑰陣列中該些通訊金鑰其中之一的部分位元組相同時,該資料封包解密後比對正確。 As described in claim 21, the method for generating a dynamic key for wireless communication further includes comparing the data content after decrypting the data packet of the standby message type with the current key When one of the communication keys in the array, when the decrypted data content is the same as the partial byte of one of the communication keys in the current key array, the data packet is correctly compared after decryption. 如請求項24所述之無線通信的動態金鑰產生方法,其中當接收到資料封包為待命訊息類型時,係以該新金鑰陣列其中之一通訊金鑰的部分位元組進行解密。 The method for generating a dynamic key for wireless communication according to claim 24, wherein when the received data packet is a standby message type, a partial byte of one of the communication keys of the new key array is used for decryption.
TW108125987A 2019-07-23 2019-07-23 Dynamic key generating method for wireless communication TWI730355B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
TW108125987A TWI730355B (en) 2019-07-23 2019-07-23 Dynamic key generating method for wireless communication
JP2020125618A JP7017802B2 (en) 2019-07-23 2020-07-22 How to generate dynamic keys in wireless communication

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW108125987A TWI730355B (en) 2019-07-23 2019-07-23 Dynamic key generating method for wireless communication

Publications (2)

Publication Number Publication Date
TW202106060A TW202106060A (en) 2021-02-01
TWI730355B true TWI730355B (en) 2021-06-11

Family

ID=74566211

Family Applications (1)

Application Number Title Priority Date Filing Date
TW108125987A TWI730355B (en) 2019-07-23 2019-07-23 Dynamic key generating method for wireless communication

Country Status (2)

Country Link
JP (1) JP7017802B2 (en)
TW (1) TWI730355B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100211787A1 (en) * 2009-02-19 2010-08-19 Leonid Bukshpun Chaotic cipher system and method for secure communication
US20120294440A1 (en) * 2004-04-02 2012-11-22 Research In Motion Limited Key Agreement and Re-keying over a Bidirectional Communication Path

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09312642A (en) * 1996-05-20 1997-12-02 Fujitsu Ltd Data communication method
JP3902440B2 (en) 2001-10-29 2007-04-04 三菱電機株式会社 Cryptographic communication device
JP2004186939A (en) 2002-12-03 2004-07-02 Sony Ericsson Mobilecommunications Japan Inc Encryption processor and method therefor
WO2005117334A1 (en) 2004-05-31 2005-12-08 National Research Council Of Canada State based secure transmission for a wireless system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120294440A1 (en) * 2004-04-02 2012-11-22 Research In Motion Limited Key Agreement and Re-keying over a Bidirectional Communication Path
US20100211787A1 (en) * 2009-02-19 2010-08-19 Leonid Bukshpun Chaotic cipher system and method for secure communication

Also Published As

Publication number Publication date
TW202106060A (en) 2021-02-01
JP2021019360A (en) 2021-02-15
JP7017802B2 (en) 2022-02-09

Similar Documents

Publication Publication Date Title
US8090106B2 (en) Multi-level data encryption and decryption system and method thereof
KR20180119201A (en) Electronic device for authentication system
US10491403B2 (en) Data loss prevention with key usage limit enforcement
JP2020005282A (en) Transmission of beacon messages
CN110460439A (en) Information transferring method, device, client, server-side and storage medium
EP3223452A1 (en) Method and apparatus for providing service on basis of identifier of user equipment
Boakye-Boateng et al. Encryption protocol for resource-constrained devices in fog-based IoT using one-time pads
EP3741093B1 (en) System and method for privacy-preserving data retrieval for connected power tools
KR101688813B1 (en) Method and system for establishing relationship between iot device and owner
US10785023B2 (en) Apparatus and method for managing metering information
KR102028151B1 (en) Encryption method and system using authorization key of device
CN101738516A (en) Electronic electric energy meter and data secure transmission method thereof
EP2028820A2 (en) Method and apparatus for checking round trip based on challenge response as well as computer readable medium having recorded thereon program for the method
CN109756451B (en) Information interaction method and device
CN111586680A (en) Power grid end-to-end communication encryption system and method, communication equipment and storage medium
CN101635623B (en) Multilevel Data Encryption and Decryption System and Method
Sudarsono et al. An implementation of secure data sensor transmission in wireless sensor network for monitoring environmental health
TWI730355B (en) Dynamic key generating method for wireless communication
KR101880708B1 (en) DATA TRANSFER SYSTEM OF DEVICE IN IoT HAVING IMPROVED SECURITY
JP5361970B2 (en) Communication system, first communication device, second communication device, encrypted communication method, and program
Liao et al. A location-dependent data encryption approach for enhancing mobile information system security
JP6697355B2 (en) Transmitter, communication system, transmission method and program
GB2570292A (en) Data protection
KR101757563B1 (en) Apparatus and method for managing secret key in IoT environment
CN100407616C (en) Method for automatically updating key code of network system