lib/crypto: make it possible to use only parts of aes.[ch]
authorStefan Metzmacher <metze@samba.org>
Wed, 12 Aug 2015 10:58:49 +0000 (12:58 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 27 Aug 2015 21:23:54 +0000 (23:23 +0200)
This can be used in order to optimize some parts later.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11451

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Aug 27 23:23:54 CEST 2015 on sn-devel-104

lib/crypto/aes.c
lib/crypto/aes.h

index f7f96889c127535daaec8236dc91354f442199b0..800a97ee705ed201708f9fe62efdd03754b10966 100644 (file)
  */
 
 #include "replace.h"
+#include "aes.h"
 
+#ifdef SAMBA_RIJNDAEL
 #include "rijndael-alg-fst.h"
-#include "aes.h"
 
 int
 AES_set_encrypt_key(const unsigned char *userkey, const int bits, AES_KEY *key)
@@ -65,7 +66,9 @@ AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key)
 {
     rijndaelDecrypt(key->key, key->rounds, in, out);
 }
+#endif /* SAMBA_RIJNDAEL */
 
+#ifdef SAMBA_AES_CBC_ENCRYPT
 void
 AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
                unsigned long size, const AES_KEY *key,
@@ -112,7 +115,9 @@ AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
        }
     }
 }
+#endif /* SAMBA_AES_CBC_ENCRYPT */
 
+#ifdef SAMBA_AES_CFB8_ENCRYPT
 void
 AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
                  unsigned long size, const AES_KEY *key,
@@ -135,3 +140,4 @@ AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
         memcpy(iv, &tmp[1], AES_BLOCK_SIZE);
     }
 }
+#endif /* SAMBA_AES_CFB8_ENCRYPT */
index 7487486370acb896329c25627e64c50f1a3608be..48ea764d514eb03a05feb14e6b159fe78d95e39a 100644 (file)
 #ifndef LIB_CRYPTO_AES_H
 #define LIB_CRYPTO_AES_H 1
 
+#define SAMBA_RIJNDAEL 1
+#define SAMBA_AES_CBC_ENCRYPT 1
+#define SAMBA_AES_CFB8_ENCRYPT 1
+#define SAMBA_AES_BLOCK_XOR 1
+
 /* symbol renaming */
 #define AES_set_encrypt_key samba_AES_set_encrypt_key
 #define AES_set_decrypt_key samba_AES_decrypt_key
@@ -84,6 +89,7 @@ void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
 }
 #endif
 
+#ifdef SAMBA_AES_BLOCK_XOR
 static inline void aes_block_xor(const uint8_t in1[AES_BLOCK_SIZE],
                                 const uint8_t in2[AES_BLOCK_SIZE],
                                 uint8_t out[AES_BLOCK_SIZE])
@@ -111,6 +117,7 @@ static inline void aes_block_xor(const uint8_t in1[AES_BLOCK_SIZE],
                memcpy(out, o, AES_BLOCK_SIZE);
        }
 }
+#endif /* SAMBA_AES_BLOCK_XOR */
 
 static inline void aes_block_lshift(const uint8_t in[AES_BLOCK_SIZE],
                                    uint8_t out[AES_BLOCK_SIZE])