TestCa.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef TESTCA_H
  16. #define TESTCA_H
  17. #include "rust/cjdns_sys/RTypes.h"
  18. #include "interface/Iface.h"
  19. #include "util/events/EventBase.h"
  20. #include "crypto/random/Random.h"
  21. #include "util/Linker.h"
  22. Linker_require("crypto/test/TestCa.c")
  23. typedef struct TestCa_s TestCa_t;
  24. typedef struct TestCa_Session_s {
  25. struct Iface plaintext;
  26. struct Iface ciphertext;
  27. } TestCa_Session_t;
  28. enum TestCa_Config {
  29. TestCa_Config_OLD,
  30. TestCa_Config_OLD_NEW,
  31. TestCa_Config_NOISE
  32. };
  33. TestCa_t* TestCa_new(
  34. Allocator_t *allocator,
  35. const uint8_t *privateKey,
  36. EventBase_t* eventBase,
  37. struct Log* logger,
  38. struct Random* rand0,
  39. struct Random* rand1,
  40. enum TestCa_Config cfg);
  41. int TestCa_addUser_ipv6(
  42. String_t *password,
  43. String_t *login,
  44. uint8_t *ipv6,
  45. TestCa_t *ca);
  46. int TestCa_removeUsers(TestCa_t* context, String_t* user);
  47. RTypes_StrList_t* TestCa_getUsers(const TestCa_t *ca, Allocator_t *alloc);
  48. TestCa_Session_t * TestCa_newSession(
  49. TestCa_t *ca,
  50. Allocator_t *alloc,
  51. const uint8_t *herPublicKey,
  52. bool requireAuth,
  53. char *name,
  54. bool useNoise);
  55. void TestCa_setAuth(const String_t *password, const String_t *login, TestCa_Session_t *caSession);
  56. void TestCa_resetIfTimeout(TestCa_Session_t *session);
  57. void TestCa_reset(TestCa_Session_t *session);
  58. RTypes_CryptoAuth_State_t TestCa_getState(TestCa_Session_t *session);
  59. void TestCa_getHerPubKey(TestCa_Session_t *session, uint8_t* buf);
  60. void TestCa_getPubKey(
  61. TestCa_t *ca,
  62. uint8_t* buf);
  63. #endif