Blame view

scripts/gcc-plugins/gen-random-seed.sh 305 Bytes
81f7e3824   Eric Lee   Initial Release, ...
1
2
3
4
5
6
7
8
9
10
11
  #!/bin/sh
  # SPDX-License-Identifier: GPL-2.0
  
  if [ ! -f "$1" ]; then
  	SEED=`od -A n -t x8 -N 32 /dev/urandom | tr -d ' 
  '`
  	echo "const char *randstruct_seed = \"$SEED\";" > "$1"
  	HASH=`echo -n "$SEED" | sha256sum | cut -d" " -f1 | tr -d ' 
  '`
  	echo "#define RANDSTRUCT_HASHED_SEED \"$HASH\"" > "$2"
  fi