TestCa.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 "benc/String.h"
  18. #include "rust/cjdns_sys/RTypes.h"
  19. #include "interface/Iface.h"
  20. #include "util/events/EventBase.h"
  21. #include "crypto/random/Random.h"
  22. #include "util/Linker.h"
  23. Linker_require("crypto/test/TestCa.c")
  24. typedef struct TestCa_s TestCa_t;
  25. typedef struct TestCa_Session_s {
  26. struct Iface plaintext;
  27. struct Iface ciphertext;
  28. } TestCa_Session_t;
  29. enum TestCa_Config {
  30. TestCa_Config_OLD,
  31. TestCa_Config_OLD_NEW,
  32. TestCa_Config_NOISE
  33. };
  34. TestCa_t* TestCa_new(
  35. Allocator_t *allocator,
  36. const uint8_t *privateKey,
  37. struct EventBase* eventBase,
  38. struct Log* logger,
  39. struct Random* rand0,
  40. struct Random* rand1,
  41. enum TestCa_Config cfg);
  42. int TestCa_addUser_ipv6(
  43. String_t *password,
  44. String_t *login,
  45. uint8_t *ipv6,
  46. TestCa_t *ca);
  47. int TestCa_removeUsers(TestCa_t* context, String_t* user);
  48. RTypes_StrList_t* TestCa_getUsers(const TestCa_t *ca, Allocator_t *alloc);
  49. TestCa_Session_t * TestCa_newSession(
  50. TestCa_t *ca,
  51. Allocator_t *alloc,
  52. const uint8_t *herPublicKey,
  53. bool requireAuth,
  54. char *name,
  55. bool useNoise);
  56. void TestCa_setAuth(const String_t *password, const String_t *login, TestCa_Session_t *caSession);
  57. void TestCa_resetIfTimeout(TestCa_Session_t *session);
  58. void TestCa_reset(TestCa_Session_t *session);
  59. RTypes_CryptoAuth_State_t TestCa_getState(TestCa_Session_t *session);
  60. void TestCa_getHerPubKey(TestCa_Session_t *session, uint8_t* buf);
  61. void TestCa_getPubKey(
  62. TestCa_t *ca,
  63. uint8_t* buf);
  64. #endif