Commit Graph

36 Commits

Author SHA1 Message Date
Antara Borwankar 55b0b75bb9 fix: [Stage1B] Extending correct cfg data and hash length in tpm
length of external config data and hash keys extended to the TPM was
incorrect. This commit fixes this issue.

Signed-off-by: Antara Borwankar <antara.borwankar@intel.com>
2024-04-24 11:07:35 -07:00
Bejean Mosher 028087e30d fix: Container header parsing failure in some cases.
GetContainerHeaderSize() parses header component entries to find the
offset of the end of the last component entry and checks this against
ContainerHdr->DataOffset. However, there is a valid case where this can
exactly equal to ContainerHdr->DataOffset, when the component alignment is
small enough and there is no component auth data (AuthType is none). This
check is changed to fail on greater than instead of greater or equal to
cover this case.

Signed-off-by: Bejean Mosher <bejean.mosher@intel.com>
2023-11-02 14:47:36 -07:00
Sean McGinn 0131ed6cbd Remove assert in ContainerLib
Convert assert in ContainerLib's GetContainerHeaderSize
to if statement as it breaks firmware update functionality

Signed-off-by: Sean McGinn <sean.mcginn@intel.com>
2023-08-16 12:00:11 -07:00
tsaikevin d952b1487c
fix: [Common] Fix Coverity issues (#1978)
Fixed Untrusted loop bound (CWE 606)

Signed-off-by: Kevin Tsai <kevin.tsai@intel.com>
2023-07-31 16:06:00 -07:00
Mike Crowe 990e3e81e6 Use LF line endings in the repository
Convert the line endings stored for all text files in the repository to
LF. The majority previously used DOS-style CRLF line endings. Add a
.gitattributes file to enforce this and treat certain extensions as
never being text files.

Update PatchCheck.py to insist on LF line endings rather than CRLF.
However, its other checks fail on this commit due to lots of
pre-existing complaints that it only notices because the line endings
have changed.

Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch
needs to be treated as binary since it contains a mixture of line
endings.

This change has implications depending on the client platform you are
using the repository from:

* Windows

The usual configuration for Git on Windows means that text files will
be checked out to the work tree with DOS-style CRLF line endings. If
that's not the case then you can configure Git to do so for the entire
machine with:

 git config --global core.autocrlf true

or for just the repository with:

 git config core.autocrlf true

Line endings will be normalised to LF when they are committed to the
repository. If you commit a text file with only LF line endings then it
will be converted to CRLF line endings in your work tree.

* Linux, MacOS and other Unices

The usual configuration for Git on such platforms is to check files out
of the repository with LF line endings. This is probably the right thing
for you. In the unlikely even that you are using Git on Unix but editing
or compiling on Windows for some reason then you may need to tweak your
configuration to force the use of CRLF line endings as described above.

* General

For more information see
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings .

Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400
Signed-off-by: Mike Crowe <mac@mcrowe.com>
2021-11-10 12:46:42 -08:00
Maurice Ma ae3ffa3ee8 Print Payload ID in human readable format
This patch printed Playload ID in human readable string format
instead of HEX string.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-05 17:04:20 -07:00
Maurice Ma 99332b68dc Fix new Klocwork scanning issues
This patch fixed some new reported klocwork scanning issues.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-08-25 09:57:23 -07:00
Sindhura Grandhi aeef6df940 Generate zero size dummy data in the Component Entry
This patch generate a component binary of zero size if not
already present.

Signed-off-by: Sindhura Grandhi <sindhura.grandhi@intel.com>
2020-08-24 14:41:35 -07:00
Subash Lakkimsetti 57c11052cd Check LocateComponentEntry outputs before its consumed
LocateComponentEntry is modified to locate only container
entry. Additional checks are required at consumer end
for Container entry and CompEntry.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-07-08 20:08:30 -07:00
Subash Lakkimsetti 99e4ba268c Initialize variables for container svn
Fix klocwork issues.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-07-06 10:32:06 -07:00
Subash Lakkimsetti ad839a3507 Container capsule update svn check
Add support for security version check for
container and its components with ones available
in flash for capsule updates.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-07-01 20:02:41 -07:00
Maurice Ma 0311566858 Use container format for key hash store
This patch converted key hash store in SBL image into container
format. In this way unified data structure can be used to
simplify code.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-06-16 11:20:12 -07:00
Maurice Ma e0c4326b81 Fixed several Klocwork scanning issue
Fixed several Klocwork issues reported for CFL build.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-05-28 09:43:12 -07:00
Maurice Ma fc6aa78708 Add OEM container verification support
Current SBL supports container header verification. If the container
signature is BOOT, it will use HASH_USAGE_PUBKEY_OS. Otherwise, it
will use HASH_USAGE_PUBKEY_CONTAINER_DEF. This patch added OEM signed
container support. If a container signature between OEM0 to OEM7 is
found, it will be verified use HASH_USAGE_PUBKEY_OEM(x) where x is 0
to 7. To add an OEM public key hash, it can be done by updating
pub_key_list in GetKeyHashList() in file BoardConfig.py.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-05-22 12:19:50 -07:00
Maurice Ma 86566d4196 Move container initialization earlier
Current container library cannot be used before memory is initialized
because the structure will only be initialized after memory. This
patch moved the initialization into Stage1A so that the library can be
used much earlier. The containers registered before memory will be
migrated into memory automatically post memory initialization. In this
way it avoids duplicated header authentication.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-04-24 08:06:05 -07:00
Subash Lakkimsetti 85617ef888
RSA PSS scheme in signing tools (#641)
Added an build config _SIGNING_SCHEME for
selection of signing schmemes. Updated tools
with param for selecting the signing scheme when
they are run in stand alone mode. Authtypes in
container are updated.

Supported Signing schemes - RSA_PCKS_1_5, RSA_PSS
Intel Crypto recommends PSS and same defaulted in
SlimBoot.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-04-10 17:25:58 -07:00
Vegnish Rao de49b23c7e
Fix Klockwork issue flagged in BootloaderCommonPkg (#646)
Fix for: Klockwork flags possible null pointer variable 'CompressHdr'
being dereferenced.

Signed-off-by: Vegnish Rao <vegnish.rao.paramesura.rao@intel.com>

Co-authored-by: Vegnish Rao <vegnish.rao.paramesura.rao@intel.com>
2020-04-07 17:22:24 -07:00
Vegnish Rao 02eb402864
Fix Klockwork issues flagged in BootloaderCommonPkg (#634)
Fix for: Klockwork flags variable 'CompLoc' for being used uninitialized.

Signed-off-by: Vegnish Rao <vegnish.rao.paramesura.rao@intel.com>

Co-authored-by: Vegnish Rao <vegnish.rao.paramesura.rao@intel.com>
2020-04-03 11:21:57 -07:00
Maurice Ma 72cb08ee7d Enable QEMU Stage1A boot in X64 mode (#621)
* [QEMU] Enable Stage1A boot in X64 mode

This patch added necessary changes to enable QEMU boot through
Stage1A in SBL X64 build.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>

* [QEMU] Enable QEMU Linux boot in X64 mode

This patch enabled SBL X64 boot for Linux. At this moment, since
FSP is still in 32 bit mode, it is required to thunk back into
32 bit mode to call FSP APIs.
It fixed #622.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-04-02 07:30:43 -07:00
Aiden Park 3ec0361920
Fix pointer type cast errors from Visual Studio (#617)
Visual Studio reports more pointer type cast errors with 64-bit build.
This will cover the issue on the existing targets.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-03-27 11:03:28 -07:00
Aiden Park 29446a1c2a
Pointer type cast for both 32/64-bit operation (#615)
This patch allows both 32/64-bit addressing properly.
- Pointer type cast with UINTN
- Add missing EFIAPI for APIs

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-03-26 17:30:55 -07:00
Subash Lakkimsetti d111dcb12a Measured boot update for Linux OS Image
Unified interface is added in TpmLib to extend stage and
OS Image digest. For Container OS Image this interface
is added as callback functionality. IAS image utilizes same
functionality to extend TPM digest.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-28 09:35:46 -07:00
Subash Lakkimsetti f9e542a72c Update firmware component stage hash extend
LoadComponentCallback is extended to perfom TPM extend
for firmware component stages. Component callback would be
invoked after authentication.

TpmExtendStageHash would extend hash based on hash validity.
TpmExtendConfigData is added to handle the Config data blob extend.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-13 08:30:45 -08:00
Subash Lakkimsetti 8a4289c110 Pass Hash Alg param for verifying hash data with RsaVerify
Hash verification of Public key hash should be based on
hash alg used with Hash store. Previously hash alg in
signature info is used. There would be instances where
hashstore hash alg differs from signing alg.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-09 13:26:04 -08:00
Subash Lakkimsetti 79abb75ed6 Enable RSA3072 and SHA384 signing support
This patch introduces support for RSA3K and SHA384 signing
And verifications support to Slimbootloader. Component hash
verification is done using PcdCompSignHashAlg.

To enable RSA3072 and SHA384,
 - Signing hash algorithm SIGN_HASH_TYPE should be set to SHA2_384
 - RSA3K private keys should be configured in platform board configs.
 - Set IPP_CRYPTO_ALG_MASK to include SHA2_384
 - Enable required IPP_CRYPTO_OPTIMIZATION_MASK
 - Default siging hash type is set to SHA2_256. Use hash type option
   while using the tools as Gencontainer, CfgDataTool in standalone
   mode.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2020-01-02 11:23:49 -07:00
Subash Lakkimsetti 71c64f40bd IPP Crypto and Secure boot lib to support multiple hashes
Hash and RSA signing parameters were hardcoded in
Crypto wrappers and secure boot libraries. This patch
address support for multiple hash and key sizes.

Signed-off-by: Subash Lakkimsetti <subashx.lakkimsetti@intel.com>
2019-12-12 08:13:04 -07:00
Maurice Ma df15627dd7 Enable updatable hash store component KEYH
Current SBL hash store has many limitations:
- Only support fixed hash size
- Only support 1:1 public key and usage mapping
- Only support build time key enrollment

This patch addressed this issue by introducing:
- Add a updatable KEYH component to hold extra key hash
- Allow append new hash entries from KEYH
- Use variable length entry for hash
- Introduce "Usage" bit mask for a key usage

This will allow using a single key to sign multiple components, or
using multiple keys to sign a single component. The built-in hash
store will only contain hash for STAGE1B, STAGE2, PAYLOAD,
PAYLOAD_FWU and MASTER public key hash. Master key hash will be used
to verify the KEYH component loaded at runtime in Stage1B. Once KEYH
is loaded, it will be appended into global hash store. The combined
hash store will be used to verify other components on the boot flow.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-12-10 19:19:04 -08:00
Subash Lakkimsetti 929bca6807 SecureBoot: Publickey and Signature data structure updates
This patch implements pubKey and signature updates done
in storage. Added info as sigining types, signing algo,
key sizes which could be used in secureboot and crypto
libraries.

Information from IASImage is transformed to updated
crypto and secure boot implementation. Only RSA2048 and sha256
support is updated as IAS image supports only this combination.

Signed-off-by: Subash Lakkimsetti <subashx.lakkimsetti@intel.com>
2019-12-10 11:42:23 -08:00
Aiden Park b24fd2759c Cosmetic: Convert LF to CRLF
This will fully support PatchCheck.py.
- Remove all trailing whitespace
- Convert LF to CRLF by default
- Update EFI_D_* to DEBUG_*
- Re-enable CRLF check in PatchCheck.py

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-12-02 16:21:19 -08:00
Maurice Ma 0087546e83 Misc Klocwork scanning fixes in BootloaderCommonPkg
This patches fixed several Klocwork scanning reports in
BootloaderCommonPkg.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-11-01 23:37:43 +08:00
Sai Talamudupula 709d7c1470 Support boot image from container
Add support to load the boot image from container.
Container must be signed using the same private key
as the key used to sign IAS (i.e. IAS_PRIVATE_KEY).

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-10-02 12:18:45 -07:00
Sai Talamudupula 1a7287881b Update ContainerLib
Add GetNextAvailableComponent() and authenticate the
components after registering them in CONTAINER_LIST.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-09-27 14:13:01 -07:00
Maurice Ma d2bd63df12 Allocate page aligned memory for component loading in container (#326)
To assist source level debug, it is better to always load PE/TE images
at page aligned memory address so that the script can locate the image
much easier. This patch changed the AllocatePool to AllocatePages for
component loading inside a container.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-09-23 09:19:27 -07:00
James Gutbub b0e390f1d3 Fix ContainerLib flash bug
There is a small bug in the ContainerLib
where the check for whether the data is
stored in the flash needs to be adjusted.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-08-15 14:03:46 -07:00
Maurice Ma ef682b19c3 Switch to use container for EPAYLOAD
This patch enabled container use case for EPAYLOAD loading.
It also switched to use LoadComponent() API for Stage2 and
payload loading. It simplified the code flow. An example in
QEMU was added to demonstrate on how to add a container in
build and load it in Stage2 code.

To define a container layout, it is required to provide
GetContainerList() in BoardConfig.py. Then in stage or payload
code, LoadComponent() can be used to load a component from the
container.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-01 15:58:25 -07:00
Maurice Ma 93b2e96d8e Add ContainerLib to support sub-region
This patch added a ContainerLib to support load and location a
component from a specified container. It copies the component
from flash to memory, authenticate it, and then decompress it if
required. It can also be used to support load component from flash
map in SBL stage2 or payload, such as payload or e-payload.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-07-31 09:32:00 -07:00