summaryrefslogtreecommitdiff
path: root/src/common/crypto.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-09-19 15:53:41 +0000
committerNick Mathewson <nickm@torproject.org>2007-09-19 15:53:41 +0000
commit5f7950e8744a8c59ede2da56d99d0e878f00d18a (patch)
treece5f17a5dbc7fafb4ae03e44c285f627c12ff722 /src/common/crypto.h
parent7e93139a85b6f912c11d8e26bc512d9330008278 (diff)
downloadtor-5f7950e8744a8c59ede2da56d99d0e878f00d18a.tar.gz
tor-5f7950e8744a8c59ede2da56d99d0e878f00d18a.zip
r15172@catbus: nickm | 2007-09-19 11:50:02 -0400
New (untested) code to implement AES-with-IV. Currently, IVs are generated randomly. Once tested, should be (almost) a drop-in replacement for the CBC functions. svn:r11519
Diffstat (limited to 'src/common/crypto.h')
-rw-r--r--src/common/crypto.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 1d1f758fcb..b548978aaa 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -21,6 +21,8 @@
#define DIGEST_LEN 20
/** Length of our symmetric cipher's keys. */
#define CIPHER_KEY_LEN 16
+/** Length of our symmetric cipher's IV. */
+#define CIPHER_IV_LEN 16
/** Length of our public keys. */
#define PK_BYTES (1024/8)
/** Length of our DH keys. */
@@ -115,6 +117,8 @@ int crypto_pk_check_fingerprint_syntax(const char *s);
/* symmetric crypto */
int crypto_cipher_generate_key(crypto_cipher_env_t *env);
int crypto_cipher_set_key(crypto_cipher_env_t *env, const char *key);
+void crypto_cipher_generate_iv(char *iv_out);
+int crypto_cipher_set_iv(crypto_cipher_env_t *env, const char *iv);
const char *crypto_cipher_get_key(crypto_cipher_env_t *env);
int crypto_cipher_encrypt_init_cipher(crypto_cipher_env_t *env);
int crypto_cipher_decrypt_init_cipher(crypto_cipher_env_t *env);
@@ -124,6 +128,13 @@ int crypto_cipher_encrypt(crypto_cipher_env_t *env, char *to,
int crypto_cipher_decrypt(crypto_cipher_env_t *env, char *to,
const char *from, size_t fromlen);
+int crypto_cipher_encrypt_with_iv(crypto_cipher_env_t *env,
+ char *to, size_t tolen,
+ const char *from, size_t fromlen);
+int crypto_cipher_decrypt_with_iv(crypto_cipher_env_t *env,
+ char *to, size_t tolen,
+ const char *from, size_t fromlen);
+
int crypto_cipher_encrypt_cbc(const char *key, char *to, size_t tolen,
const char *from, size_t fromlen);
int crypto_cipher_decrypt_cbc(const char *key, char *to, size_t tolen,