| 1 | /*++\r |
| 2 | \r |
| 3 | Copyright (c) 2006, Intel Corporation \r |
| 4 | All rights reserved. This program and the accompanying materials \r |
| 5 | are licensed and made available under the terms and conditions of the BSD License \r |
| 6 | which accompanies this distribution. The full text of the license may be found at \r |
| 7 | http://opensource.org/licenses/bsd-license.php \r |
| 8 | \r |
| 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
| 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r |
| 11 | \r |
| 12 | Module Name:\r |
| 13 | \r |
| 14 | SecurityStub.c\r |
| 15 | \r |
| 16 | Abstract:\r |
| 17 | \r |
| 18 | This driver supports platform security service\r |
| 19 | \r |
| 20 | --*/\r |
| 21 | \r |
| 22 | //\r |
| 23 | // Include common header file for this module.\r |
| 24 | //\r |
| 25 | #include "CommonHeader.h"\r |
| 26 | \r |
| 27 | #include "SecurityStub.h"\r |
| 28 | \r |
| 29 | //\r |
| 30 | // Handle for the Security Architectural Protocol instance produced by this driver\r |
| 31 | //\r |
| 32 | EFI_HANDLE mSecurityArchProtocolHandle = NULL;\r |
| 33 | \r |
| 34 | //\r |
| 35 | // Security Architectural Protocol instance produced by this driver\r |
| 36 | //\r |
| 37 | EFI_SECURITY_ARCH_PROTOCOL mSecurityStub = { \r |
| 38 | SecurityStubAuthenticateState \r |
| 39 | };\r |
| 40 | \r |
| 41 | //\r |
| 42 | // Worker functions\r |
| 43 | //\r |
| 44 | EFI_STATUS\r |
| 45 | EFIAPI\r |
| 46 | SecurityStubAuthenticateState (\r |
| 47 | IN EFI_SECURITY_ARCH_PROTOCOL *This,\r |
| 48 | IN UINT32 AuthenticationStatus,\r |
| 49 | IN EFI_DEVICE_PATH_PROTOCOL *File\r |
| 50 | )\r |
| 51 | /*++\r |
| 52 | \r |
| 53 | Routine Description:\r |
| 54 | \r |
| 55 | The EFI_SECURITY_ARCH_PROTOCOL (SAP) is used to abstract platform-specific \r |
| 56 | policy from the DXE core response to an attempt to use a file that returns a \r |
| 57 | given status for the authentication check from the section extraction protocol. \r |
| 58 | \r |
| 59 | The possible responses in a given SAP implementation may include locking \r |
| 60 | flash upon failure to authenticate, attestation logging for all signed drivers, \r |
| 61 | and other exception operations. The File parameter allows for possible logging \r |
| 62 | within the SAP of the driver.\r |
| 63 | \r |
| 64 | If File is NULL, then EFI_INVALID_PARAMETER is returned.\r |
| 65 | \r |
| 66 | If the file specified by File with an authentication status specified by \r |
| 67 | AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.\r |
| 68 | \r |
| 69 | If the file specified by File with an authentication status specified by \r |
| 70 | AuthenticationStatus is not safe for the DXE Core to use under any circumstances, \r |
| 71 | then EFI_ACCESS_DENIED is returned.\r |
| 72 | \r |
| 73 | If the file specified by File with an authentication status specified by \r |
| 74 | AuthenticationStatus is not safe for the DXE Core to use right now, but it \r |
| 75 | might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is \r |
| 76 | returned.\r |
| 77 | \r |
| 78 | Arguments:\r |
| 79 | \r |
| 80 | This - The EFI_SECURITY_ARCH_PROTOCOL instance.\r |
| 81 | \r |
| 82 | AuthenticationStatus - This is the authentication type returned from the Section \r |
| 83 | Extraction protocol. See the Section Extraction Protocol \r |
| 84 | Specification for details on this type.\r |
| 85 | \r |
| 86 | File - This is a pointer to the device path of the file that is \r |
| 87 | being dispatched. This will optionally be used for logging.\r |
| 88 | \r |
| 89 | Returns:\r |
| 90 | \r |
| 91 | EFI_SUCCESS - The file specified by File did authenticate, and the \r |
| 92 | platform policy dictates that the DXE Core may use File.\r |
| 93 | \r |
| 94 | EFI_INVALID_PARAMETER - File is NULL.\r |
| 95 | \r |
| 96 | EFI_SECURITY_VIOLATION - The file specified by File did not authenticate, and \r |
| 97 | the platform policy dictates that File should be placed \r |
| 98 | in the untrusted state. A file may be promoted from \r |
| 99 | the untrusted to the trusted state at a future time \r |
| 100 | with a call to the Trust() DXE Service.\r |
| 101 | \r |
| 102 | EFI_ACCESS_DENIED - The file specified by File did not authenticate, and \r |
| 103 | the platform policy dictates that File should not be \r |
| 104 | used for any purpose. \r |
| 105 | \r |
| 106 | --*/\r |
| 107 | {\r |
| 108 | if (File == NULL) {\r |
| 109 | return EFI_INVALID_PARAMETER;\r |
| 110 | }\r |
| 111 | \r |
| 112 | return EFI_SUCCESS;\r |
| 113 | }\r |
| 114 | \r |
| 115 | EFI_STATUS\r |
| 116 | EFIAPI\r |
| 117 | SecurityStubInitialize (\r |
| 118 | IN EFI_HANDLE ImageHandle,\r |
| 119 | IN EFI_SYSTEM_TABLE *SystemTable\r |
| 120 | )\r |
| 121 | /*++\r |
| 122 | \r |
| 123 | Routine Description:\r |
| 124 | \r |
| 125 | Initialize the state information for the Security Architectural Protocol\r |
| 126 | \r |
| 127 | Arguments:\r |
| 128 | \r |
| 129 | ImageHandle of the loaded driver\r |
| 130 | Pointer to the System Table\r |
| 131 | \r |
| 132 | Returns:\r |
| 133 | \r |
| 134 | Status\r |
| 135 | \r |
| 136 | EFI_SUCCESS - successful installation of the service\r |
| 137 | EFI_OUT_OF_RESOURCES - cannot allocate protocol data structure\r |
| 138 | EFI_DEVICE_ERROR - cannot create the timer service\r |
| 139 | \r |
| 140 | --*/\r |
| 141 | {\r |
| 142 | EFI_STATUS Status;\r |
| 143 | \r |
| 144 | //\r |
| 145 | // Make sure the Security Architectural Protocol is not already installed in the system\r |
| 146 | //\r |
| 147 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiSecurityArchProtocolGuid);\r |
| 148 | \r |
| 149 | //\r |
| 150 | // Install the Security Architectural Protocol onto a new handle\r |
| 151 | //\r |
| 152 | Status = gBS->InstallMultipleProtocolInterfaces (\r |
| 153 | &mSecurityArchProtocolHandle,\r |
| 154 | &gEfiSecurityArchProtocolGuid,\r |
| 155 | &mSecurityStub,\r |
| 156 | NULL\r |
| 157 | );\r |
| 158 | ASSERT_EFI_ERROR (Status);\r |
| 159 | \r |
| 160 | return Status;\r |
| 161 | }\r |