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