@@ -163,6 +163,7 @@ clevis_luks_decode_jwe() {
163
163
clevis_luks_print_pin_config () {
164
164
local P=" ${1} "
165
165
local decoded=" ${2} "
166
+ local THP=" ${3} "
166
167
167
168
local content
168
169
if ! content=" $( jose fmt -j- -g clevis -g " ${P} " -o- <<< " ${decoded}" ) " \
@@ -173,9 +174,15 @@ clevis_luks_print_pin_config() {
173
174
local pin=
174
175
case " ${P} " in
175
176
tang)
176
- local url
177
+ local url adv thp
177
178
url=" $( jose fmt -j- -g url -u- <<< " ${content}" ) "
178
- pin=$( printf ' {"url":"%s"}' " ${url} " )
179
+ if [ -z " ${THP} " ]; then
180
+ pin=$( printf ' {"url":"%s"}' " ${url} " )
181
+ else
182
+ adv=" $( jose fmt -j- -g adv -o- <<< " ${content}" ) "
183
+ thp=" $( jose jwk thp -i- <<< " ${adv}" | tail -n1) "
184
+ pin=$( printf ' {"url":"%s","thp":"%s"}' " ${url} " " ${thp} " )
185
+ fi
179
186
printf " tang '%s'" " ${pin} "
180
187
;;
181
188
tpm2)
@@ -195,7 +202,7 @@ clevis_luks_print_pin_config() {
195
202
sss)
196
203
local threshold
197
204
threshold=$( jose fmt -j- -Og t -o- <<< " ${content}" )
198
- clevis_luks_process_sss_pin " ${content} " " ${threshold} "
205
+ clevis_luks_process_sss_pin " ${content} " " ${threshold} " " ${THP} "
199
206
;;
200
207
* )
201
208
printf " unknown pin '%s'" " ${P} "
@@ -207,6 +214,7 @@ clevis_luks_print_pin_config() {
207
214
# from it.
208
215
clevis_luks_decode_pin_config () {
209
216
local jwe=" ${1} "
217
+ local THP=" ${2} "
210
218
211
219
local decoded
212
220
if ! decoded=$( clevis_luks_decode_jwe " ${jwe} " ) ; then
@@ -218,7 +226,7 @@ clevis_luks_decode_pin_config() {
218
226
return 1
219
227
fi
220
228
221
- clevis_luks_print_pin_config " ${P} " " ${decoded} "
229
+ clevis_luks_print_pin_config " ${P} " " ${decoded} " " ${THP} "
222
230
}
223
231
224
232
# clevis_luks_join_sss_cfg() will receive a list of configurations for a given
@@ -235,6 +243,7 @@ clevis_luks_join_sss_cfg() {
235
243
clevis_luks_process_sss_pin () {
236
244
local jwe=" ${1} "
237
245
local threshold=" ${2} "
246
+ local THP=" ${3} "
238
247
239
248
local sss_tang
240
249
local sss_tpm2
@@ -245,7 +254,7 @@ clevis_luks_process_sss_pin() {
245
254
246
255
local coded
247
256
for coded in $( jose fmt -j- -Og jwe -Af- <<< " ${jwe}" | tr -d ' "' ) ; do
248
- if ! pin_cfg=" $( clevis_luks_decode_pin_config " ${coded} " ) " ; then
257
+ if ! pin_cfg=" $( clevis_luks_decode_pin_config " ${coded} " " ${THP} " ) " ; then
249
258
continue
250
259
fi
251
260
read -r pin cfg <<< " ${pin_cfg}"
@@ -286,14 +295,15 @@ clevis_luks_process_sss_pin() {
286
295
clevis_luks_read_pins_from_slot () {
287
296
local DEV=" ${1} "
288
297
local SLOT=" ${2} "
298
+ local THP=" ${3} "
289
299
290
300
local jwe
291
301
if ! jwe=$( clevis_luks_read_slot " ${DEV} " " ${SLOT} " 2> /dev/null) ; then
292
302
return 1
293
303
fi
294
304
295
305
local cfg
296
- if ! cfg=" $( clevis_luks_decode_pin_config " ${jwe} " ) " ; then
306
+ if ! cfg=" $( clevis_luks_decode_pin_config " ${jwe} " " ${THP} " ) " ; then
297
307
return 1
298
308
fi
299
309
printf " %s: %s\n" " ${SLOT} " " ${cfg} "
0 commit comments