# A Complete Key Management Scheme for LoRaWAN v1.1 +
## 6 New Key Generation Algorithm for LoRaWAN  
Energy consumption is a key consideration for the key generation of the LoRaWAN devices due to constrained-energy supply on the devices. The proposed algorithm for key generation must satisfy the following criteria. (1): The algorithm must produce the same output key for the paired sender and receiver when the same input seed is used. In other words, if the sender and receiver use same input key on each side; then they should generate an identical output key on each side (The end device must be able to derive the same output session key which same at the network/application server). (2): Computing-efficient is needed for the algorithm. (3): The output of the key generation should be randomly distributed. A key generation scheme can be considered to be a pseudo-random number generator. There are many existing algorithms that could be used as the generator, including the AES and Blowfish [29], another widely used block cipher. The initial test has shown that Blowfish and AES are comparable in computing efficiency for a small size input data, and this has also been verified in many published papers [30; 31]. The Rabbit cipher [32] is a famous stream cipher that is well known for its speed as it is one of the algorithms in the final eSTREAM project in 2008 [33]. The reason that the Rabbit cipher is chosen from the eSTREAM project to be our proposed base algorithm due to it uses a 128 bits key that is the same as the AES 128 used in the current version of LoRaWAN. Hence, it is compatible, there is no need to change the setting of the input key size. Also, it has been proposed to use for the Wireless Sensor Networks [34]. Furthermore, unlike other final winners in the project, the Rabbit algorithm did not have the drawbacks that appeared in the other algorithms. For example, HC-128 is a table-driven algorithm, it is costly to initialize the cipher. Hence, it is not suitable for application that requires frequent key updates [35]. SOSEMANUK and Salsa20 have also been found to be vulnerable under attacks [36; 37; 38]. Therefore, the Rabbit cipher is a well-chosen choice for our proposed scheme. The Rabbit algorithm is actually a pseudo-random generator and the initial test has shown that the Rabbit algorithm is faster than AES. After a further study on the Rabbit algorithm, a modified Rabbit algorithm is proposed to further speed up the computing. Figure 4: Flowchart for ensuring the Backward Compatibility in BCS. The Rabbit cipher takes a 128-bit secret key with a 64-bit of IV as input, that produces an output of 128 bits keystream. The keystream then XORed with plaintext to produce the ciphertext. Here, only the keystream generation part is interested in the research. The Initial Vector (IV) in the Rabbit algorithm is for more nonlinearity and diffusion. It is important for the Rabbit as a cipher. However, as a key generator, the input key to the Rabbit algorithm will meet the basic requirement. By removing the IV and IV setups from the algorithm, the simpler Rabbit is still a decent pseudo-random generator which was introduced by [PERSON] et al. in 2003 as a cipher [39]. Hence, the proposed Modified Rabbit is based on the simpler Rabbit, but the proposed Modified Rabbit is faster than the latest Rabbit [32], please see the experimental section. There are two versions of the proposed Modified Rabbit PRNG (v1 and v2). Our Modified Rabbit PRNG v1 has been published in [6]. The difference is the number of iterations in the system. Proposed Modified Rabbit has the following procedures (refer to Figure 5 for its structure): (1). XORed the key with some shared-contexts, the shared-contexts can be found on both sides of the link such as DevNounce, JoinEUI, and JoinNounce, etc. (2). The result goes through the Rabbit PRNG with two system iterations (Modified Rabbit v1) in the Rabbit PRNG (The original Rabbit has four iterations to ensure the safe margin) [39]. Or the result goes through the Rabbit PRNG with only one system iteration (Modified Rabbit v2). (3).