Debian Codegraph @

3rdparty/vboot/utility/tpm-dad-lock

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`. -e
2 #
3 # Copyright 2010 The ChromiumOS Authors
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # Attempt to trigger the TPM Dictionary Attack Defense Lock and measure its
8 # behavior.
9
10 if [scip-shell system . . `[`. -f /sys/class/misc/tpm0/device/ownedscip-shell filesystem . . `/sys/class/misc/tpm0/device/owned`. ]; then
11 owned=$(catscip-shell system . . cat. /sys/class/misc/tpm0/device/ownedscip-shell filesystem . . `/sys/class/misc/tpm0/device/owned`.)
12 else
13 owned=$(catscip-shell system . . cat. /sys/class/tpm/tpm0/device/ownedscip-shell filesystem . . `/sys/class/tpm/tpm0/device/owned`.)
14 fi
15 if [scip-shell system . . `[`. "$owned" = "" ]; then
16 echoscip-shell system . . echo. "TPM is not functional"
17 exit 1
18 fi
19 if [scip-shell system . . `[`. "$owned" = "0" ]; then
20 echoscip-shell system . . echo. "please use random, non-empty passwords"
21 tpm_takeownership || exit 1
22 fi
23
24 attempts=0
25 max=1
26 e=/tmp/x$$
27
28 while truescip-shell system . . true.; do
29 attempts=$(( $attempts + 1 ))
30 before=$(datescip-shell system . . date. +%s)
31 defending=1
32 while [scip-shell system . . `[`. $defending -eq 1 ]; do
33 if tpm_getpubek -z 2> $e; then
34 echoscip-shell system . . echo. "unexpected success of tpm_getpubek"
35 exit 1
36 fi
37 if grepscip-shell system . . grep. -q communication $e; then
38 echoscip-shell system . . echo. "communication failure"
39 exit 1
40 fi
41 if ! grepscip-shell system . . grep. -q dictionary $e; then
42 defending=0
43 fi
44 done
45 after=$(datescip-shell system . . date. +%s)
46 elapsed=$(( $after - $before ))
47 if [scip-shell system . . `[`. $elapsed -gt $max ]; then
48 echoscip-shell system . . echo. delay of $elapsed seconds after $attempts attempts
49 max=$elapsed
50 fi
51 done