Skip to content

Commit

Permalink
lib/crypto: make it possible to use only parts of aes.[ch]
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>

Autobuild-User(master): Jeremy Allison <[email protected]>
Autobuild-Date(master): Thu Aug 27 23:23:54 CEST 2015 on sn-devel-104
  • Loading branch information
metze-samba authored and jrasamba committed Aug 27, 2015
1 parent aaad9e9 commit d9166eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/crypto/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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 */
7 changes: 7 additions & 0 deletions lib/crypto/aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit d9166eb

Please sign in to comment.