summaryrefslogtreecommitdiff
path: root/lib/crypto
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2015-08-12 12:58:49 +0200
committerJeremy Allison <jra@samba.org>2015-08-27 23:23:54 +0200
commitd9166eb2d7880d0717dbf231b02d50c2a331827e (patch)
treed2a87bd84b4556df2552858e53ab2c4bad7823c7 /lib/crypto
parentaaad9e9618686066ed24fef43cb3872fb9861678 (diff)
downloadsamba-d9166eb2d7880d0717dbf231b02d50c2a331827e.tar.gz
lib/crypto: make it possible to use only parts of aes.[ch]
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
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/aes.c8
-rw-r--r--lib/crypto/aes.h7
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/crypto/aes.c b/lib/crypto/aes.c
index f7f96889c12..800a97ee705 100644
--- a/lib/crypto/aes.c
+++ b/lib/crypto/aes.c
@@ -32,9 +32,10 @@
*/
#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 */
diff --git a/lib/crypto/aes.h b/lib/crypto/aes.h
index 7487486370a..48ea764d514 100644
--- a/lib/crypto/aes.h
+++ b/lib/crypto/aes.h
@@ -36,6 +36,11 @@
#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])