Coder Social home page Coder Social logo

libspdm's Introduction

libspdm is a sample implementation that follows the DMTF SPDM specifications

Features

  1. Specifications

    The SPDM and secured message libraries follow :

    DSP0274 Security Protocol and Data Model (SPDM) Specification (version 1.0.1, version 1.1.2 and version 1.2.1)

    DSP0277 Secured Messages using SPDM Specification (version 1.1.0)

    MCTP and secured MCTP follow :

    DSP0275 Security Protocol and Data Model (SPDM) over MCTP Binding Specification (version 1.0.0)

    DSP0276 Secured MCTP Messages over MCTP Binding Specification (version 1.0.0)

    PCIE follows :

    PCI Express Base Specification Revision 6.0 (version 1.0)

  2. Includes libraries that can be used to construct an SPDM Requester and an SPDM Responder.

  3. Programming Context

    The core libraries in libspdm/library require only the C99 freestanding headers and so are suitable for embedded and systems programming. Any functionality beyond the freestanding headers is provided by libspdm/os_stub or by the library's Integrator. All statically allocated memory in the core libraries is read-only. The core libraries do not dynamically allocate memory.

  4. Implemented Requests and Responses

    SPDM 1.0: GET_VERSION, GET_CAPABILITIES, NEGOTIATE_ALGORITHMS, GET_DIGESTS, GET_CERTIFICATE, CHALLENGE, and GET_MEASUREMENTS.

    SPDM 1.1: KEY_EXCHANGE, FINISH, PSK_EXCHANGE, PSK_FINISH, END_SESSION, HEARTBEAT, KEY_UPDATE, and ENCAPSULATED messages.

    SPDM 1.2: GET_CSR, SET_CERTIFICATE, CHUNK_SEND, and CHUNK_GET.

  5. Cryptographic Algorithm Support

    The SPDM library requires cryptolib API, including random number generation, symmetric cryptography, asymmetric cryptography, hash, and message authentication code.

    Currently supported algorithms: Hash:SHA2/SHA3/SM3, Signature:RSA-SSA/RSA-PSS/ECDSA/EdDSA/SM2-Sign, KeyExchange:FFDHE/ECDHE/SM2-KeyExchange, AEAD:AES_GCM/ChaCha20Poly1305/SM4_GCM. NOTE: NIST algorithms and Shang-Mi (SM) algorithms should not be mixed together.

    An Mbed TLS wrapper is included in cryptlib_mbedtls. NOTE: SMx and EdDSA are not supported.

    An OpenSSL wrapper is included in cryptlib_openssl. NOTE: SM2-KeyExchange and SM4_GCM are not supported.

  6. Execution Context

    Support to build an OS application for spdm_requester_emu and spdm_responder_emu to trace communication between Requester and Responder.

    Support to be included in UEFI host environment EDKII, such as edkii_spdm_requester

    Support to be included in OpenBMC. It is in planning, see SPDM Integration.

    Support to be linked by other language. For example, JAVA verifier.

  7. Supported Architecture and Cross-Compiler based on X64 platform.

Windows System ia32 x64 arm aarch64 riscv32 riscv64
VS2015 cl cl - - - -
VS2019 cl cl - - - -
VS2022 cl cl - - - -
ARM_DS2022 - - armclang armclang - -
GCC gcc gcc - - - -
CLANG clang-cl clang-cl - - - -
Linux System ia32 x64 arm aarch64 riscv32 riscv64
GCC gcc gcc - - - -
CLANG clang clang - - - -
ARM_DS2022 - - armclang armclang - -
ARM_GNU - - arm-none-linux-gnueabihf-gcc aarch64-none-linux-gnu-gcc - -
ARM_GNU_BARE_METAL - - arm-none-eabi aarch64-none-elf - -
ARM_GCC - - arm-linux-gnueabi-gcc - - -
AARCH64_GCC - - - aarch64-linux-gnu-gcc - -
RISCV_GNU - - - - riscv32-unknown-linux-gnu-gcc riscv64-unknown-linux-gnu-gcc
RISCV64_GCC - - - - - riscv64-linux-gnu-gcc
RISCV_XPACK - - - - riscv-none-elf-gcc riscv-none-elf-gcc

Documents

  1. Presentation

    Open Source Firmware Conference 2020 - openspdm

    Free and Open Source Developers European Meeting 2021 - openspdm

  2. Library Threat Model

    The user guide can be found at threat_model.

  3. Library Design

    The detailed design can be found at design.

  4. User Guide

    The user guide can be found at user_guide.

Prerequisites

Build Tools for Windows

  1. Compiler for IA32/X64 (Choose one)

    a) Visual Studio 2022, Visual Studio 2019, Visual Studio 2015

    b) LLVM (LLVM13)

    • Install LLVM-13.0.0-win64.exe. Change the LLVM install path to C:\LLVM, and add LLVM in PATH environment.
    • LLVM13 works good for clang and libfuzzer build. Other versions are not validated for clang build.
    • Because the libfuzzer lib path is hard coded in CMakeLists, other versions may fail for libfuzzer build.

For other architectures, refer to build.

  1. CMake (Version 3.17.2 is known to work. Newer versions may fail).

Build Tools for Linux

  1. Compiler for IA32/X64 (Choose one)

    a) GCC (above GCC5)

    b) LLVM (above LLVM10)

    • Install steps: sudo apt-get install llvm-10 then sudo apt-get install clang-10.
    • Use llvm-ar -version and clang -v to confirm the LLVM version.
    • If LLVM installation fails or LLVM installation version is low, you can update Linux version to fix the issue.

For other architectures, refer to build.

  1. CMake.

Cryptography Library

  1. Mbed TLS as cryptography library. Version 2.28.1.

  2. OpenSSL as cryptography library. Version 3.0.8.

Unit Test framework

  1. cmocka. Version 1.1.5.

Build

Git Submodule

libspdm uses submodules for Mbed TLS, OpenSSL, and cmocka.

To get a fully buildable repository, use git submodule update --init. If there is an update for submodules, use git submodule update.

Windows Builds for IA32/X64

For ia32 builds, use a x86 Native Tools Command Prompt for Visual Studio... command prompt.

For x64 builds, use a x64 Native Tools Command Prompt for Visual Studio... command prompt.

General build steps: (Note the .. at the end of the cmake command).

cd libspdm
mkdir build
cd build
cmake -G"NMake Makefiles" -DARCH=<x64|ia32> -DTOOLCHAIN=<VS2022|VS2019|VS2015|CLANG> -DTARGET=<Debug|Release> -DCRYPTO=<mbedtls|openssl> ..
nmake copy_sample_key
nmake

Example CMake commands:

cmake -G"NMake Makefiles" -DARCH=x64 -DTOOLCHAIN=VS2019 -DTARGET=Debug -DCRYPTO=mbedtls ..
cmake -G"NMake Makefiles" -DARCH=x64 -DTOOLCHAIN=VS2019 -DTARGET=Release -DCRYPTO=mbedtls ..
cmake -G"NMake Makefiles" -DARCH=x64 -DTOOLCHAIN=VS2019 -DTARGET=Debug -DCRYPTO=openssl ..
cmake -G"NMake Makefiles" -DARCH=x64 -DTOOLCHAIN=VS2019 -DTARGET=Release -DCRYPTO=openssl ..

Note ia32 build is not supported for CLANG build on Windows.

CMake can also generate Visual Studio project files. For example:

cmake -G"Visual Studio 16 2019" -DARCH=x64 -DTOOLCHAIN=VS2019 -DTARGET=Release -DCRYPTO=mbedtls ..

Support OpenSSL binary build. For example:

Note: Install the OpenSSL with command `nmake install` before build libspdm.
cmake -G"Visual Studio 16 2019" -DARCH=x64 -DTOOLCHAIN=VS2019 -DTARGET=Release -DCRYPTO=openssl -DENABLE_BINARY_BUILD=1 -DCOMPILED_LIBCRYPTO_PATH=<OPENSSL_PATH>/libcrypto.lib -DCOMPILED_LIBSSL_PATH=<OPENSSL_PATH>/libssl.lib ..

For other architectures, refer to build.

Linux Builds for IA32/X64

If ia32 builds run on a 64-bit Linux machine, then install sudo apt-get install gcc-multilib.

General build steps: (Note the .. at the end of the cmake command).

cd libspdm
mkdir build
cd build
cmake -DARCH=<x64|ia32|arm|aarch64|riscv32|riscv64|arc> -DTOOLCHAIN=<GCC|CLANG> -DTARGET=<Debug|Release> -DCRYPTO=<mbedtls|openssl> ..
make copy_sample_key
make

Example CMake commands:

cmake -DARCH=ia32 -DTOOLCHAIN=GCC -DTARGET=Debug -DCRYPTO=openssl ..
cmake -DARCH=ia32 -DTOOLCHAIN=GCC -DTARGET=Release -DCRYPTO=openssl ..
cmake -DARCH=arm -DTOOLCHAIN=GCC -DTARGET=Debug -DCRYPTO=openssl ..
cmake -DARCH=x64 -DTOOLCHAIN=CLANG -DTARGET=Release -DCRYPTO=mbedtls ..

Support OpenSSL binary build. For example:

Note: Install OpenSSL with command `sudo make install` before build libspdm.
cmake -DARCH=x64 -DTOOLCHAIN=GCC -DTARGET=Release -DCRYPTO=openssl -DENABLE_BINARY_BUILD=1 -DCOMPILED_LIBCRYPTO_PATH=<OPENSSL_PATH>/libcrypto.a -DCOMPILED_LIBSSL_PATH=<OPENSSL_PATH>/libssl.a ..

For other architectures, refer to build.

Run Test

The unit test output is at libspdm/build/bin. Open one command prompt at output dir to run test_spdm_requester > NUL and test_spdm_responder > NUL.

You should see something like:

      [==========] Running 2 test(s).
      [ RUN      ] test_spdm_responder_version_case1
      [       OK ] test_spdm_responder_version_case1
      [ RUN      ] test_spdm_responder_version_case2
      [       OK ] test_spdm_responder_version_case2
      [==========] 2 test(s) run.
      [  PASSED  ] 2 test(s).
   

Note: You must use a command prompt with the current working directory at libspdm/build/bin when running unit tests or they may fail. Eg. Don't run the unit tests from libsdpm/build directory by calling "bin/test_spdm_responder > NULL"

Other Tests

libspdm also supports other tests such as code coverage, fuzzing, symbolic execution, model checker.

Refer to test for more details.

Associated Repsositories

spdm-emu implements a full SPDM Requester and a full SPDM Responder using libspdm. It can be used to test a Requester or Responder implementation, or to see how libspdm can be integrated into a Requester or Responder implementation.

spdm-dump can be used to parse pcap files that capture SPDM traffic for offline analysis.

Features not implemented yet

  1. Refer to issues for more details.

Known limitations

This package is only the sample code to show the concept of SPDM and should not be considered fit for production. Any code including the API definition is subject to change.

libspdm's People

Contributors

jyao1 avatar steven-bellock avatar wenxing-hou avatar xiaohanjlll avatar richkong88 avatar qizhangz avatar zhiqiang520 avatar liyi77 avatar taprinz avatar xiangfeima avatar ekohandel avatar ecominetti avatar vinmaciel avatar liuw1 avatar yaohuixguo avatar kevv87 avatar raghuncstate avatar mct-sparky avatar robertkeyes avatar leetroy avatar alistair23 avatar alokprasad avatar lbbxsxlz avatar longlongyang avatar rw8896 avatar anasarif avatar shmarovfedor avatar jafarsarif10 avatar jklmnn avatar liron-himi-mvl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.