der_dsa_sig.c 1.5 KB

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