From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com []) by mx.groups.io with SMTP id smtpd.web11.71234.1584374378715450970 for ; Mon, 16 Mar 2020 08:59:40 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: jian.j.wang@intel.com) IronPort-SDR: zHDgTc7LzwebGE8zHpbSDfKiWK2QI+jG/UVIqQB5APlKlfvKU9qsB9MHVATIBPBMISO+nZ1xDs 4skMK2xazeCw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2020 08:59:39 -0700 IronPort-SDR: joWZVvYhgZwoY4KN43I94Jcv6wgtEqsLKv9/tJ4U6H12AShYoqaBOx8wp6gEklfVXb8wRrW+fK owFy95oE/4CQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,561,1574150400"; d="scan'208";a="290736882" Received: from shwdeopensfp777.ccr.corp.intel.com ([10.239.158.78]) by FMSMGA003.fm.intel.com with ESMTP; 16 Mar 2020 08:59:38 -0700 From: "Wang, Jian J" To: devel@edk2.groups.io Cc: Jiewen Yao , Chao Zhang , Nishant C Mistry Subject: [PATCH v2 1/3] SecurityPkg: add RpmcLib and VariableKeyLib public headers Date: Mon, 16 Mar 2020 23:59:34 +0800 Message-Id: <20200316155936.2039-2-jian.j.wang@intel.com> X-Mailer: git-send-email 2.24.0.windows.2 In-Reply-To: <20200316155936.2039-1-jian.j.wang@intel.com> References: <20200316155936.2039-1-jian.j.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > v2: change CounterIndex to CounterId 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..bc25a0307b --- /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] CounterId Monotonic Counter Id.=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 CounterId is invalid.=0D + @retval EFI_NOT_READY The given RPMC at CounterId 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 CounterId,=0D + OUT UINT32 *CounterValue=0D + );=0D +=0D +/**=0D + Increments the designated monotonic counter in the SPI flash device by 1= .=0D +=0D + @param[in] CounterId Monotonic Counter Id.=0D +=0D + @retval EFI_SUCCESS The operation completed successful= ly.=0D + @retval EFI_INVALID_PARAMETER The given CounterId value is inval= id.=0D + @retval EFI_NOT_READY The given RPMC at CounterId 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 CounterId=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