/src/openssl/providers/common/der/der_rsa_sig.c
Line  | Count  | Source (jump to first uncovered line)  | 
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  |  |  | 
10  |  | #include <openssl/obj_mac.h>  | 
11  |  | #include "internal/packet.h"  | 
12  |  | #include "prov/der_rsa.h"  | 
13  |  | #include "prov/der_digests.h"  | 
14  |  |  | 
15  |  | /* Aliases so we can have a uniform MD_with_RSA_CASE */  | 
16  |  | #define ossl_der_oid_sha3_224WithRSAEncryption \  | 
17  | 0  |     ossl_der_oid_id_rsassa_pkcs1_v1_5_with_sha3_224  | 
18  |  | #define ossl_der_oid_sha3_256WithRSAEncryption \  | 
19  | 0  |     ossl_der_oid_id_rsassa_pkcs1_v1_5_with_sha3_256  | 
20  |  | #define ossl_der_oid_sha3_384WithRSAEncryption \  | 
21  | 0  |     ossl_der_oid_id_rsassa_pkcs1_v1_5_with_sha3_384  | 
22  |  | #define ossl_der_oid_sha3_512WithRSAEncryption \  | 
23  | 0  |     ossl_der_oid_id_rsassa_pkcs1_v1_5_with_sha3_512  | 
24  |  | #define ossl_der_oid_mdc2WithRSAEncryption \  | 
25  | 0  |     ossl_der_oid_mdc2WithRSASignature  | 
26  |  |  | 
27  |  | #define MD_with_RSA_CASE(name, var)                                     \  | 
28  | 0  |     case NID_##name:                                                    \  | 
29  | 0  |         var = ossl_der_oid_##name##WithRSAEncryption;                   \  | 
30  | 0  |         var##_sz = sizeof(ossl_der_oid_##name##WithRSAEncryption);      \  | 
31  | 0  |         break;  | 
32  |  |  | 
33  |  | int ossl_DER_w_algorithmIdentifier_MDWithRSAEncryption(WPACKET *pkt, int tag,  | 
34  |  |                                                        int mdnid)  | 
35  | 0  | { | 
36  | 0  |     const unsigned char *precompiled = NULL;  | 
37  | 0  |     size_t precompiled_sz = 0;  | 
38  |  | 
  | 
39  | 0  |     switch (mdnid) { | 
40  | 0  | #ifndef FIPS_MODULE  | 
41  | 0  |         MD_with_RSA_CASE(md2, precompiled);  | 
42  | 0  |         MD_with_RSA_CASE(md5, precompiled);  | 
43  | 0  |         MD_with_RSA_CASE(md4, precompiled);  | 
44  | 0  |         MD_with_RSA_CASE(ripemd160, precompiled);  | 
45  | 0  |         MD_with_RSA_CASE(mdc2, precompiled);  | 
46  | 0  | #endif  | 
47  | 0  |         MD_with_RSA_CASE(sha1, precompiled);  | 
48  | 0  |         MD_with_RSA_CASE(sha224, precompiled);  | 
49  | 0  |         MD_with_RSA_CASE(sha256, precompiled);  | 
50  | 0  |         MD_with_RSA_CASE(sha384, precompiled);  | 
51  | 0  |         MD_with_RSA_CASE(sha512, precompiled);  | 
52  | 0  |         MD_with_RSA_CASE(sha512_224, precompiled);  | 
53  | 0  |         MD_with_RSA_CASE(sha512_256, precompiled);  | 
54  | 0  |         MD_with_RSA_CASE(sha3_224, precompiled);  | 
55  | 0  |         MD_with_RSA_CASE(sha3_256, precompiled);  | 
56  | 0  |         MD_with_RSA_CASE(sha3_384, precompiled);  | 
57  | 0  |         MD_with_RSA_CASE(sha3_512, precompiled);  | 
58  | 0  |     default:  | 
59  |  |         /*  | 
60  |  |          * Hash algorithms for which we do not have a valid OID  | 
61  |  |          * such as md5sha1 will just fail to provide the der encoding.  | 
62  |  |          * That does not prevent producing signatures if OID is not needed.  | 
63  |  |          */  | 
64  | 0  |         return -1;  | 
65  | 0  |     }  | 
66  |  |  | 
67  | 0  |     return ossl_DER_w_begin_sequence(pkt, tag)  | 
68  |  |         /* PARAMETERS, always NULL according to current standards */  | 
69  | 0  |         && ossl_DER_w_null(pkt, -1)  | 
70  |  |         /* OID */  | 
71  | 0  |         && ossl_DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)  | 
72  | 0  |         && ossl_DER_w_end_sequence(pkt, tag);  | 
73  | 0  | }  |