mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
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
This commit is contained in:
parent
aaad9e9618
commit
d9166eb2d7
@ -32,10 +32,11 @@
|
||||
*/
|
||||
|
||||
#include "replace.h"
|
||||
|
||||
#include "rijndael-alg-fst.h"
|
||||
#include "aes.h"
|
||||
|
||||
#ifdef SAMBA_RIJNDAEL
|
||||
#include "rijndael-alg-fst.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 */
|
||||
|
@ -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])
|
||||
|
Loading…
Reference in New Issue
Block a user