2
0

tb_dsa.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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 "eng_local.h"
  10. static ENGINE_TABLE *dsa_table = NULL;
  11. static const int dummy_nid = 1;
  12. void ENGINE_unregister_DSA(ENGINE *e)
  13. {
  14. engine_table_unregister(&dsa_table, e);
  15. }
  16. static void engine_unregister_all_DSA(void)
  17. {
  18. engine_table_cleanup(&dsa_table);
  19. }
  20. int ENGINE_register_DSA(ENGINE *e)
  21. {
  22. if (e->dsa_meth)
  23. return engine_table_register(&dsa_table,
  24. engine_unregister_all_DSA, e, &dummy_nid,
  25. 1, 0);
  26. return 1;
  27. }
  28. void ENGINE_register_all_DSA(void)
  29. {
  30. ENGINE *e;
  31. for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
  32. ENGINE_register_DSA(e);
  33. }
  34. int ENGINE_set_default_DSA(ENGINE *e)
  35. {
  36. if (e->dsa_meth)
  37. return engine_table_register(&dsa_table,
  38. engine_unregister_all_DSA, e, &dummy_nid,
  39. 1, 1);
  40. return 1;
  41. }
  42. /*
  43. * Exposed API function to get a functional reference from the implementation
  44. * table (ie. try to get a functional reference from the tabled structural
  45. * references).
  46. */
  47. ENGINE *ENGINE_get_default_DSA(void)
  48. {
  49. return engine_table_select(&dsa_table, dummy_nid);
  50. }
  51. /* Obtains an DSA implementation from an ENGINE functional reference */
  52. const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e)
  53. {
  54. return e->dsa_meth;
  55. }
  56. /* Sets an DSA implementation in an ENGINE structure */
  57. int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth)
  58. {
  59. e->dsa_meth = dsa_meth;
  60. return 1;
  61. }