瀏覽代碼

Install OneRNG driver

Bob Mottram 10 年之前
父節點
當前提交
2eec544b49
共有 2 個文件被更改,包括 54 次插入6 次删除
  1. 41
    1
      src/freedombone
  2. 13
    5
      src/freedombone-config

+ 41
- 1
src/freedombone 查看文件

110
 # This can be empty, "beaglebone" or "onerng"
110
 # This can be empty, "beaglebone" or "onerng"
111
 HWRNG_TYPE=
111
 HWRNG_TYPE=
112
 
112
 
113
+# Download location for OneRNG driver
114
+ONERNG_PACKAGE="onerng_3.3-1_all.deb"
115
+ONERNG_PACKAGE_DOWNLOAD="https://github.com/OneRNG/onerng.github.io/blob/master/sw/$ONERNG_PACKAGE?raw=true"
116
+# Hash for OneRNG driver
117
+ONERNG_PACKAGE_HASH='a9801993ffef1cc19778f5613f1837aca4212a0d299d75bd524134f865774928'
118
+
113
 # Whether this system is being installed within a docker container
119
 # Whether this system is being installed within a docker container
114
 INSTALLED_WITHIN_DOCKER="no"
120
 INSTALLED_WITHIN_DOCKER="no"
115
 
121
 
4731
 }
4737
 }
4732
 
4738
 
4733
 function install_onerng {
4739
 function install_onerng {
4734
-  # TODO
4740
+  apt-get -y install rng-tools at python-gnupg
4741
+
4742
+  # Move to the installation directory
4743
+  if [ ! -d $INSTALL_DIR ]; then
4744
+      mkdir $INSTALL_DIR
4745
+  fi
4746
+  cd $INSTALL_DIR
4747
+
4748
+  # Download the package
4749
+  if [ ! -f $ONERNG_PACKAGE ]; then
4750
+      wget $ONERNG_PACKAGE_DOWNLOAD
4751
+  fi
4752
+  if [ ! -f $ONERNG_PACKAGE ]; then
4753
+      echo "OneRNG package could not be downloaded"
4754
+      exit 59249
4755
+  fi
4756
+
4757
+  # Check the hash
4758
+  hash=$(sha256sum $ONERNG_PACKAGE)
4759
+  if [[ $hash != $ONERNG_PACKAGE_HASH ]]; then
4760
+      echo "OneRNG package: $ONERNG_PACKAGE"
4761
+      echo "Hash does not match. This could indicate that the package has been tampered with."
4762
+      echo "OneRNG expected package hash: $ONERNG_PACKAGE_HASH"
4763
+      echo "OneRNG actual hash: $hash"
4764
+      exit 25934
4765
+  fi
4766
+
4767
+  # install the package
4768
+  dpkg -i $ONERNG_PACKAGE
4769
+
4770
+  # Check that the install worked
4771
+  if [ ! -f /etc/onerng.conf ]; then
4772
+      echo 'OneRNG configuration file not found. The package may not have installed successfully.'
4773
+      exit 42904
4774
+  fi
4735
 }
4775
 }
4736
 
4776
 
4737
 function random_number_generator {
4777
 function random_number_generator {

+ 13
- 5
src/freedombone-config 查看文件

327
 
327
 
328
   data=$(tempfile 2>/dev/null)
328
   data=$(tempfile 2>/dev/null)
329
   trap "rm -f $data" 0 1 2 5 15
329
   trap "rm -f $data" 0 1 2 5 15
330
-  dialog --backtitle "Random Number Generation" \
331
-      --radiolist "Type of RNG:" 17 40 3 \
332
-      1 Haveged on \
333
-      2 Beaglebone built-in HRNG off \
334
-      3 OneRNG off 2> $data
330
+  if [[ $INSTALLING_ON_BBB == "no" ]]; then
331
+      dialog --backtitle "Random Number Generation" \
332
+          --radiolist "Type of RNG:" 17 40 3 \
333
+          1 Haveged on \
334
+          2 Beaglebone built-in HRNG off \
335
+          3 OneRNG off 2> $data
336
+  else
337
+      dialog --backtitle "Random Number Generation" \
338
+          --radiolist "Type of RNG:" 17 40 3 \
339
+          1 Haveged off \
340
+          2 Beaglebone built-in HRNG on \
341
+          3 OneRNG off 2> $data
342
+  fi
335
   sel=$?
343
   sel=$?
336
   case $sel in
344
   case $sel in
337
       1) exit 0;;
345
       1) exit 0;;