You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rdns_curve.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2014, Vsevolod Stakhov
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY AUTHOR ''AS IS'' AND ANY
  15. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
  18. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef RDNS_CURVE_H_
  26. #define RDNS_CURVE_H_
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. struct rdns_curve_ctx;
  31. /**
  32. * Create new dnscurve ctx
  33. * @return
  34. */
  35. struct rdns_curve_ctx* rdns_curve_ctx_new (double rekey_interval);
  36. /**
  37. * Add key for server `name`
  38. * @param ctx curve context
  39. * @param name name of server (ip address)
  40. * @param pubkey pubkey bytes (must be `RDSN_CURVE_PUBKEY_LEN`)
  41. */
  42. void rdns_curve_ctx_add_key (struct rdns_curve_ctx *ctx,
  43. const char *name, const unsigned char *pubkey);
  44. /**
  45. * Destroy curve context
  46. * @param ctx
  47. */
  48. void rdns_curve_ctx_destroy (struct rdns_curve_ctx *ctx);
  49. /**
  50. * Register DNSCurve plugin (libsodium should be enabled for this)
  51. * @param resolver
  52. * @param ctx
  53. */
  54. void rdns_curve_register_plugin (struct rdns_resolver *resolver,
  55. struct rdns_curve_ctx *ctx);
  56. /**
  57. * Create DNSCurve key from the base16 encoded string
  58. * @param hex input hex (must be NULL terminated)
  59. * @return a key or NULL (not NULL terminated)
  60. */
  61. unsigned char * rdns_curve_key_from_hex (const char *hex);
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* RDNS_CURVE_H_ */