From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com []) by mx.groups.io with SMTP id smtpd.web11.4405.1583992343621109277 for ; Wed, 11 Mar 2020 22:52:25 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: jian.j.wang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2020 22:52:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,543,1574150400"; d="scan'208";a="236706526" Received: from shwdeopensfp777.ccr.corp.intel.com ([10.239.158.78]) by orsmga008.jf.intel.com with ESMTP; 11 Mar 2020 22:52:23 -0700 From: "Wang, Jian J" To: devel@edk2.groups.io Cc: Jiewen Yao , Chao Zhang , Nishant C Mistry Subject: [PATCH 1/3] SecurityPkg: add RpmcLib and VariableKeyLib public headers Date: Thu, 12 Mar 2020 13:52:19 +0800 Message-Id: <20200312055221.1781-2-jian.j.wang@intel.com> X-Mailer: git-send-email 2.24.0.windows.2 In-Reply-To: <20200312055221.1781-1-jian.j.wang@intel.com> References: <20200312055221.1781-1-jian.j.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2594 RpmcLib.h and VariableKeyLib.h are header files required to access RPMC device and Key generator from platform. They will be used to ensure the integrity and confidentiality of NV variables. Cc: Jiewen Yao Cc: Chao Zhang Cc: Nishant C Mistry Signed-off-by: Jian J Wang --- SecurityPkg/Include/Library/RpmcLib.h | 50 +++++++++++++++++ SecurityPkg/Include/Library/VariableKeyLib.h | 59 ++++++++++++++++++++ SecurityPkg/SecurityPkg.dec | 8 +++ 3 files changed, 117 insertions(+) create mode 100644 SecurityPkg/Include/Library/RpmcLib.h create mode 100644 SecurityPkg/Include/Library/VariableKeyLib.h diff --git a/SecurityPkg/Include/Library/RpmcLib.h b/SecurityPkg/Include/Li= brary/RpmcLib.h new file mode 100644 index 0000000000..c2e7d12f43 --- /dev/null +++ b/SecurityPkg/Include/Library/RpmcLib.h @@ -0,0 +1,50 @@ +/** @file=0D + Public definitions for the Replay Protected Monotonic Counter (RPMC) Lib= rary.=0D +=0D +Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef _RPMC_LIB_H_=0D +#define _RPMC_LIB_H_=0D +=0D +#include =0D +=0D +/**=0D + Requests the current monotonic counter from the designated RPMC counter.= =0D +=0D + @param[in] CounterIndex The RPMC index.=0D + @param[out] CounterValue A pointer to a buffer to store the= RPMC value.=0D +=0D + @retval EFI_SUCCESS The operation completed successful= ly.=0D + @retval EFI_INVALID_PARAMETER The CounterValue pointer is is NUL= L or CounterIndex is invalid.=0D + @retval EFI_NOT_READY The given RPMC at CounterIndex is = not yet initialized.=0D + @retval EFI_DEVICE_ERROR A device error occurred while atte= mpting to update the counter.=0D + @retval EFI_UNSUPPORTED Requesting the monotonic counter i= s not supported in the current boot configuration.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RequestMonotonicCounter (=0D + IN UINT8 CounterIndex,=0D + OUT UINT32 *CounterValue=0D + );=0D +=0D +/**=0D + Increments the designated monotonic counter in the SPI flash device by 1= .=0D +=0D + @param[in] CounterIndex The RPMC index.=0D +=0D + @retval EFI_SUCCESS The operation completed successful= ly.=0D + @retval EFI_INVALID_PARAMETER The given CounterIndex value is in= valid.=0D + @retval EFI_NOT_READY The given RPMC at CounterIndex is = not yet initialized.=0D + @retval EFI_DEVICE_ERROR A device error occurred while atte= mpting to update the counter.=0D + @retval EFI_UNSUPPORTED Incrementing the monotonic counter= is not supported in the current boot configuration.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +IncrementMonotonicCounter (=0D + IN UINT8 CounterIndex=0D + );=0D +=0D +#endif \ No newline at end of file diff --git a/SecurityPkg/Include/Library/VariableKeyLib.h b/SecurityPkg/Inc= lude/Library/VariableKeyLib.h new file mode 100644 index 0000000000..fe642b3d66 --- /dev/null +++ b/SecurityPkg/Include/Library/VariableKeyLib.h @@ -0,0 +1,59 @@ +/** @file=0D + Public definitions for Variable Key Library.=0D +=0D +Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef _VARIABLE_KEY_LIB_H_=0D +#define _VARIABLE_KEY_LIB_H_=0D +=0D +#include =0D +=0D +/**=0D + Retrieves the variable root key.=0D +=0D + @param[out] VariableRootKey A pointer to pointer for the var= iable root key buffer.=0D + @param[in,out] VariableRootKeySize The size in bytes of the variabl= e root key.=0D +=0D + @retval EFI_SUCCESS The variable root key was returned= .=0D + @retval EFI_DEVICE_ERROR An error occurred while attempting= to get the variable root key.=0D + @retval EFI_ACCESS_DENIED The function was invoked after loc= king the key interface.=0D + @retval EFI_UNSUPPORTED The variable root key is not suppo= rted in the current boot configuration.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +GetVariableRootKey (=0D + OUT VOID **VariableRootKey,=0D + IN OUT UINTN *VariableRootKeySize=0D + );=0D +=0D +/**=0D + Regenerates the variable root key.=0D +=0D + @retval EFI_SUCCESS The variable root key was regenera= ted successfully.=0D + @retval EFI_DEVICE_ERROR An error occurred while attempting= to regenerate the root key.=0D + @retval EFI_ACCESS_DENIED The function was invoked after loc= king the key interface.=0D + @retval EFI_UNSUPPORTED Key regeneration is not supported = in the current boot configuration.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RegenerateKey (=0D + VOID=0D + );=0D +=0D +/**=0D + Locks the regenerate key interface.=0D +=0D + @retval EFI_SUCCESS The key interface was locked succe= ssfully.=0D + @retval EFI_UNSUPPORTED Locking the key interface is not s= upported in the current boot configuration.=0D + @retval Others An error occurred while attempting= to lock the key interface.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +LockKeyInterface (=0D + VOID=0D + );=0D +=0D +#endif \ No newline at end of file diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec index 5335cc5397..2cdfb02cc5 100644 --- a/SecurityPkg/SecurityPkg.dec +++ b/SecurityPkg/SecurityPkg.dec @@ -76,6 +76,14 @@ #=0D TcgStorageOpalLib|Include/Library/TcgStorageOpalLib.h=0D =0D + ## @libraryclass Provides interfaces to access RPMC device.=0D + #=0D + RpmcLib|Include/Library/RpmcLib.h=0D +=0D + ## @libraryclass Provides interfaces to access variable root key.=0D + #=0D + VariableKeyLib|Include/Library/VariableKeyLib.h=0D +=0D [Guids]=0D ## Security package token space guid.=0D # Include/Guid/SecurityPkgTokenSpace.h=0D --=20 2.24.0.windows.2