From 7f67e79ddcacf9c0f98ae9749bc1c61d75570ce1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 4 Jan 2009 14:21:20 +0000 Subject: get rid of some mallocs and mpz_inits at cipher --- src/cipher.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/cipher.h') diff --git a/src/cipher.h b/src/cipher.h index 036eb72..137540b 100644 --- a/src/cipher.h +++ b/src/cipher.h @@ -39,7 +39,7 @@ #include #include "key_derivation.h" #else -typedef u_int8_t* key_derivation_t; +typedef u_int8_t key_derivation_t; #endif enum cipher_type_enum { c_unknown, c_null, c_aes_ctr }; @@ -50,9 +50,7 @@ struct cipher_struct { u_int16_t key_length_; buffer_t key_; buffer_t salt_; -#ifndef NO_CRYPT - gcry_cipher_hd_t handle_; -#endif + void* params_; }; typedef struct cipher_struct cipher_t; @@ -66,9 +64,20 @@ int32_t cipher_null_crypt(u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t #ifndef NO_CRYPT +struct cipher_aesctr_param_struct { + gcry_cipher_hd_t handle_; + buffer_t ctr_; +#ifndef NO_LIBGMP + mpz_t mp_ctr; + mpz_t mp_sid_mux; + mpz_t mp_seq; +#endif +}; +typedef struct cipher_aesctr_param_struct cipher_aesctr_param_t; + int cipher_aesctr_init(cipher_t* c); void cipher_aesctr_close(cipher_t* c); -buffer_t cipher_aesctr_calc_ctr(cipher_t* c, key_derivation_t* kd, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux); +int cipher_aesctr_calc_ctr(cipher_t* c, key_derivation_t* kd, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux); int32_t cipher_aesctr_crypt(cipher_t* c, key_derivation_t* kd, u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t olen, seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux); #endif -- cgit v1.2.3