This file is indexed.

/usr/bin/clevis-decrypt-tang is in clevis 8-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash -e
# vim: set tabstop=8 shiftwidth=4 softtabstop=4 expandtab smarttab colorcolumn=80:
#
# Copyright (c) 2017 Red Hat, Inc.
# Author: Nathaniel McCallum <npmccallum@redhat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

[ $# -eq 1 -a "$1" == "--summary" ] && exit 1

if [ -t 0 ]; then
    echo >&2
    echo "Usage: clevis decrypt tang < JWE > PLAINTEXT" >&2
    echo >&2
    exit 1
fi

read -d . hdr

if ! jhd=`jose b64 dec -i- <<< "$hdr"`; then
    echo "Error decoding JWE protected header!" >&2
    exit 1
fi

if [ "`jose fmt -j- -Og clevis -g pin -u- <<< "$jhd"`" != "tang" ]; then
    echo "JWE pin mismatch!" >&2
    exit 1
fi

if ! clt=`jose fmt -j- -Og epk -Oo- <<< "$jhd"`; then
    echo "JWE missing required 'epk' header parameter!" >&2
    exit 1
fi

if ! kid=`jose fmt -j- -Og kid -Su- <<< "$jhd"`; then
    echo "JWE missing required 'kid' header parameter!" >&2
    exit 1
fi

if ! srv=`jose fmt -j- -Og clevis -g tang -g adv -Oo- <<< "$jhd" \
        | jose jwk thp -i- -f "$kid"`; then
    echo "JWE missing required 'clevis.tang.adv' header parameter!" >&2
    exit 1
fi

if ! url=`jose fmt -j- -Og clevis -g tang -g url -Su- <<< "$jhd"`; then
    echo "JWE missing required 'clevis.tang.url' header parameter!" >&2
    exit 1
fi

if ! crv=`jose fmt -j- -Og crv -Su- <<< "$clt"`; then
    echo "Unable to determine EPK's curve!" >&2
    exit 1
fi

if ! eph=`jose jwk gen -i "{\"alg\":\"ECMR\",\"crv\":\"$crv\"}"`; then
    echo "Error generating ephemeral key!" >&2
    exit 1
fi

xfr=`jose jwk exc -i '{"alg":"ECMR"}' -l- -r- <<< "$clt$eph"`

url="$url/rec/$kid"
ct="Content-Type: application/jwk+json"
if ! rep=`curl -sfg -X POST -H "$ct" --data-binary @- "$url" <<< "$xfr"`; then
    echo "Error communicating with the server!" >&2
    exit 1
fi

if ! rep=`jose fmt -j- -Og kty -q EC -EUUg crv -q "$crv" -EUUo- <<< "$rep"`; then
    echo "Received invalid server reply!" >&2
    exit 1
fi

tmp=`jose jwk exc -i '{"alg":"ECMR"}' -l- -r- <<< "$eph$srv"`
rep=`jose jwk pub -i- <<< "$rep"`
jwk=`jose jwk exc -l- -r- <<< "$rep$tmp"`
exec jose jwe dec -k- -i- < <(echo -n "$jwk$hdr."; cat)