xref: /netbsd-src/crypto/external/bsd/openssl/dist/providers/common/securitycheck_default.c (revision b0d1725196a7921d003d2c66a14f186abda4176b)
1*b0d17251Schristos /*
2*b0d17251Schristos  * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
3*b0d17251Schristos  *
4*b0d17251Schristos  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*b0d17251Schristos  * this file except in compliance with the License.  You can obtain a copy
6*b0d17251Schristos  * in the file LICENSE in the source distribution or at
7*b0d17251Schristos  * https://www.openssl.org/source/license.html
8*b0d17251Schristos  */
9*b0d17251Schristos 
10*b0d17251Schristos #include "internal/deprecated.h"
11*b0d17251Schristos 
12*b0d17251Schristos #include <openssl/rsa.h>
13*b0d17251Schristos #include <openssl/core.h>
14*b0d17251Schristos #include <openssl/core_names.h>
15*b0d17251Schristos #include <openssl/obj_mac.h>
16*b0d17251Schristos #include "prov/securitycheck.h"
17*b0d17251Schristos #include "internal/nelem.h"
18*b0d17251Schristos 
19*b0d17251Schristos /* Disable the security checks in the default provider */
ossl_securitycheck_enabled(OSSL_LIB_CTX * libctx)20*b0d17251Schristos int ossl_securitycheck_enabled(OSSL_LIB_CTX *libctx)
21*b0d17251Schristos {
22*b0d17251Schristos     return 0;
23*b0d17251Schristos }
24*b0d17251Schristos 
ossl_digest_rsa_sign_get_md_nid(OSSL_LIB_CTX * ctx,const EVP_MD * md,ossl_unused int sha1_allowed)25*b0d17251Schristos int ossl_digest_rsa_sign_get_md_nid(OSSL_LIB_CTX *ctx, const EVP_MD *md,
26*b0d17251Schristos                                     ossl_unused int sha1_allowed)
27*b0d17251Schristos {
28*b0d17251Schristos     int mdnid;
29*b0d17251Schristos 
30*b0d17251Schristos     static const OSSL_ITEM name_to_nid[] = {
31*b0d17251Schristos         { NID_md5,       OSSL_DIGEST_NAME_MD5       },
32*b0d17251Schristos         { NID_md5_sha1,  OSSL_DIGEST_NAME_MD5_SHA1  },
33*b0d17251Schristos         { NID_md2,       OSSL_DIGEST_NAME_MD2       },
34*b0d17251Schristos         { NID_md4,       OSSL_DIGEST_NAME_MD4       },
35*b0d17251Schristos         { NID_mdc2,      OSSL_DIGEST_NAME_MDC2      },
36*b0d17251Schristos         { NID_ripemd160, OSSL_DIGEST_NAME_RIPEMD160 },
37*b0d17251Schristos     };
38*b0d17251Schristos 
39*b0d17251Schristos     mdnid = ossl_digest_get_approved_nid_with_sha1(ctx, md, 1);
40*b0d17251Schristos     if (mdnid == NID_undef)
41*b0d17251Schristos         mdnid = ossl_digest_md_to_nid(md, name_to_nid, OSSL_NELEM(name_to_nid));
42*b0d17251Schristos     return mdnid;
43*b0d17251Schristos }
44