aboutsummaryrefslogtreecommitdiff
path: root/src/common/crypto_format.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-07-31 11:21:34 -0400
committerNick Mathewson <nickm@torproject.org>2015-07-31 11:21:34 -0400
commit347fe449fe818f97e0f3ba29dd0a08ff6d39081e (patch)
tree9397c155e38a7e7084b91c55f1c57f576aa42b25 /src/common/crypto_format.h
parent8c83e8cec0e8d4c29577ae7c7b27637e5b91c99e (diff)
downloadtor-347fe449fe818f97e0f3ba29dd0a08ff6d39081e.tar.gz
tor-347fe449fe818f97e0f3ba29dd0a08ff6d39081e.zip
Move formatting functions around.
The base64 and base32 functions used to be in crypto.c; crypto_format.h had no header; some general-purpose functions were in crypto_curve25519.c. This patch makes a {crypto,util}_format.[ch], and puts more functions there. Small modules are beautiful!
Diffstat (limited to 'src/common/crypto_format.h')
-rw-r--r--src/common/crypto_format.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/common/crypto_format.h b/src/common/crypto_format.h
new file mode 100644
index 0000000000..b972d3f509
--- /dev/null
+++ b/src/common/crypto_format.h
@@ -0,0 +1,46 @@
+/* Copyright (c) 2001, Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2015, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_CRYPTO_FORMAT_H
+#define TOR_CRYPTO_FORMAT_H
+
+#include "testsupport.h"
+#include "torint.h"
+#include "crypto_ed25519.h"
+
+int crypto_write_tagged_contents_to_file(const char *fname,
+ const char *typestring,
+ const char *tag,
+ const uint8_t *data,
+ size_t datalen);
+
+ssize_t crypto_read_tagged_contents_from_file(const char *fname,
+ const char *typestring,
+ char **tag_out,
+ uint8_t *data_out,
+ ssize_t data_out_len);
+
+#define ED25519_BASE64_LEN 43
+int ed25519_public_from_base64(ed25519_public_key_t *pkey,
+ const char *input);
+int ed25519_public_to_base64(char *output,
+ const ed25519_public_key_t *pkey);
+
+/* XXXX move these to crypto_format.h */
+#define ED25519_SIG_BASE64_LEN 86
+
+int ed25519_signature_from_base64(ed25519_signature_t *sig,
+ const char *input);
+int ed25519_signature_to_base64(char *output,
+ const ed25519_signature_t *sig);
+
+int digest_to_base64(char *d64, const char *digest);
+int digest_from_base64(char *digest, const char *d64);
+int digest256_to_base64(char *d64, const char *digest);
+int digest256_from_base64(char *digest, const char *d64);
+
+#endif
+