crypto_format.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Copyright (c) 2001, Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2017, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef TOR_CRYPTO_FORMAT_H
  7. #define TOR_CRYPTO_FORMAT_H
  8. #include "testsupport.h"
  9. #include "torint.h"
  10. #include "crypto_ed25519.h"
  11. int crypto_write_tagged_contents_to_file(const char *fname,
  12. const char *typestring,
  13. const char *tag,
  14. const uint8_t *data,
  15. size_t datalen);
  16. ssize_t crypto_read_tagged_contents_from_file(const char *fname,
  17. const char *typestring,
  18. char **tag_out,
  19. uint8_t *data_out,
  20. ssize_t data_out_len);
  21. #define ED25519_BASE64_LEN 43
  22. int ed25519_public_from_base64(ed25519_public_key_t *pkey,
  23. const char *input);
  24. int ed25519_public_to_base64(char *output,
  25. const ed25519_public_key_t *pkey);
  26. const char *ed25519_fmt(const ed25519_public_key_t *pkey);
  27. /* XXXX move these to crypto_format.h */
  28. #define ED25519_SIG_BASE64_LEN 86
  29. int ed25519_signature_from_base64(ed25519_signature_t *sig,
  30. const char *input);
  31. int ed25519_signature_to_base64(char *output,
  32. const ed25519_signature_t *sig);
  33. int digest_to_base64(char *d64, const char *digest);
  34. int digest_from_base64(char *digest, const char *d64);
  35. int digest256_to_base64(char *d64, const char *digest);
  36. int digest256_from_base64(char *digest, const char *d64);
  37. #endif