Design and Implementation of Random Number Generator System Based on Android Smartphone Sensor
Total Page:16
File Type:pdf, Size:1020Kb
International Journal of Network Security, Vol.23, No.1, PP.33-41, Jan. 2021 (DOI: 10.6633/IJNS.202101_23(1).05) 33 Design and Implementation of Random Number Generator System Based on Android Smartphone Sensor Yusuf Kurniawan and Mochamad Beta Auditama (Corresponding author: Yusuf Kurniawan) School of Electrical Engineering and Informatics, Institut Teknologi Bandung Jl. Ganesha No.10, Lb. Siliwangi, Kecamatan Coblong, Kota Bandung, Jawa Barat 40132, Indonesia (Email: [email protected]) (Received May 21, 2019; revised and accepted May 2, 2020) Abstract 4) Conclusion. An android smartphone has various types of sensors in its de- vice. All of these sensors produce data based on environmen- 2 Related Work tal condition that exists around the device. These data have the potential to be used as the random number because of its 2.1 Android Sensor non-deterministic component. To realize it, some steps need to be carried out, such as knowing the characteristic of the sen- The android smartphone divides its sensor into two types, sor, estimating the entropy value possessed by the sensor data, namely the base sensor and composite sensor. The base sensor and so on. As a proof-of-concept, this research is conducted to is a single physical sensor that measures certain phenomena design and implement the entropy source and pseudorandom that exist in the sensor environment, whereas composite sensor number generator based on the android sensor. The research is a combination of one or more single physical sensor with a result shows that by using accelerometer data with XOR re- specific algorithm to measure a phenomenon which is not cov- sult as the input of entropy source and HMAC DRBG as the ered by the base sensor. In this research, the composite sensor pseudorandom number generator, so the high quality of ran- is not selected as randomness source, because only base sensor dom number based on the android sensor can be obtained. that actually produces non-deterministic data. Table 1 shows a list of the base sensor and their reporting Keywords: Android Sensor; Entropy Source; Pseudorandom mode. The base sensor with a ”continuous” reporting mode Number Generator will produce data continuously as long as the sensor operates, whereas the base sensor with the ”on-change” reporting mode 1 Introduction will only produce data when a phenomenon in the environment changes significantly. To get as many random numbers as pos- sible, the base sensor with a” continuous” reporting mode is In November 2017, there were already 2.3 billion active smart- selected as a randomness source. phone devices based on the Android operating system in the world. The android smartphone provides various features for Table 1: A list of base sensor in Android its users, such as mobile banking. These features use a lot of smartphone resources, especially the random numbers. Sensor name Reporting mode Actually, the android operating system has already a ran- Temperature On-change dom number generation system based on the interrupt process, Heart rate On-change I/O disk operations, and the user input [14]. This random Light On-change number generation system is considered safe, but the android Proximity On-change smartphone also has a potential resource to be used as a ran- Relative humidity On-change domness source, which is the sensor. This paper is organized Pressure Continuous as follows : Magnetometer Continuous Accelerometer Continuous Gyroscope Continuous 1) Related Work; 2) Entropy Source Based on Android Sensor; Because the pressure sensor is rarely owned by the majority 3) Pseudorandom Number Generator (PRNG); of the Android smartphone and the measurement result of the International Journal of Network Security, Vol.23, No.1, PP.33-41, Jan. 2021 (DOI: 10.6633/IJNS.202101_23(1).05) 34 magnetometer is unstable, especially when the magnetometer maximum output size is equal or less than the number of the is placed close to the iron material, only accelerometer and input data. This problem can be overcome by using PRNG gyroscope are selected as the randomness source for now. which only involves two components, namely a seed (non- determinism data with limited size) and a deterministic algo- 2.2 Micro-electromechanical Systems (MEMS) rithm. A deterministic algorithm is designed to be able to pro- duce a long-size of high-quality random numbers from short- MEMS is a modern technology to manufacture accelerome- size seed. The existing cryptographic algorithm, such as hash ter and gyroscope on the Android smartphone. With MEMS function and symmetric encryption block, can be used as a technology, accelerometer and gyroscope can be produced as PRNG deterministic algorithm. a microscale integrated device by creating and combining me- chanical and electrical components [5]. 2.4 Entropy In the real-world, the MEMS accelerometer and gyroscope have two dominant types of non-deterministic noise which Entropy represents the level of difficulty at guessing the next are bias instability (BI) and Angle/ Velocity Random Walk output produced by the system [6]. For example, there are (ARW/VRW) [4]. If the sensor is operated when not moving machine 1 and machine 2 where each machine producing four (motionless) and two or more set data with size and sample is letters A, B, C, D randomly with the following probability of created, the average value for a set data is different from each occurrence: other. This difference in value is called BI error. ARW/ VRW error is caused by the Brownian motion of air particles trapped Machine1 : inside the MEMS device [11]. These two non-deterministic er- rors are the majority factors that cause MEMS accelerometer P(A) = 0; 25; P(B) = 0; 25; output and gyroscope to always fluctuate randomly and subse- P(C) = 0; 25; P(D) = 0; 25: quently have the potential to generate random numbers. The magnitude of BI and ARW/VRW error owned by the MEMS Machine2 : accelerometer and gyroscope can be estimated using the Allan Variance (AVAR) method [10]. P(A) = 0; 50; P(B) = 0; 25; Table 2 shows the BI and ARW/VRW coefficient values P(C) = 0; 125; P(D) = 0; 125: for MEMS accelerometer and gyroscope from different types of Android smartphones, namely B and Q. For example, if Thus, the entropy value for machine 1 is greater than the en- the gyroscope on Andromax R is operated for an hour (3.600 tropy value for machine 2, because machine 2 will produce let- seconds), the ARW error in which the coefficient value is B ters A and B more often than letters C and D. This is different = 0.0012 rad.s1/2 causes the measurement result to deviate ap- from machine 1 which producing its four letters with (almost) proximately 0.0012 x (3600)1/2 = 0.072 rad. equal quantity. Below is given the equation to calculate the entropy value of a system that has n sample space: Table 2: The value of B and Q for the MEMS accelerometer Entropy = [ p1 x log2(p1) + p2 x log2(p2) + ... + pn-1 x and gyroscope from five different types of Android log2(pn-1) + pn x log2(pn)...], smartphones with pi = the occurrence probability for the ith unique ele- ment (1 ≤ i ≤ n). Accelerometer Gyroscope Smartphone B[m/s2] Q[(m/s).s1=2 B[rad/s] B[rad/s1=2] A 0.0046 0.0028 2.87x10−5 0.0012 3 Entropy Source Based on Android B 7.34x10−4 0.0022 4.83x10−5 3.66x10−4 C 3.69x10−4 6.08x10−4 No gyroscope Sensor D 6.39x10−4 0.0014 1.26x10−4 3.10x10−4 E 2.61x10−4 8.39x10−4 3.41x10−5 9.02x10−5 The entropy source used in this research is in conformance with the NIST SP 800-90B recommendation. See Figure 1 and [9]. There are five components involved in this entropy *Note: Smartphone A, B, C, D, E consecutively are Andro- source, namely randomness source, digitization, entropy esti- max R, Asus Zenfone 2, Galaxy Fame, Galaxy Note 10,1, & mation (for each sensor sample), health test, and conditioning. Galaxy S III Mini. 3.1 Randomness Source 2.3 Random Number Generator The randomness source is implemented by the accelerometer There are two kinds of systems that can be used to generate or gyroscope. Several specifications shall be satisfied with col- the random number, namely True Random Number Generator lecting sensor samples as follows: (TRNG) and Pseudorandom Number Generator (PRNG) [13]. TRNG, or it can also be referred to as an entropy source, pro- 1) Sensor samples are collected from five different types of duces a random number with the highest quality because this Android smartphones: Andromax R, Asus Zenfone 2, output is formed from purely non-deterministic input. How- Samsung Galaxy Fame (no gyroscope), Samsung Galaxy ever, the output size of TRNG is so little, specifically, the Note 10.1, and Samsung Galaxy S III Mini. International Journal of Network Security, Vol.23, No.1, PP.33-41, Jan. 2021 (DOI: 10.6633/IJNS.202101_23(1).05) 35 Figure 2: Entropy estimation process per sensor sample 3.3 Entropy Estimation Per Sensor Sample Figure 2 shows the procedure of entropy estimation for each Figure 1: Entropy source model sensor sample. 1) Data collection: For each type of sensor on each Android smartphone, two types of data sets need to be formed, 2) The sensor sample is taken by placing the smartphone on namely sequential data set and restart data set. Sequen- the table, the direction of the smartphone screen is facing tial data set is formed by operating the sensor continu- up to the rooftop, and the smartphone is in a motionless ously until 1,000,100 samples are obtained, while restart state.