#
#   Copyright (C) 2022, 2023 SUSE LLC
#
#   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 2 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, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#   Written by Olaf Kirch <okir@suse.com>

alias cmd_requires_luks_device=false
alias cmd_perform=cmd_tpm_authorize

function cmd_tpm_authorize {

    if [ -z "$FDE_AUTHORIZED_POLICY" ]; then
	display_errorbox "Cannot authorize PCR policy, no authorized policy defined"
	exit 1
    fi

    tpm_set_authorized_policy_paths "$FDE_AUTHORIZED_POLICY"
    bootloader_authorize_pcr_policy "$FDE_AP_SECRET_KEY" "$FDE_AP_SEALED_SECRET"
}
