Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more check for supported algorithm #1581

Merged
merged 2 commits into from
Jan 17, 2023

Conversation

Wenxing-hou
Copy link
Contributor

Signed-off-by: Wenxing Hou [email protected]

include/internal/libspdm_macro_check.h Outdated Show resolved Hide resolved
include/internal/libspdm_macro_check.h Outdated Show resolved Hide resolved
#define LIBSPDM_FIPS_SIGNATURE_ALGO \
((LIBSPDM_RSA_SSA_SUPPORT) || (LIBSPDM_RSA_PSS_SUPPORT) || (LIBSPDM_ECDSA_SUPPORT))

#define LIBSPDM_FIPS_DHE_ALGO ((LIBSPDM_FFDHE_SUPPORT) || (LIBSPDM_ECDHE_SUPPORT))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some (most) of these algorithms are conditional on the endpoint's capabilities. For example if an endpoint does not support asymmetric key exchange then LIBSPDM_FIPS_DHE_ALGO can be 0 / false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I have deleted the LIBSPDM_FIPS_DHE_ALGO check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we follow the capability, we should remove LIBSPDM_FIPS_AEAD_ALGO as well, since it is not required in authentication only use case.

We should remove LIBSPDM_FIPS_SIGNATURE_ALGO as well, since it is not required in PSK use case.

Then we only need LIBSPDM_FIPS_HASH_ALGO.

However, that at least one bit set according to capability should be enforced by the logic in https://github.com/DMTF/libspdm/blob/main/include/internal/libspdm_macro_check.h.
I dont think it is related to FIPS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my suggestion:

  1. We should improve the algo check with capability in https://github.com/DMTF/libspdm/blob/main/include/internal/libspdm_macro_check.h. E.g LIBSPDM_HASH_ALGO_SUPPORT is missing, LIBSPDM_AEAD_ALGO_SUPPORT is missing.

  2. We dont need LIBSPDM_FIPS_xxx_ALGO, because at least one bit rule is already applied.

This should be a generic algo check, not specific FIPS algo check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I have added the LIBSPDM_HASH_ALGO_SUPPORT and LIBSPDM_AEAD_ALGO_SUPPORT.
But for LIBSPDM_AEAD_ALGO_SUPPORT, I don't know how to add the check.

@steven-bellock steven-bellock added enhancement New feature or request security An issue that impacts security labels Jan 5, 2023
@steven-bellock steven-bellock added this to the Q1 2023 milestone Jan 5, 2023
@Wenxing-hou Wenxing-hou force-pushed the add_check_for_FIPS_approved_algo branch 3 times, most recently from 94534ae to 963ed0c Compare January 9, 2023 08:43
@Wenxing-hou Wenxing-hou changed the title Add check that at least one FIPS algorithm is supported Add more check for supported algorithm Jan 9, 2023
@@ -30,6 +39,10 @@
#error If KEY_EX_CAP is enabled then at least one DHE algorithm must also be enabled.
#endif

#if !LIBSPDM_HASH_ALGO_SUPPORT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is valid use case that if SPDM only supports unsigned measurement with raw bit stream.

@jyao1
Copy link
Member

jyao1 commented Jan 15, 2023

It has been a while since we discuss this. I recommend:

  1. For AEAD:
#if (LIBSPDM_ENABLE_CAPABILITY_KEY_EX_CAP) && !LIBSPDM_AEAD_ALGO_SUPPORT
    #error If KEY_EX_CAP is enabled then at least one AEAD algorithm must also be enabled.
#endif

#if (LIBSPDM_ENABLE_CAPABILITY_PSK_EX_CAP) && !LIBSPDM_AEAD_ALGO_SUPPORT
    #error If PSK_EX_CAP is enabled then at least one AEAD algorithm must also be enabled.
#endif
  1. For HASH:
#if (LIBSPDM_ENABLE_CAPABILITY_CERT_CAP) && !LIBSPDM_HASH_ALGO_SUPPORT
    #error If CERT_CAP is enabled then at least one HASH algorithm must also be enabled.
#endif

#if (LIBSPDM_ENABLE_CAPABILITY_CHAL_CAP) && !LIBSPDM_HASH_ALGO_SUPPORT
    #error If CHAL_CAP is enabled then at least one HASH algorithm must also be enabled.
#endif

#if (LIBSPDM_ENABLE_CAPABILITY_KEY_EX_CAP) && !LIBSPDM_HASH_ALGO_SUPPORT
    #error If KEY_EX_CAP is enabled then at least one HASH algorithm must also be enabled.
#endif

#if (LIBSPDM_ENABLE_CAPABILITY_PSK_EX_CAP) && !LIBSPDM_HASH_ALGO_SUPPORT
    #error If PSK_EX_CAP is enabled then at least one HASH algorithm must also be enabled.
#endif

NOTE:

  1. If fail, we know something is wrong.
  2. If pass, we still not know if everything is correct, because the information is not enough.

@jyao1
Copy link
Member

jyao1 commented Jan 15, 2023

For FIPS specific check as addition, I think we can do following:

/* 1. Collect info before FIPS */
#if LIBSPDM_FIPS_MODE
#define LIBSPDM_ASYM_ALGO_SUPPORT \
    ((LIBSPDM_RSA_SSA_SUPPORT) || (LIBSPDM_RSA_PSS_SUPPORT) || (LIBSPDM_ECDSA_SUPPORT) || \
     (LIBSPDM_SM2_DSA_SUPPORT) || (LIBSPDM_EDDSA_ED25519_SUPPORT) || (LIBSPDM_EDDSA_ED448_SUPPORT))

#define LIBSPDM_DHE_ALGO_SUPPORT \
    ((LIBSPDM_FFDHE_SUPPORT) || (LIBSPDM_ECDHE_SUPPORT) || (LIBSPDM_SM2_KEY_EXCHANGE_SUPPORT))

#define LIBSPDM_AEAD_ALGO_SUPPORT ...

#define LIBSPDM_HASH_ALGO_SUPPORT ...
#endif /*LIBSPDM_FIPS_MODE*/

/* 2. Enforce FIPS algo */
#if LIBSPDM_FIPS_MODE
#undef LIBSPDM_SM2_DSA_SUPPORT
#define LIBSPDM_SM2_DSA_SUPPORT 0
......
#endif /*LIBSPDM_FIPS_MODE*/

/* 3. Collect info and check after FIPS enforcement */
#if LIBSPDM_FIPS_MODE
#define LIBSPDM_FIPS_ASYM_ALGO_SUPPORT \
    ((LIBSPDM_RSA_SSA_SUPPORT) || (LIBSPDM_RSA_PSS_SUPPORT) || (LIBSPDM_ECDSA_SUPPORT))

#define LIBSPDM_FIPS_DHE_ALGO_SUPPORT \
    ((LIBSPDM_FFDHE_SUPPORT) || (LIBSPDM_ECDHE_SUPPORT))

#define LIBSPDM_FIPS_AEAD_ALGO_SUPPORT ...

#define LIBSPDM_FIPS_HASH_ALGO_SUPPORT ...
#endif /*LIBSPDM_FIPS_MODE*/

/* 4. Check FIPS algo after enforcement*/
#if LIBSPDM_FIPS_MODE
#if (LIBSPDM_ASYM_ALGO_SUPPORT) && !LIBSPDM_FIPS_ASYM_ALGO_SUPPORT
    #error ASYM algo is cleared after FIPS enforcement.
#endif

#if (LIBSPDM_DHE_ALGO_SUPPORT) && !LIBSPDM_FIPS_DHE_ALGO_SUPPORT
    #error DHE algo is cleared after FIPS enforcement.
#endif

#if (LIBSPDM_AEAD_ALGO_SUPPORT) && !LIBSPDM_FIPS_AEAD_ALGO_SUPPORT
    #error AEAD algo is cleared after FIPS enforcement.
#endif

#if (LIBSPDM_HASH_ALGO_SUPPORT) && !LIBSPDM_FIPS_HASH_ALGO_SUPPORT
    #error HASH algo is cleared after FIPS enforcement.
#endif

#endif /*LIBSPDM_FIPS_MODE*/

#endif

@Wenxing-hou Wenxing-hou force-pushed the add_check_for_FIPS_approved_algo branch 2 times, most recently from 1876528 to 82bcabe Compare January 15, 2023 14:50
@Wenxing-hou Wenxing-hou force-pushed the add_check_for_FIPS_approved_algo branch from 82bcabe to 04a7dfa Compare January 16, 2023 01:24
@Wenxing-hou
Copy link
Contributor Author

Thanks. I have added the check for generic algo support and FIPS approved algo.
But I think the DHE_algo need to be AEAD_algo. It is a typo error.

image

@jyao1 jyao1 merged commit f59b5cb into DMTF:main Jan 17, 2023
@Wenxing-hou Wenxing-hou deleted the add_check_for_FIPS_approved_algo branch March 23, 2023 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request security An issue that impacts security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants