]> git.ipfire.org Git - people/ms/strongswan.git/blob - programs/_keycensor/_keycensor.in
- import of strongswan-2.7.0
[people/ms/strongswan.git] / programs / _keycensor / _keycensor.in
1 #! /bin/sh
2 # implements key censoring for barf
3 # Copyright (C) 1999, 2002 Henry Spencer.
4 #
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>.
9 #
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
13 # for more details.
14 #
15 # RCSID $Id: _keycensor.in,v 1.1 2004/03/15 20:35:27 as Exp $
16
17 usage="Usage: $0 [file ...]"
18 me="ipsec _keycensor"
19
20 for dummy
21 do
22 case "$1" in
23 --help) echo "$usage" ; exit 0 ;;
24 --version) echo "$me $IPSEC_VERSION" ; exit 0 ;;
25 --) shift ; break ;;
26 -*) echo "$0: unknown option \`$1'" >&2 ; exit 2 ;;
27 *) break ;;
28 esac
29 shift
30 done
31
32 awk ' /(sig|enc|auth)key[ \t]*=[ \t]*[^%]/ {
33 i = match($0, /key[ \t]*=[ \t]*/)
34 i += RLENGTH
35 cold = substr($0, 1, i-1)
36 hot = substr($0, i)
37 sub(/[ \t]+(#.*)?$/, "", hot)
38 q = "'"'"'" # single quote
39 if (hot ~ q)
40 cooled = "[cannot be condensed]"
41 else if (hot ~ /^0s/)
42 cooled = "[keyid " substr(hot, 3, 9) "]"
43 else {
44 run = "echo " q hot q " | md5sum"
45 run | getline
46 close(run)
47 cooled = "[sums to " substr($1, 1, 4) "...]"
48 }
49 print cold cooled
50 next
51 }
52 { print }' $*