# A Complete Key Management Scheme for LoRaWAN v1.1 +
## 6 New Key Generation Algorithm for LoRaWAN
The result from the Rabbit PRNG then XORed with the shared-contexts. (4). After that, the result once again passes through the Rabbit PRNG with the number of system iterations either two for Modified Rabbit v1 or one for Modified Rabbit v2. (5). The resulting key from the second Rabbit PRNG is the final key produced by the proposed Modified Rabbit PRNG. Every step in the proposed PRNG is to ensure the greater key diffusion. Since the Rabbit is based on the simpler Rabbit [39] that does not contain the IV. The proposed PRNG  
Figure 5: The proposed Modified Rabbit PRNG. brings 128 bits shared-contexts into the algorithm to make more nonlinearity and more diffusion into the system. Also, due to the proposed Modified Rabbit used cipher feedback with one more round that goes through the Rabbit PRNG. Hence, the result has given a considerable safe margin. The test results and analysis are conducted below. A computing experiment is conducted on the Modified Rabbit PRNG v1 [6], Modified Rabbit PRNG v2, Rabbit PRNG, and AES_ECB. The test environment is a MacBook Pro with the processor 2.8 GHz Intel Core i7, 16 G.B., 1600 MHz DDR3 Memory, macOS High Sierra v10.13.6 Operating System. The 1 million repeat test is carried on each of the algorithms. The computing time comparison is shown in Figure 6. As seen from the figure, the Modified Rabbit v1 [6] is about 10.2% faster than Rabbit PRNG and 23.2% faster than AES_ECB. However, the proposed Modified Rabbit v2 is about 14.8% faster than the Modified Rabbit v1, 23.5% faster than Rabbit PRNG and 34.6% faster than AES_ECB. Hence, the proposed Modified Rabbit v2 is the most computing-efficient algorithm among the four key generators. Randomness tests were also carried out on the keys generated by AES, Rabbit, the Modified Rabbit v1 and v2 algorithms. The tests follow the NIST Randomness Guidelines [26]. The first test is on the 0s and 1s distribution in the whole 128-bit key. All four algorithms have produced similar results, i.e., the percentage of 1s in the key stream is about 50%. The second test is on segments of the 128 bits. The 128 keys are partitioned into 16 segments with the segment size: 8. The number of 1s in the segments for all four algorithms follow almost the same distribution shown in Figure 7.  
In addition, the Modified Rabbit v1 and v2 were also tested to verify the key uniqueness. In LoRaWAN v1.1, The session key update recommendation suggests that the session key should be updated at least every 17 minutes. Therefore, the Modified Rabbit v1 and v2 have tested in a range of 100 years. That means the proposed PRNG key generator can guarantee 100% uniqueness in the keys only if the test result shows 100% uniqueness. In the test trials, 100 years equals to 3,091,800 key updates. The results have shown that the  
Figure 6: Runtime Test: Modified Rabbit v2 vs Modified Rabbit v1 vs Rabbit vs AES ECB. 100% uniqueness in the keys which means that no repeats have been found in 3,091,800 keys. As the study did not do an exhaust test, the average of repeat key appearance may need far more than 3 million key generations.