2
0

der_dsa_sig.c 1.4 KB

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