Commit | Line | Data |
---|---|---|
8e580e35 MW |
1 | ### -*-sh-*- |
2 | ### | |
3 | ### Key type for REOP | |
4 | ### | |
5 | ### (c) 2015 Mark Wooding | |
6 | ### | |
7 | ||
8 | ###----- Licensing notice --------------------------------------------------- | |
9 | ### | |
10 | ### This file is part of the distorted.org.uk key management suite. | |
11 | ### | |
12 | ### distorted-keys is free software; you can redistribute it and/or modify | |
13 | ### it under the terms of the GNU General Public License as published by | |
14 | ### the Free Software Foundation; either version 2 of the License, or | |
15 | ### (at your option) any later version. | |
16 | ### | |
17 | ### distorted-keys is distributed in the hope that it will be useful, | |
18 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ### GNU General Public License for more details. | |
21 | ### | |
22 | ### You should have received a copy of the GNU General Public License | |
23 | ### along with distorted-keys; if not, write to the Free Software Foundation, | |
24 | ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
25 | ||
26 | defprops k_props <<EOF | |
27 | identity t $R_LINE | |
28 | EOF | |
29 | ||
30 | : ${kprop_label=%{label\}} | |
31 | ||
32 | k_generate () { | |
33 | base=$1 nub=$2 | |
34 | ||
35 | ident=$(subst "\`identity' value" "$kprop_identity" kopt_ "$R_LINE") | |
36 | REOP_PASSPHRASE=$(cat "$nub") \ | |
37 | reop -G -i"$ident" -s"$base/sec" -p"$base/pub" | |
38 | } | |
39 | ||
40 | k_encrypt () { | |
41 | base=$1 | |
42 | ||
43 | reop -Gn -idistorted-keys.tmp -s$tmp/sec -p$tmp/ct | |
44 | reop -E -s$tmp/sec -p"$base/pub" -m- -x- >>$tmp/ct | |
45 | cat $tmp/ct | |
46 | } | |
47 | ||
48 | k_decrypt () { | |
49 | base=$1 nub=$2 | |
50 | ||
51 | sed -n " | |
52 | /^-----BEGIN REOP PUBLIC KEY-----\$/,/^-----END REOP PUBLIC KEY-----\$/ \ | |
53 | w $tmp/pub | |
54 | /^-----BEGIN REOP ENCRYPTED MESSAGE-----\$/,/^-----END REOP ENCRYPTED MESSAGE-----\$/ \ | |
55 | w $tmp/ct" | |
56 | REOP_PASSPHRASE=$(cat "$nub") \ | |
57 | reop -D -s"$base/sec" -p$tmp/pub -m- -x$tmp/ct | |
58 | } | |
59 | ||
60 | k_sign () { | |
61 | base=$1 nub=$2 | |
62 | ||
63 | REOP_PASSPHRASE=$(cat "$nub") \ | |
64 | reop -S -s"$base/sec" -m- -x- | |
65 | } | |
66 | ||
67 | k_verify () { | |
68 | base=$1 sig=$3 | |
69 | ||
70 | echo "$sig" >$tmp/sig | |
71 | reop -Vq -p"$base/pub" -m- -x$tmp/sig | |
72 | } | |
73 | ||
74 | ###----- That's all, folks -------------------------------------------------- |