2 # implements secret censoring for barf
3 # Copyright (C) 1999 Henry Spencer.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # RCSID $Id: _secretcensor,v 1.9 2002/04/01 23:36:50 mcr Exp $
17 usage="Usage: $0 [file ...]"
18 me="ipsec _secretcensor"
23 --help) echo "$usage" ; exit 0 ;;
24 --version) echo "$me $IPSEC_VERSION" ; exit 0 ;;
26 -*) echo "$0: unknown option \`$1'" >&2 ; exit 2 ;;
32 awk ' function cool(hot, q, cooled, run) {
33 # warning: may destroy input line!
34 q = "'"'"'" # single quote
36 return "[cannot be summed]"
38 return "[keyid " substr(hot, 3, 9) "]"
39 run = "echo " q hot q " | md5sum"
42 return "[sums to " substr($1, 1, 4) "...]"
45 i = match($0, /"[^"]+"/)
46 cold1 = substr($0, 1, i)
47 cold2 = substr($0, i+RLENGTH-1)
48 hot = substr($0, i+1, RLENGTH-2)
49 print cold1 cool(hot) cold2
53 i = match($0, /^.*#pubkey=/)
55 cold = substr($0, 1, i)
61 i = match($0, /^.*[ \t][^ \t]/)
63 cold = substr($0, 1, i)
65 print cold cool("0s" hot)
68 /^[ \t]+(Modulus|P[a-z]+Exponent|Prime[12]|Exponent[12]|Coefficient):/ {
69 i = match($0, /^[^:]*:[ \t]*/)
71 cold = substr($0, 1, i)