xref: /freebsd/crypto/openssl/providers/common/der/der_dsa_sig.c (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2020 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 /*
11*b077aed3SPierre Pronchery  * DSA low level APIs are deprecated for public use, but still ok for
12*b077aed3SPierre Pronchery  * internal use.
13*b077aed3SPierre Pronchery  */
14*b077aed3SPierre Pronchery #include "internal/deprecated.h"
15*b077aed3SPierre Pronchery 
16*b077aed3SPierre Pronchery #include <openssl/obj_mac.h>
17*b077aed3SPierre Pronchery #include "internal/packet.h"
18*b077aed3SPierre Pronchery #include "prov/der_dsa.h"
19*b077aed3SPierre Pronchery 
20*b077aed3SPierre Pronchery #define MD_CASE(name)                                                   \
21*b077aed3SPierre Pronchery     case NID_##name:                                                    \
22*b077aed3SPierre Pronchery         precompiled = ossl_der_oid_id_dsa_with_##name;                  \
23*b077aed3SPierre Pronchery         precompiled_sz = sizeof(ossl_der_oid_id_dsa_with_##name);       \
24*b077aed3SPierre Pronchery         break;
25*b077aed3SPierre Pronchery 
ossl_DER_w_algorithmIdentifier_DSA_with_MD(WPACKET * pkt,int tag,DSA * dsa,int mdnid)26*b077aed3SPierre Pronchery int ossl_DER_w_algorithmIdentifier_DSA_with_MD(WPACKET *pkt, int tag,
27*b077aed3SPierre Pronchery                                                DSA *dsa, int mdnid)
28*b077aed3SPierre Pronchery {
29*b077aed3SPierre Pronchery     const unsigned char *precompiled = NULL;
30*b077aed3SPierre Pronchery     size_t precompiled_sz = 0;
31*b077aed3SPierre Pronchery 
32*b077aed3SPierre Pronchery     switch (mdnid) {
33*b077aed3SPierre Pronchery         MD_CASE(sha1);
34*b077aed3SPierre Pronchery         MD_CASE(sha224);
35*b077aed3SPierre Pronchery         MD_CASE(sha256);
36*b077aed3SPierre Pronchery         MD_CASE(sha384);
37*b077aed3SPierre Pronchery         MD_CASE(sha512);
38*b077aed3SPierre Pronchery         MD_CASE(sha3_224);
39*b077aed3SPierre Pronchery         MD_CASE(sha3_256);
40*b077aed3SPierre Pronchery         MD_CASE(sha3_384);
41*b077aed3SPierre Pronchery         MD_CASE(sha3_512);
42*b077aed3SPierre Pronchery     default:
43*b077aed3SPierre Pronchery         return 0;
44*b077aed3SPierre Pronchery     }
45*b077aed3SPierre Pronchery 
46*b077aed3SPierre Pronchery     return ossl_DER_w_begin_sequence(pkt, tag)
47*b077aed3SPierre Pronchery         /* No parameters (yet?) */
48*b077aed3SPierre Pronchery         && ossl_DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)
49*b077aed3SPierre Pronchery         && ossl_DER_w_end_sequence(pkt, tag);
50*b077aed3SPierre Pronchery }
51