initrd_luks_pkcs/usr/share/decrypt_pkcs/pkcs15_get-key.sh

21 lines
498 B
Bash
Raw Normal View History

2021-04-11 14:29:58 +00:00
#!/bin/sh
. /etc/default/decrypt_pkcs
pkcs15-tool -c 2>/dev/null \
| awk '{ if ($1=="ID")
{nline++ ; printf $NF" "}
else if ($1=="Encoded" && $2=="serial")
{print $NF}}' \
| while read id serial ; do
if [ -f "${DECIPHER_MULTI_FOLDER}/${DECIPHER_MULTI_PATTERN}${serial}.enc" ] ; then
export key="${DECIPHER_MULTI_FOLDER}/${DECIPHER_MULTI_PATTERN}${serial}.enc"
export arg="-k ${id}"
echo ${key} ${arg}
exit 0
fi
done
exit 1