<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">I agree to change the function name to be more specific to avoid confusion, since this lib is intended<o:p></o:p></p>
<p class="MsoNormal">to be used for variable service only. I’ll send v5 soon.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Jian<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Yao, Jiewen <jiewen.yao@intel.com> <br>
<b>Sent:</b> Wednesday, March 25, 2020 5:55 PM<br>
<b>To:</b> Bret Barkelew <Bret.Barkelew@microsoft.com>; devel@edk2.groups.io; Wang, Jian J <jian.j.wang@intel.com><br>
<b>Cc:</b> Zhang, Chao B <chao.b.zhang@intel.com>; Mistry, Nishant C <nishant.c.mistry@intel.com><br>
<b>Subject:</b> RE: [EXTERNAL] [edk2-devel] [PATCH v4 1/3] SecurityPkg: add RpmcLib and VariableKeyLib public headers<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Good point.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I think the original design limits the usage to be variable driver. As such, the API only gets a “variable root key”.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">A “platform root key” can derive the “variable root key” and some “other features’ root key”.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The tricky part is to regenerate the key, when the variable is under attack.<o:p></o:p></p>
<p class="MsoNormal">In that case, we want to only regenerate the “variable root key”, instead of “platform root key”.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">That’s why we want to introduce a variablekeylib module.<o:p></o:p></p>
<p class="MsoNormal">To make API consistent, maybe we should rename GetVariableRootKey() to GetVariableKey(), RegenerateKey() to RegenerateVariableKey(), and LockKeyInterface() to LockVariableKeyInterface()<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If we really want to create a generic platformkeylib module, then we need add a key indicator. Such as:<o:p></o:p></p>
<p class="MsoNormal">EFI_STATUS<br>
EFIAPI<br>
GetPlatformKey (<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">  IN GUID   *KeyIndicator,<br>
  OUT VOID    **PlatformKey,<br>
  IN  OUT UINTN   *PlatformKeySize<br>
  );<o:p></o:p></p>
<p class="MsoNormal">Then the variable driver can pass a GUID, and any other feature driver can pass anther GUID.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you<o:p></o:p></p>
<p class="MsoNormal">Yao Jiewen<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Bret Barkelew <<a href="mailto:Bret.Barkelew@microsoft.com">Bret.Barkelew@microsoft.com</a>>
<br>
<b>Sent:</b> Wednesday, March 25, 2020 1:44 AM<br>
<b>To:</b> <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Wang, Jian J <<a href="mailto:jian.j.wang@intel.com">jian.j.wang@intel.com</a>><br>
<b>Cc:</b> Yao, Jiewen <<a href="mailto:jiewen.yao@intel.com">jiewen.yao@intel.com</a>>; Zhang, Chao B <<a href="mailto:chao.b.zhang@intel.com">chao.b.zhang@intel.com</a>>; Mistry, Nishant C <<a href="mailto:nishant.c.mistry@intel.com">nishant.c.mistry@intel.com</a>><br>
<b>Subject:</b> RE: [EXTERNAL] [edk2-devel] [PATCH v4 1/3] SecurityPkg: add RpmcLib and VariableKeyLib public headers<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is there a reason this needs to be called “VariableKeyLib” rather than any other “KeyLib”? It seems general-purpose as an interface.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- Bret<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black">
<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a> <<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>> on behalf of Wang, Jian J via Groups.Io <<a href="mailto:jian.j.wang=intel.com@groups.io">jian.j.wang=intel.com@groups.io</a>><br>
<b>Sent:</b> Monday, March 23, 2020 11:35:21 PM<br>
<b>To:</b> <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a> <<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>><br>
<b>Cc:</b> Jiewen Yao <<a href="mailto:jiewen.yao@intel.com">jiewen.yao@intel.com</a>>; Chao Zhang <<a href="mailto:chao.b.zhang@intel.com">chao.b.zhang@intel.com</a>>; Nishant C Mistry <<a href="mailto:nishant.c.mistry@intel.com">nishant.c.mistry@intel.com</a>><br>
<b>Subject:</b> [EXTERNAL] [edk2-devel] [PATCH v4 1/3] SecurityPkg: add RpmcLib and VariableKeyLib public headers</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">> v4: remove CounterId which should not be exposed<br>
<br>
REF: <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2594&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C3e34ac4a40d94c82e86b08d7cfbd8b82%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206285305504454&amp;sdata=wCxxsc6cc%2Ffduq88XOZOZv6debpAQMZiIdsFjD0zHXE%3D&amp;reserved=0">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2594&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C3e34ac4a40d94c82e86b08d7cfbd8b82%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206285305504454&amp;sdata=wCxxsc6cc%2Ffduq88XOZOZv6debpAQMZiIdsFjD0zHXE%3D&amp;reserved=0</a><br>
<br>
RpmcLib.h and VariableKeyLib.h are header files required to access RPMC<br>
device and Key generator from platform. They will be used to ensure the<br>
integrity and confidentiality of NV variables.<br>
<br>
Cc: Jiewen Yao <<a href="mailto:jiewen.yao@intel.com">jiewen.yao@intel.com</a>><br>
Cc: Chao Zhang <<a href="mailto:chao.b.zhang@intel.com">chao.b.zhang@intel.com</a>><br>
Cc: Nishant C Mistry <<a href="mailto:nishant.c.mistry@intel.com">nishant.c.mistry@intel.com</a>><br>
Signed-off-by: Jian J Wang <<a href="mailto:jian.j.wang@intel.com">jian.j.wang@intel.com</a>><br>
---<br>
 SecurityPkg/Include/Library/RpmcLib.h        | 42 ++++++++++++++<br>
 SecurityPkg/Include/Library/VariableKeyLib.h | 59 ++++++++++++++++++++<br>
 SecurityPkg/SecurityPkg.dec                  |  8 +++<br>
 3 files changed, 109 insertions(+)<br>
 create mode 100644 SecurityPkg/Include/Library/RpmcLib.h<br>
 create mode 100644 SecurityPkg/Include/Library/VariableKeyLib.h<br>
<br>
diff --git a/SecurityPkg/Include/Library/RpmcLib.h b/SecurityPkg/Include/Library/RpmcLib.h<br>
new file mode 100644<br>
index 0000000000..8e3868516c<br>
--- /dev/null<br>
+++ b/SecurityPkg/Include/Library/RpmcLib.h<br>
@@ -0,0 +1,42 @@<br>
+/** @file<br>
<br>
+  Public definitions for the Replay Protected Monotonic Counter (RPMC) Library.<br>
<br>
+<br>
<br>
+Copyright (c) 2020, Intel Corporation. All rights reserved.<BR><br>
<br>
+SPDX-License-Identifier: BSD-2-Clause-Patent<br>
<br>
+<br>
<br>
+**/<br>
<br>
+<br>
<br>
+#ifndef _RPMC_LIB_H_<br>
<br>
+#define _RPMC_LIB_H_<br>
<br>
+<br>
<br>
+#include <Uefi/UefiBaseType.h><br>
<br>
+<br>
<br>
+/**<br>
<br>
+  Requests the monotonic counter from the designated RPMC counter.<br>
<br>
+<br>
<br>
+  @param[out]   CounterValue            A pointer to a buffer to store the RPMC value.<br>
<br>
+<br>
<br>
+  @retval       EFI_SUCCESS             The operation completed successfully.<br>
<br>
+  @retval       EFI_DEVICE_ERROR        A device error occurred while attempting to update the counter.<br>
<br>
+  @retval       EFI_UNSUPPORTED         The operation is un-supported.<br>
<br>
+**/<br>
<br>
+EFI_STATUS<br>
<br>
+EFIAPI<br>
<br>
+RequestMonotonicCounter (<br>
<br>
+  OUT UINT32  *CounterValue<br>
<br>
+  );<br>
<br>
+<br>
<br>
+/**<br>
<br>
+  Increments the monotonic counter in the SPI flash device by 1.<br>
<br>
+<br>
<br>
+  @retval       EFI_SUCCESS             The operation completed successfully.<br>
<br>
+  @retval       EFI_DEVICE_ERROR        A device error occurred while attempting to update the counter.<br>
<br>
+  @retval       EFI_UNSUPPORTED         The operation is un-supported.<br>
<br>
+**/<br>
<br>
+EFI_STATUS<br>
<br>
+EFIAPI<br>
<br>
+IncrementMonotonicCounter (<br>
<br>
+  VOID<br>
<br>
+  );<br>
<br>
+<br>
<br>
+#endif<br>
\ No newline at end of file<br>
diff --git a/SecurityPkg/Include/Library/VariableKeyLib.h b/SecurityPkg/Include/Library/VariableKeyLib.h<br>
new file mode 100644<br>
index 0000000000..fe642b3d66<br>
--- /dev/null<br>
+++ b/SecurityPkg/Include/Library/VariableKeyLib.h<br>
@@ -0,0 +1,59 @@<br>
+/** @file<br>
<br>
+  Public definitions for Variable Key Library.<br>
<br>
+<br>
<br>
+Copyright (c) 2020, Intel Corporation. All rights reserved.<BR><br>
<br>
+SPDX-License-Identifier: BSD-2-Clause-Patent<br>
<br>
+<br>
<br>
+**/<br>
<br>
+<br>
<br>
+#ifndef _VARIABLE_KEY_LIB_H_<br>
<br>
+#define _VARIABLE_KEY_LIB_H_<br>
<br>
+<br>
<br>
+#include <Uefi/UefiBaseType.h><br>
<br>
+<br>
<br>
+/**<br>
<br>
+  Retrieves the variable root key.<br>
<br>
+<br>
<br>
+  @param[out]     VariableRootKey         A pointer to pointer for the variable root key buffer.<br>
<br>
+  @param[in,out]  VariableRootKeySize     The size in bytes of the variable root key.<br>
<br>
+<br>
<br>
+  @retval       EFI_SUCCESS             The variable root key was returned.<br>
<br>
+  @retval       EFI_DEVICE_ERROR        An error occurred while attempting to get the variable root key.<br>
<br>
+  @retval       EFI_ACCESS_DENIED       The function was invoked after locking the key interface.<br>
<br>
+  @retval       EFI_UNSUPPORTED         The variable root key is not supported in the current boot configuration.<br>
<br>
+**/<br>
<br>
+EFI_STATUS<br>
<br>
+EFIAPI<br>
<br>
+GetVariableRootKey (<br>
<br>
+      OUT VOID    **VariableRootKey,<br>
<br>
+  IN  OUT UINTN   *VariableRootKeySize<br>
<br>
+  );<br>
<br>
+<br>
<br>
+/**<br>
<br>
+  Regenerates the variable root key.<br>
<br>
+<br>
<br>
+  @retval       EFI_SUCCESS             The variable root key was regenerated successfully.<br>
<br>
+  @retval       EFI_DEVICE_ERROR        An error occurred while attempting to regenerate the root key.<br>
<br>
+  @retval       EFI_ACCESS_DENIED       The function was invoked after locking the key interface.<br>
<br>
+  @retval       EFI_UNSUPPORTED         Key regeneration is not supported in the current boot configuration.<br>
<br>
+**/<br>
<br>
+EFI_STATUS<br>
<br>
+EFIAPI<br>
<br>
+RegenerateKey (<br>
<br>
+  VOID<br>
<br>
+  );<br>
<br>
+<br>
<br>
+/**<br>
<br>
+  Locks the regenerate key interface.<br>
<br>
+<br>
<br>
+  @retval       EFI_SUCCESS             The key interface was locked successfully.<br>
<br>
+  @retval       EFI_UNSUPPORTED         Locking the key interface is not supported in the current boot configuration.<br>
<br>
+  @retval       Others                  An error occurred while attempting to lock the key interface.<br>
<br>
+**/<br>
<br>
+EFI_STATUS<br>
<br>
+EFIAPI<br>
<br>
+LockKeyInterface (<br>
<br>
+  VOID<br>
<br>
+  );<br>
<br>
+<br>
<br>
+#endif<br>
\ No newline at end of file<br>
diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec<br>
index 5335cc5397..2cdfb02cc5 100644<br>
--- a/SecurityPkg/SecurityPkg.dec<br>
+++ b/SecurityPkg/SecurityPkg.dec<br>
@@ -76,6 +76,14 @@<br>
   #<br>
<br>
   TcgStorageOpalLib|Include/Library/TcgStorageOpalLib.h<br>
<br>
 <br>
<br>
+  ## @libraryclass  Provides interfaces to access RPMC device.<br>
<br>
+  #<br>
<br>
+  RpmcLib|Include/Library/RpmcLib.h<br>
<br>
+<br>
<br>
+  ## @libraryclass  Provides interfaces to access variable root key.<br>
<br>
+  #<br>
<br>
+  VariableKeyLib|Include/Library/VariableKeyLib.h<br>
<br>
+<br>
<br>
 [Guids]<br>
<br>
   ## Security package token space guid.<br>
<br>
   # Include/Guid/SecurityPkgTokenSpace.h<br>
<br>
-- <br>
2.24.0.windows.2<br>
<br>
<br>
-=-=-=-=-=-=<br>
Groups.io Links: You receive all messages sent to this group.<br>
<br>
View/Reply Online (#56132): <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F56132&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C3e34ac4a40d94c82e86b08d7cfbd8b82%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206285305514447&amp;sdata=CoBs9mwnHTAAZiErAEHS3E7dbdRd%2FZefJPKXKPmJwfc%3D&amp;reserved=0">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F56132&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C3e34ac4a40d94c82e86b08d7cfbd8b82%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206285305514447&amp;sdata=CoBs9mwnHTAAZiErAEHS3E7dbdRd%2FZefJPKXKPmJwfc%3D&amp;reserved=0</a><br>
Mute This Topic: <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.io%2Fmt%2F72512084%2F1852292&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C3e34ac4a40d94c82e86b08d7cfbd8b82%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206285305514447&amp;sdata=%2B14%2BIfGmu88GSnKZnpb51EGaW3MqfFCT1%2BWI5Bhdlo0%3D&amp;reserved=0">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.io%2Fmt%2F72512084%2F1852292&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C3e34ac4a40d94c82e86b08d7cfbd8b82%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206285305514447&amp;sdata=%2B14%2BIfGmu88GSnKZnpb51EGaW3MqfFCT1%2BWI5Bhdlo0%3D&amp;reserved=0</a><br>
Group Owner: <a href="mailto:devel+owner@edk2.groups.io">devel+owner@edk2.groups.io</a><br>
Unsubscribe: <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C3e34ac4a40d94c82e86b08d7cfbd8b82%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206285305514447&amp;sdata=JLLWLjx0OW0eTjn7xXG5aNHdAfWQqhY4qLXSuNhhcys%3D&amp;reserved=0">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C3e34ac4a40d94c82e86b08d7cfbd8b82%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206285305514447&amp;sdata=JLLWLjx0OW0eTjn7xXG5aNHdAfWQqhY4qLXSuNhhcys%3D&amp;reserved=0</a> 
 [bret.barkelew@microsoft.com]<br>
-=-=-=-=-=-=<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>


You receive all messages sent to this group.



<p>

<a target="_blank" href="https://edk2.groups.io/g/devel/message/56369">View/Reply Online (#56369)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/72522973/1813853">Mute This Topic</a>
  

| <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>



<br>

<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>