securitycheck_fips.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include "internal/deprecated.h"
  10. #include <openssl/rsa.h>
  11. #include <openssl/dsa.h>
  12. #include <openssl/dh.h>
  13. #include <openssl/ec.h>
  14. #include <openssl/err.h>
  15. #include <openssl/proverr.h>
  16. #include <openssl/core_names.h>
  17. #include <openssl/obj_mac.h>
  18. #include "prov/securitycheck.h"
  19. int FIPS_security_check_enabled(OSSL_LIB_CTX *libctx);
  20. int ossl_securitycheck_enabled(OSSL_LIB_CTX *libctx)
  21. {
  22. #if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
  23. return FIPS_security_check_enabled(libctx);
  24. #else
  25. return 0;
  26. #endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
  27. }
  28. int ossl_digest_rsa_sign_get_md_nid(OSSL_LIB_CTX *ctx, const EVP_MD *md,
  29. int sha1_allowed)
  30. {
  31. #if !defined(OPENSSL_NO_FIPS_SECURITYCHECKS)
  32. if (ossl_securitycheck_enabled(ctx))
  33. return ossl_digest_get_approved_nid_with_sha1(ctx, md, sha1_allowed);
  34. #endif /* OPENSSL_NO_FIPS_SECURITYCHECKS */
  35. return ossl_digest_get_approved_nid(md);
  36. }