summaryrefslogtreecommitdiff
path: root/src/cipher.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cipher.h')
-rw-r--r--src/cipher.h39
1 files changed, 12 insertions, 27 deletions
diff --git a/src/cipher.h b/src/cipher.h
index 3e172a2..2cf45d6 100644
--- a/src/cipher.h
+++ b/src/cipher.h
@@ -65,45 +65,30 @@ 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];
+#define C_AESCTR_DEFAULT_KEY_LENGTH 128
+#define C_AESCTR_CTR_LENGTH 16
+#define C_AESCTR_SALT_LENGTH 14
+
+union __attribute__((__packed__)) cipher_aesctr_ctr_union {
+ u_int8_t buf_[C_AESCTR_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];
+ u_int8_t buf_[C_AESCTR_SALT_LENGTH];
+ u_int16_t zero_;
} 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];
+ struct __attribute__((__packed__)) {
+ u_int8_t fill_[C_AESCTR_SALT_LENGTH - sizeof(mux_t) - sizeof(sender_id_t) - 2 - sizeof(seq_nr_t)];
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];
+ u_int16_t zero_;
} 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
+typedef union cipher_aesctr_ctr_union cipher_aesctr_ctr_t;
struct cipher_aesctr_param_struct {
gcry_cipher_hd_t handle_;
-#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;