| 
				
			 | 
			
			
				@@ -1497,18 +1497,20 @@ function remove_instructions_from_motd { 
			 | 
		
	
		
			
			| 
				1497
			 | 
			
				1497
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				1498
			 | 
			
				1498
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				1499
			 | 
			
				1499
			 | 
			
			
				 function check_hwrng { 
			 | 
		
	
		
			
			| 
				1500
			 | 
			
				
			 | 
			
			
				-  # If hardware random number generation was enabled then make sure that the device exists. 
			 | 
		
	
		
			
			| 
				1501
			 | 
			
				
			 | 
			
			
				-  # if /dev/hwrng is not found then any subsequent cryptographic key generation would 
			 | 
		
	
		
			
			| 
				1502
			 | 
			
				
			 | 
			
			
				-  # suffer from low entropy and might be insecure 
			 | 
		
	
		
			
			| 
				1503
			 | 
			
				
			 | 
			
			
				-  if [ ! -f /etc/default/rng-tools ]; then 
			 | 
		
	
		
			
			| 
				1504
			 | 
			
				
			 | 
			
			
				-      return 
			 | 
		
	
		
			
			| 
				1505
			 | 
			
				
			 | 
			
			
				-  fi 
			 | 
		
	
		
			
			| 
				1506
			 | 
			
				
			 | 
			
			
				-  if [ ! -e /dev/hwrng ]; then 
			 | 
		
	
		
			
			| 
				1507
			 | 
			
				
			 | 
			
			
				-      ls /dev/hw* 
			 | 
		
	
		
			
			| 
				1508
			 | 
			
				
			 | 
			
			
				-      echo 'The hardware random number generator is enabled but could not be detected on' 
			 | 
		
	
		
			
			| 
				1509
			 | 
			
				
			 | 
			
			
				-      echo '/dev/hwrng.  There may be a problem with the installation or the Beaglebone hardware.' 
			 | 
		
	
		
			
			| 
				1510
			 | 
			
				
			 | 
			
			
				-      exit 75 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1500
			 | 
			
			
				+  if [[ $HWRNG_TYPE == "beaglebone" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1501
			 | 
			
			
				+      # If hardware random number generation was enabled then make sure that the device exists. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1502
			 | 
			
			
				+      # if /dev/hwrng is not found then any subsequent cryptographic key generation would 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1503
			 | 
			
			
				+      # suffer from low entropy and might be insecure 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1504
			 | 
			
			
				+      if [ ! -e /dev/hwrng ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1505
			 | 
			
			
				+          ls /dev/hw* 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1506
			 | 
			
			
				+          echo 'The hardware random number generator is enabled but could not be detected on' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1507
			 | 
			
			
				+          echo '/dev/hwrng.  There may be a problem with the installation or the Beaglebone hardware.' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1508
			 | 
			
			
				+          exit 75 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1509
			 | 
			
			
				+      fi 
			 | 
		
	
		
			
			| 
				1511
			 | 
			
				1510
			 | 
			
			
				   fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1511
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1512
			 | 
			
			
				+  # If a OneRNG device was install then verify its firmware 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1513
			 | 
			
			
				+  check_onerng_verification 
			 | 
		
	
		
			
			| 
				1512
			 | 
			
				1514
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				1513
			 | 
			
				1515
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				1514
			 | 
			
				1516
			 | 
			
			
				 function get_mariadb_password { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -4736,6 +4738,22 @@ function enable_zram { 
			 | 
		
	
		
			
			| 
				4736
			 | 
			
				4738
			 | 
			
			
				   echo 'enable_zram' >> $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				4737
			 | 
			
				4739
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				4738
			 | 
			
				4740
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				4741
			 | 
			
			
				+function check_onerng_verification { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4742
			 | 
			
			
				+  if [[ $HWRNG_TYPE != "onerng" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4743
			 | 
			
			
				+      return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4744
			 | 
			
			
				+  fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4745
			 | 
			
			
				+  echo 'Checking OneRNG firmware verification' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4746
			 | 
			
			
				+  last_onerng_validation=$(cat /var/log/syslog.1 | grep "OneRNG: firmware verification" | awk '/./{line=$0} END{print line}') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4747
			 | 
			
			
				+  if [[ $last_onerng_validation != *"passed OK"* ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4748
			 | 
			
			
				+      last_onerng_validation=$(cat /var/log/syslog | grep "OneRNG: firmware verification" | awk '/./{line=$0} END{print line}') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4749
			 | 
			
			
				+      if [[ $last_onerng_validation != *"passed OK"* ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4750
			 | 
			
			
				+          echo $last_onerng_validation 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4751
			 | 
			
			
				+          echo 'OneRNG firmware verification failed' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4752
			 | 
			
			
				+          exit 735026 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4753
			 | 
			
			
				+      fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4754
			 | 
			
			
				+  fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4755
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4756
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				4739
			 | 
			
				4757
			 | 
			
			
				 function install_onerng { 
			 | 
		
	
		
			
			| 
				4740
			 | 
			
				4758
			 | 
			
			
				   apt-get -y install rng-tools at python-gnupg 
			 | 
		
	
		
			
			| 
				4741
			 | 
			
				4759
			 | 
			
			
				  
			 |