Skip to content

Commit

Permalink
ARM: move AES typedefs and function prototypes to separate header
Browse files Browse the repository at this point in the history
Put the struct definitions for AES keys and the asm function prototypes in a
separate header and export the asm functions from the module.
This allows other drivers to use them directly.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
  • Loading branch information
Ard Biesheuvel committed Oct 4, 2013
1 parent cf154b7 commit 5ce26f3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
22 changes: 6 additions & 16 deletions arch/arm/crypto/aes_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,12 @@
#include <linux/crypto.h>
#include <crypto/aes.h>

#define AES_MAXNR 14
#include "aes_glue.h"

typedef struct {
unsigned int rd_key[4 *(AES_MAXNR + 1)];
int rounds;
} AES_KEY;

struct AES_CTX {
AES_KEY enc_key;
AES_KEY dec_key;
};

asmlinkage void AES_encrypt(const u8 *in, u8 *out, AES_KEY *ctx);
asmlinkage void AES_decrypt(const u8 *in, u8 *out, AES_KEY *ctx);
asmlinkage int private_AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key);
asmlinkage int private_AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key);
EXPORT_SYMBOL(AES_encrypt);
EXPORT_SYMBOL(AES_decrypt);
EXPORT_SYMBOL(private_AES_set_encrypt_key);
EXPORT_SYMBOL(private_AES_set_decrypt_key);

static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
{
Expand Down Expand Up @@ -81,7 +71,7 @@ static struct crypto_alg aes_alg = {
.cipher = {
.cia_min_keysize = AES_MIN_KEY_SIZE,
.cia_max_keysize = AES_MAX_KEY_SIZE,
.cia_setkey = aes_set_key,
.cia_setkey = aes_set_key,
.cia_encrypt = aes_encrypt,
.cia_decrypt = aes_decrypt
}
Expand Down
19 changes: 19 additions & 0 deletions arch/arm/crypto/aes_glue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#define AES_MAXNR 14

struct AES_KEY {
unsigned int rd_key[4 * (AES_MAXNR + 1)];
int rounds;
};

struct AES_CTX {
struct AES_KEY enc_key;
struct AES_KEY dec_key;
};

asmlinkage void AES_encrypt(const u8 *in, u8 *out, struct AES_KEY *ctx);
asmlinkage void AES_decrypt(const u8 *in, u8 *out, struct AES_KEY *ctx);
asmlinkage int private_AES_set_decrypt_key(const unsigned char *userKey,
const int bits, struct AES_KEY *key);
asmlinkage int private_AES_set_encrypt_key(const unsigned char *userKey,
const int bits, struct AES_KEY *key);

0 comments on commit 5ce26f3

Please sign in to comment.