diff options
author | Christian Pointner <equinox@anytun.org> | 2009-01-04 22:31:33 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-01-04 22:31:33 +0000 |
commit | 4bdb7d2512e65eab86559ad8fb011e1b359b0425 (patch) | |
tree | f59fdc75bd03e5b912ee91ad1e3681191043825f /src/cipher.h | |
parent | added libgmp free ctr calc implementation to key derivation (diff) |
added libgmp free calc ctr implementation to cipher
Diffstat (limited to 'src/cipher.h')
-rw-r--r-- | src/cipher.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/cipher.h b/src/cipher.h index 137540b..3e172a2 100644 --- a/src/cipher.h +++ b/src/cipher.h @@ -64,13 +64,45 @@ int32_t cipher_null_crypt(u_int8_t* in, u_int32_t ilen, u_int8_t* out, u_int32_t #ifndef NO_CRYPT + +#define C_AES_DEFAULT_KEY_LENGTH 128 +#define C_AES_CTR_LENGTH 16 +#define C_AES_CTR_ZERO_LENGTH 2 +#ifdef NO_LIBGMP +union __attribute__ ((__packed__)) cipher_aesctr_ctr_buf_union { + u_int8_t buf_[C_AES_CTR_LENGTH]; + struct __attribute__ ((__packed__)) { + u_int8_t buf_[C_AES_CTR_LENGTH - C_AES_CTR_ZERO_LENGTH]; + u_int8_t zero_[C_AES_CTR_ZERO_LENGTH]; + } salt_; + struct __attribute__ ((__packed__)) { + u_int8_t fill_[C_AES_CTR_LENGTH - sizeof(mux_t) - sizeof(sender_id_t) - 2 - sizeof(seq_nr_t) - C_AES_CTR_ZERO_LENGTH]; + mux_t mux_; + sender_id_t sender_id_; + u_int8_t empty_[2]; + seq_nr_t seq_nr_; + u_int8_t zero_[C_AES_CTR_ZERO_LENGTH]; + } params_; +}; +typedef union cipher_aesctr_ctr_buf_union cipher_aesctr_ctr_buf_t; + +struct cipher_aesctr_ctr_struct { + u_int32_t length_; + u_int8_t* buf_; + cipher_aesctr_ctr_buf_t ctr_; +}; +typedef struct cipher_aesctr_ctr_struct cipher_aesctr_ctr_t; +#endif + struct cipher_aesctr_param_struct { gcry_cipher_hd_t handle_; - buffer_t ctr_; #ifndef NO_LIBGMP + buffer_t ctr_; mpz_t mp_ctr; mpz_t mp_sid_mux; mpz_t mp_seq; +#else + cipher_aesctr_ctr_t ctr_; #endif }; typedef struct cipher_aesctr_param_struct cipher_aesctr_param_t; |